@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
|
@@ -1,17 +1,17 @@
|
|
|
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("./navigation"), exports);
|
|
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("./navigation"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './router';
|
|
1
|
+
export * from './router';
|
|
@@ -1,17 +1,17 @@
|
|
|
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("./router"), exports);
|
|
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("./router"), exports);
|
|
@@ -57,9 +57,7 @@ declare global {
|
|
|
57
57
|
at: number;
|
|
58
58
|
};
|
|
59
59
|
};
|
|
60
|
-
__VISTA_RSC_ROUTER__?: {
|
|
61
|
-
refresh: () => void;
|
|
62
|
-
prefetch: (url: string) => void;
|
|
60
|
+
__VISTA_RSC_ROUTER__?: RSCNavigationState & {
|
|
63
61
|
resume: (url: string) => void;
|
|
64
62
|
getState: () => {
|
|
65
63
|
pathname: string;
|
|
@@ -121,14 +121,36 @@ function getCallServer() {
|
|
|
121
121
|
}
|
|
122
122
|
return _callServer;
|
|
123
123
|
}
|
|
124
|
-
function
|
|
124
|
+
function flightRequestUrl(pathname, search) {
|
|
125
|
+
const normalized = pathname === '/' ? '' : pathname.replace(/\/$/, '');
|
|
126
|
+
// Static CDNs rewrite `/rsc/docs` → `/rsc/docs.rsc`. Request the extensionless
|
|
127
|
+
// URL so that rewrite is not applied twice (`/rsc/docs.rsc` → `/rsc/docs.rsc.rsc`).
|
|
128
|
+
return `/rsc${normalized}${search}`;
|
|
129
|
+
}
|
|
130
|
+
function hardNavigate(url) {
|
|
131
|
+
if (typeof window === 'undefined')
|
|
132
|
+
return;
|
|
133
|
+
window.location.assign(url);
|
|
134
|
+
}
|
|
135
|
+
function fetchFlight(pathname, search, options = {}) {
|
|
125
136
|
const key = cacheKey(pathname, search);
|
|
126
137
|
const cached = flightCache.get(key);
|
|
127
138
|
if (cached)
|
|
128
139
|
return cached;
|
|
129
140
|
const create = getCreateFromFetch();
|
|
130
|
-
const
|
|
141
|
+
const requestUrl = flightRequestUrl(pathname, search);
|
|
142
|
+
const hardFallback = options.hardFallback !== false;
|
|
143
|
+
const thenable = create(fetch(requestUrl, {
|
|
131
144
|
headers: { Accept: 'text/x-component' },
|
|
145
|
+
}).then((response) => {
|
|
146
|
+
const contentType = response.headers.get('content-type') || '';
|
|
147
|
+
if (!response.ok || contentType.includes('text/html')) {
|
|
148
|
+
if (hardFallback) {
|
|
149
|
+
hardNavigate(`${pathname}${search}`);
|
|
150
|
+
}
|
|
151
|
+
throw new Error(`Flight request failed (${response.status}): ${requestUrl}`);
|
|
152
|
+
}
|
|
153
|
+
return response;
|
|
132
154
|
}), { callServer: getCallServer() });
|
|
133
155
|
// Evict oldest if over limit
|
|
134
156
|
if (flightCache.size >= CACHE_MAX) {
|
|
@@ -148,8 +170,7 @@ function prefetchFlight(pathname, search) {
|
|
|
148
170
|
const key = cacheKey(pathname, search);
|
|
149
171
|
if (flightCache.has(key))
|
|
150
172
|
return;
|
|
151
|
-
|
|
152
|
-
fetchFlight(pathname, search);
|
|
173
|
+
fetchFlight(pathname, search, { hardFallback: false });
|
|
153
174
|
}
|
|
154
175
|
// ---------------------------------------------------------------------------
|
|
155
176
|
// RSCRoot — reads the current Flight thenable
|
|
@@ -157,6 +178,26 @@ function prefetchFlight(pathname, search) {
|
|
|
157
178
|
function RSCRoot({ response }) {
|
|
158
179
|
return React.use(response);
|
|
159
180
|
}
|
|
181
|
+
class FlightNavigationErrorBoundary extends React.Component {
|
|
182
|
+
state = { failed: false };
|
|
183
|
+
static getDerivedStateFromError() {
|
|
184
|
+
return { failed: true };
|
|
185
|
+
}
|
|
186
|
+
componentDidCatch() {
|
|
187
|
+
hardNavigate(this.props.href);
|
|
188
|
+
}
|
|
189
|
+
componentDidUpdate(prevProps) {
|
|
190
|
+
if (prevProps.href !== this.props.href && this.state.failed) {
|
|
191
|
+
this.setState({ failed: false });
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
render() {
|
|
195
|
+
if (this.state.failed) {
|
|
196
|
+
return null;
|
|
197
|
+
}
|
|
198
|
+
return this.props.children;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
160
201
|
function RSCRouter({ initialResponse, initialPathname }) {
|
|
161
202
|
const [flightResponse, setFlightResponse] = React.useState(initialResponse);
|
|
162
203
|
const [pathname, setPathname] = React.useState(initialPathname || (typeof window !== 'undefined' ? window.location.pathname : '/'));
|
|
@@ -164,6 +205,13 @@ function RSCRouter({ initialResponse, initialPathname }) {
|
|
|
164
205
|
? new URLSearchParams(window.location.search)
|
|
165
206
|
: new URLSearchParams());
|
|
166
207
|
const [isPending, startTransition] = React.useTransition();
|
|
208
|
+
const href = `${pathname}${searchParams.toString() ? `?${searchParams.toString()}` : ''}`;
|
|
209
|
+
React.useEffect(() => {
|
|
210
|
+
const initialKey = cacheKey(initialPathname || (typeof window !== 'undefined' ? window.location.pathname : '/'), typeof window !== 'undefined' ? window.location.search : '');
|
|
211
|
+
if (!flightCache.has(initialKey)) {
|
|
212
|
+
flightCache.set(initialKey, initialResponse);
|
|
213
|
+
}
|
|
214
|
+
}, [initialPathname, initialResponse]);
|
|
167
215
|
// Handle browser back/forward
|
|
168
216
|
React.useEffect(() => {
|
|
169
217
|
const onPopState = () => {
|
|
@@ -214,6 +262,33 @@ function RSCRouter({ initialResponse, initialPathname }) {
|
|
|
214
262
|
setFlightResponse(fetchFlight(curPath, curSearch));
|
|
215
263
|
});
|
|
216
264
|
}, []);
|
|
265
|
+
const resume = React.useCallback((url) => {
|
|
266
|
+
const parsed = new URL(url, window.location.origin);
|
|
267
|
+
const nextPath = parsed.pathname;
|
|
268
|
+
const nextSearch = parsed.search;
|
|
269
|
+
const nextUrl = `${nextPath}${nextSearch}`;
|
|
270
|
+
const nextResponse = fetchFlight(nextPath, nextSearch);
|
|
271
|
+
document.documentElement.setAttribute('data-vista-ppr', 'flight-resuming');
|
|
272
|
+
recordRuntimeTrace('rsc-resume-start', { url: nextUrl });
|
|
273
|
+
dispatchRuntimeEvent('vista:rsc-resume-start', { url: nextUrl });
|
|
274
|
+
startTransition(() => {
|
|
275
|
+
setPathname(nextPath);
|
|
276
|
+
setSearchParams(new URLSearchParams(nextSearch));
|
|
277
|
+
setFlightResponse(nextResponse);
|
|
278
|
+
});
|
|
279
|
+
Promise.resolve(nextResponse)
|
|
280
|
+
.then(() => {
|
|
281
|
+
recordRuntimeTrace('rsc-resume-complete', { url: nextUrl });
|
|
282
|
+
dispatchRuntimeEvent('vista:rsc-resume-complete', { url: nextUrl });
|
|
283
|
+
})
|
|
284
|
+
.catch((error) => {
|
|
285
|
+
const message = error && typeof error === 'object' && 'message' in error
|
|
286
|
+
? String(error.message || error)
|
|
287
|
+
: String(error || 'Unknown RSC resume error');
|
|
288
|
+
recordRuntimeTrace('rsc-resume-error', { url: nextUrl, message });
|
|
289
|
+
dispatchRuntimeEvent('vista:rsc-resume-error', { url: nextUrl, message });
|
|
290
|
+
});
|
|
291
|
+
}, []);
|
|
217
292
|
const contextValue = React.useMemo(() => ({
|
|
218
293
|
pathname,
|
|
219
294
|
searchParams,
|
|
@@ -225,59 +300,31 @@ function RSCRouter({ initialResponse, initialPathname }) {
|
|
|
225
300
|
refresh,
|
|
226
301
|
isPending,
|
|
227
302
|
}), [pathname, searchParams, push, replace, back, forward, prefetch, refresh, isPending]);
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
const bridge = {
|
|
233
|
-
refresh,
|
|
234
|
-
prefetch,
|
|
235
|
-
resume: (url) => {
|
|
236
|
-
const parsed = new URL(url, window.location.origin);
|
|
237
|
-
const nextPath = parsed.pathname;
|
|
238
|
-
const nextSearch = parsed.search;
|
|
239
|
-
const nextUrl = `${nextPath}${nextSearch}`;
|
|
240
|
-
const nextResponse = fetchFlight(nextPath, nextSearch);
|
|
241
|
-
document.documentElement.setAttribute('data-vista-ppr', 'flight-resuming');
|
|
242
|
-
recordRuntimeTrace('rsc-resume-start', { url: nextUrl });
|
|
243
|
-
dispatchRuntimeEvent('vista:rsc-resume-start', { url: nextUrl });
|
|
244
|
-
startTransition(() => {
|
|
245
|
-
setPathname(nextPath);
|
|
246
|
-
setSearchParams(new URLSearchParams(nextSearch));
|
|
247
|
-
setFlightResponse(nextResponse);
|
|
248
|
-
});
|
|
249
|
-
Promise.resolve(nextResponse)
|
|
250
|
-
.then(() => {
|
|
251
|
-
recordRuntimeTrace('rsc-resume-complete', { url: nextUrl });
|
|
252
|
-
dispatchRuntimeEvent('vista:rsc-resume-complete', { url: nextUrl });
|
|
253
|
-
})
|
|
254
|
-
.catch((error) => {
|
|
255
|
-
const message = error && typeof error === 'object' && 'message' in error
|
|
256
|
-
? String(error.message || error)
|
|
257
|
-
: String(error || 'Unknown RSC resume error');
|
|
258
|
-
recordRuntimeTrace('rsc-resume-error', { url: nextUrl, message });
|
|
259
|
-
dispatchRuntimeEvent('vista:rsc-resume-error', { url: nextUrl, message });
|
|
260
|
-
});
|
|
261
|
-
},
|
|
303
|
+
if (typeof window !== 'undefined') {
|
|
304
|
+
window.__VISTA_RSC_ROUTER__ = {
|
|
305
|
+
...contextValue,
|
|
306
|
+
resume,
|
|
262
307
|
getState: () => ({
|
|
263
308
|
pathname,
|
|
264
309
|
search: searchParams.toString() ? `?${searchParams.toString()}` : '',
|
|
265
310
|
isPending,
|
|
266
311
|
}),
|
|
267
312
|
};
|
|
268
|
-
|
|
313
|
+
}
|
|
314
|
+
React.useEffect(() => {
|
|
315
|
+
if (typeof window === 'undefined') {
|
|
316
|
+
return;
|
|
317
|
+
}
|
|
269
318
|
recordRuntimeTrace('rsc-router-ready', {
|
|
270
319
|
pathname,
|
|
271
320
|
search: searchParams.toString() ? `?${searchParams.toString()}` : '',
|
|
272
321
|
});
|
|
273
322
|
document.dispatchEvent(new CustomEvent('vista:rsc-router-ready'));
|
|
274
323
|
return () => {
|
|
275
|
-
|
|
276
|
-
delete window.__VISTA_RSC_ROUTER__;
|
|
277
|
-
}
|
|
324
|
+
delete window.__VISTA_RSC_ROUTER__;
|
|
278
325
|
};
|
|
279
|
-
}, [
|
|
280
|
-
return ((0, jsx_runtime_1.jsx)(exports.RSCRouterContext.Provider, { value: contextValue, children: (0, jsx_runtime_1.jsx)(RSCRoot, { response: flightResponse }) }));
|
|
326
|
+
}, []);
|
|
327
|
+
return ((0, jsx_runtime_1.jsx)(exports.RSCRouterContext.Provider, { value: contextValue, children: (0, jsx_runtime_1.jsx)(FlightNavigationErrorBoundary, { href: href, children: (0, jsx_runtime_1.jsx)(RSCRoot, { response: flightResponse }) }) }));
|
|
281
328
|
}
|
|
282
329
|
// ---------------------------------------------------------------------------
|
|
283
330
|
// Hooks — unified versions that work in both RSC and legacy modes
|
|
@@ -287,5 +334,11 @@ function RSCRouter({ initialResponse, initialPathname }) {
|
|
|
287
334
|
* otherwise falls back to null.
|
|
288
335
|
*/
|
|
289
336
|
function useRSCRouter() {
|
|
290
|
-
|
|
337
|
+
const ctx = React.useContext(exports.RSCRouterContext);
|
|
338
|
+
if (ctx)
|
|
339
|
+
return ctx;
|
|
340
|
+
if (typeof window !== 'undefined' && typeof window.__VISTA_RSC_ROUTER__?.push === 'function') {
|
|
341
|
+
return window.__VISTA_RSC_ROUTER__;
|
|
342
|
+
}
|
|
343
|
+
return null;
|
|
291
344
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './rsc-router';
|
|
1
|
+
export * from './rsc-router';
|
|
@@ -1,17 +1,17 @@
|
|
|
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("./rsc-router"), exports);
|
|
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("./rsc-router"), exports);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './script';
|
|
2
|
-
export { default } from './script';
|
|
1
|
+
export * from './script';
|
|
2
|
+
export { default } from './script';
|
|
@@ -1,23 +1,23 @@
|
|
|
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
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
|
-
};
|
|
19
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.default = void 0;
|
|
21
|
-
__exportStar(require("./script"), exports);
|
|
22
|
-
var script_1 = require("./script");
|
|
23
|
-
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(script_1).default; } });
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
|
+
};
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.default = void 0;
|
|
21
|
+
__exportStar(require("./script"), exports);
|
|
22
|
+
var script_1 = require("./script");
|
|
23
|
+
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(script_1).default; } });
|
package/dist/config.d.ts
CHANGED
|
@@ -87,5 +87,5 @@ export declare function resolveTypedApiConfig(config: VistaConfig): ResolvedType
|
|
|
87
87
|
export declare function resolveCacheComponentsConfig(config: VistaConfig): ResolvedCacheComponentsConfig;
|
|
88
88
|
export type ResolvedDeployConfig = Required<DeployConfig>;
|
|
89
89
|
export declare function resolveDeployConfig(config: VistaConfig): ResolvedDeployConfig;
|
|
90
|
-
export declare function inferDeployOutputForTarget(
|
|
90
|
+
export declare function inferDeployOutputForTarget(_target: Exclude<DeployTarget, 'auto'>): DeployOutput;
|
|
91
91
|
export declare function loadConfig(cwd?: string): VistaConfig;
|
package/dist/config.js
CHANGED
|
@@ -168,13 +168,7 @@ function resolveDeployConfig(config) {
|
|
|
168
168
|
preferBuildOutputApi: merged.preferBuildOutputApi !== false,
|
|
169
169
|
};
|
|
170
170
|
}
|
|
171
|
-
function inferDeployOutputForTarget(
|
|
172
|
-
if (target === 'vercel' || target === 'cloudflare' || target === 'netlify') {
|
|
173
|
-
return 'static';
|
|
174
|
-
}
|
|
175
|
-
if (target === 'render' || target === 'docker') {
|
|
176
|
-
return 'standalone';
|
|
177
|
-
}
|
|
171
|
+
function inferDeployOutputForTarget(_target) {
|
|
178
172
|
return 'standalone';
|
|
179
173
|
}
|
|
180
174
|
function mergeConfig(userConfig) {
|
|
@@ -8,12 +8,14 @@ const fs_1 = __importDefault(require("fs"));
|
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
const cli_runner_1 = require("../cli-runner");
|
|
10
10
|
const preflight_1 = require("../preflight");
|
|
11
|
+
const runtime_pack_1 = require("../runtime-pack");
|
|
11
12
|
const utils_1 = require("../utils");
|
|
13
|
+
const docker_1 = require("./docker");
|
|
12
14
|
const CLOUDFLARE_OUTPUT_DIR = '.vista/deploy/cloudflare';
|
|
13
15
|
function getCloudflareOutputDir(ctx) {
|
|
14
16
|
return path_1.default.join(ctx.cwd, CLOUDFLARE_OUTPUT_DIR);
|
|
15
17
|
}
|
|
16
|
-
function
|
|
18
|
+
function writeStaticWranglerToml(ctx, outputDir) {
|
|
17
19
|
const targetFile = path_1.default.join(ctx.cwd, 'wrangler.toml');
|
|
18
20
|
const relativeOutput = path_1.default.relative(ctx.cwd, outputDir).replace(/\\/g, '/');
|
|
19
21
|
const content = `name = "my-vista-app"
|
|
@@ -23,50 +25,48 @@ pages_build_output_dir = "${relativeOutput}"
|
|
|
23
25
|
(0, utils_1.writeFileIfAllowed)(targetFile, content, ctx.force);
|
|
24
26
|
return targetFile;
|
|
25
27
|
}
|
|
26
|
-
function writeRoutesJson(outputDir) {
|
|
27
|
-
const routesPath = path_1.default.join(outputDir, '_routes.json');
|
|
28
|
-
const routes = {
|
|
29
|
-
version: 1,
|
|
30
|
-
include: ['/*'],
|
|
31
|
-
exclude: ['/static/*'],
|
|
32
|
-
};
|
|
33
|
-
fs_1.default.writeFileSync(routesPath, `${JSON.stringify(routes, null, 2)}\n`, 'utf8');
|
|
34
|
-
return routesPath;
|
|
35
|
-
}
|
|
36
|
-
function writeRedirects(outputDir) {
|
|
37
|
-
const redirectsPath = path_1.default.join(outputDir, '_redirects');
|
|
38
|
-
const lines = [
|
|
39
|
-
'/_vista/* /:splat 200',
|
|
40
|
-
'/ /static/pages/index.html 200',
|
|
41
|
-
'/rsc /static/pages/index.rsc 200',
|
|
42
|
-
'/_rsc/* /static/pages/:splat.rsc 200',
|
|
43
|
-
'/* /static/pages/:splat.html 200',
|
|
44
|
-
];
|
|
45
|
-
fs_1.default.writeFileSync(redirectsPath, `${lines.join('\n')}\n`, 'utf8');
|
|
46
|
-
return redirectsPath;
|
|
47
|
-
}
|
|
48
28
|
exports.cloudflareAdapter = {
|
|
49
29
|
id: 'cloudflare',
|
|
50
|
-
requiredOutput: '
|
|
51
|
-
supportsFullRuntime:
|
|
30
|
+
requiredOutput: 'standalone',
|
|
31
|
+
supportsFullRuntime: true,
|
|
52
32
|
async preflight(ctx) {
|
|
53
|
-
|
|
33
|
+
if ((0, runtime_pack_1.isStaticOnlyDeploy)(ctx)) {
|
|
34
|
+
return (0, preflight_1.runStaticHostPreflight)(ctx);
|
|
35
|
+
}
|
|
36
|
+
return (0, preflight_1.runStandalonePreflight)(ctx);
|
|
54
37
|
},
|
|
55
38
|
async emit(ctx) {
|
|
56
39
|
const outputDir = getCloudflareOutputDir(ctx);
|
|
57
40
|
fs_1.default.rmSync(outputDir, { recursive: true, force: true });
|
|
58
41
|
(0, utils_1.ensureDir)(outputDir);
|
|
42
|
+
if ((0, runtime_pack_1.isStaticOnlyDeploy)(ctx)) {
|
|
43
|
+
(0, utils_1.copyStaticHostAssets)(ctx.cwd, ctx.vistaDir, outputDir);
|
|
44
|
+
(0, utils_1.prepareStaticCdnOutput)(outputDir);
|
|
45
|
+
const wranglerPath = writeStaticWranglerToml(ctx, outputDir);
|
|
46
|
+
return {
|
|
47
|
+
status: 'emitted',
|
|
48
|
+
target: 'cloudflare',
|
|
49
|
+
artifactPaths: [outputDir, wranglerPath],
|
|
50
|
+
instructions: [
|
|
51
|
+
'Static mode: Cloudflare Pages serves pre-rendered output.',
|
|
52
|
+
'For Flight SSR, omit deploy.output "static" and use Cloudflare Containers.',
|
|
53
|
+
],
|
|
54
|
+
};
|
|
55
|
+
}
|
|
59
56
|
(0, utils_1.copyStaticHostAssets)(ctx.cwd, ctx.vistaDir, outputDir);
|
|
60
|
-
|
|
61
|
-
const
|
|
62
|
-
const
|
|
57
|
+
(0, runtime_pack_1.writeCloudflareContainerWorker)(outputDir);
|
|
58
|
+
const wranglerPath = (0, runtime_pack_1.writeCloudflareFullRuntimeToml)(ctx);
|
|
59
|
+
const dockerfilePath = path_1.default.join(ctx.cwd, 'Dockerfile');
|
|
60
|
+
(0, utils_1.writeFileIfAllowed)(dockerfilePath, docker_1.DOCKERFILE_TEMPLATE, ctx.force);
|
|
63
61
|
return {
|
|
64
62
|
status: 'emitted',
|
|
65
63
|
target: 'cloudflare',
|
|
66
|
-
artifactPaths: [outputDir,
|
|
64
|
+
artifactPaths: [outputDir, wranglerPath, dockerfilePath],
|
|
67
65
|
instructions: [
|
|
68
|
-
'Cloudflare
|
|
69
|
-
'
|
|
66
|
+
'Cloudflare Workers cannot spawn Vista’s Node Flight process.',
|
|
67
|
+
'Full SSR uses Cloudflare Containers (same Dockerfile as docker deploy).',
|
|
68
|
+
'Run: npx wrangler login && npx wrangler deploy --prod',
|
|
69
|
+
'Or build/run the Dockerfile on any Node host (Fly, Railway, Render).',
|
|
70
70
|
],
|
|
71
71
|
};
|
|
72
72
|
},
|
|
@@ -85,22 +85,22 @@ exports.cloudflareAdapter = {
|
|
|
85
85
|
};
|
|
86
86
|
}
|
|
87
87
|
const outputDir = getCloudflareOutputDir(ctx);
|
|
88
|
+
const staticOnly = (0, runtime_pack_1.isStaticOnlyDeploy)(ctx);
|
|
89
|
+
const wranglerCommand = staticOnly
|
|
90
|
+
? `wrangler pages deploy "${outputDir}" --project-name my-vista-app${ctx.prod ? '' : ' --branch preview'}`
|
|
91
|
+
: ctx.prod
|
|
92
|
+
? 'wrangler deploy --prod'
|
|
93
|
+
: 'wrangler deploy';
|
|
88
94
|
if (!(0, cli_runner_1.isCliAvailable)('wrangler')) {
|
|
89
95
|
return {
|
|
90
96
|
status: 'emitted',
|
|
91
97
|
target: 'cloudflare',
|
|
92
98
|
artifactPaths: emitted.artifactPaths,
|
|
93
99
|
warnings: [...warnings, 'Wrangler CLI not found. Install with: npm i -g wrangler'],
|
|
94
|
-
instructions:
|
|
95
|
-
'Install Wrangler: npm i -g wrangler',
|
|
96
|
-
`Then run: wrangler pages deploy "${outputDir}" --project-name my-vista-app`,
|
|
97
|
-
'Or connect the repo in the Cloudflare Pages dashboard.',
|
|
98
|
-
],
|
|
100
|
+
instructions: emitted.instructions,
|
|
99
101
|
};
|
|
100
102
|
}
|
|
101
|
-
const
|
|
102
|
-
const command = `wrangler pages deploy "${outputDir}" --project-name my-vista-app ${branchFlag}`.trim();
|
|
103
|
-
const result = (0, cli_runner_1.runCliCommand)(command, { cwd: ctx.cwd, dryRun: ctx.dryRun });
|
|
103
|
+
const result = (0, cli_runner_1.runCliCommand)(wranglerCommand, { cwd: ctx.cwd, dryRun: ctx.dryRun });
|
|
104
104
|
if (!result.ok) {
|
|
105
105
|
return {
|
|
106
106
|
status: 'emitted',
|
|
@@ -109,7 +109,8 @@ exports.cloudflareAdapter = {
|
|
|
109
109
|
warnings: [...warnings, result.stderr || 'Wrangler deploy failed.'],
|
|
110
110
|
instructions: [
|
|
111
111
|
'Run: wrangler login',
|
|
112
|
-
'Or set CLOUDFLARE_API_TOKEN
|
|
112
|
+
'Or set CLOUDFLARE_API_TOKEN.',
|
|
113
|
+
...(staticOnly ? [] : ['If Containers are unavailable, deploy the Dockerfile to Fly/Railway/Render.']),
|
|
113
114
|
],
|
|
114
115
|
};
|
|
115
116
|
}
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import type { DeployAdapter } from '../types';
|
|
2
|
+
export declare const DOCKERFILE_TEMPLATE = "# syntax=docker/dockerfile:1\n\nFROM node:20-alpine AS builder\nWORKDIR /app\nCOPY package.json package-lock.json* pnpm-lock.yaml* yarn.lock* ./\nRUN npm install --no-audit --no-fund\nCOPY . .\nRUN npm run build\n\nFROM node:20-alpine AS runner\nWORKDIR /app\nENV NODE_ENV=production\nENV PORT=3003\nCOPY --from=builder /app/package.json ./package.json\nCOPY --from=builder /app/node_modules ./node_modules\nCOPY --from=builder /app/.vista ./.vista\nEXPOSE 3003\nCMD [\"node\", \".vista/standalone/server.js\"]\n";
|
|
2
3
|
export declare const dockerAdapter: DeployAdapter;
|
|
@@ -3,12 +3,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.dockerAdapter = void 0;
|
|
6
|
+
exports.dockerAdapter = exports.DOCKERFILE_TEMPLATE = void 0;
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
8
|
const cli_runner_1 = require("../cli-runner");
|
|
9
9
|
const preflight_1 = require("../preflight");
|
|
10
10
|
const utils_1 = require("../utils");
|
|
11
|
-
|
|
11
|
+
exports.DOCKERFILE_TEMPLATE = `# syntax=docker/dockerfile:1
|
|
12
12
|
|
|
13
13
|
FROM node:20-alpine AS builder
|
|
14
14
|
WORKDIR /app
|
|
@@ -21,8 +21,9 @@ FROM node:20-alpine AS runner
|
|
|
21
21
|
WORKDIR /app
|
|
22
22
|
ENV NODE_ENV=production
|
|
23
23
|
ENV PORT=3003
|
|
24
|
-
COPY --from=builder /app/.vista ./.vista
|
|
25
24
|
COPY --from=builder /app/package.json ./package.json
|
|
25
|
+
COPY --from=builder /app/node_modules ./node_modules
|
|
26
|
+
COPY --from=builder /app/.vista ./.vista
|
|
26
27
|
EXPOSE 3003
|
|
27
28
|
CMD ["node", ".vista/standalone/server.js"]
|
|
28
29
|
`;
|
|
@@ -47,7 +48,7 @@ exports.dockerAdapter = {
|
|
|
47
48
|
async emit(ctx) {
|
|
48
49
|
const dockerfilePath = path_1.default.join(ctx.cwd, 'Dockerfile');
|
|
49
50
|
const dockerignorePath = path_1.default.join(ctx.cwd, '.dockerignore');
|
|
50
|
-
(0, utils_1.writeFileIfAllowed)(dockerfilePath, DOCKERFILE_TEMPLATE, ctx.force);
|
|
51
|
+
(0, utils_1.writeFileIfAllowed)(dockerfilePath, exports.DOCKERFILE_TEMPLATE, ctx.force);
|
|
51
52
|
(0, utils_1.writeFileIfAllowed)(dockerignorePath, DOCKERIGNORE_TEMPLATE, ctx.force);
|
|
52
53
|
return {
|
|
53
54
|
status: 'emitted',
|