@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
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* react-server-dom-webpack/client.node calls __webpack_require__ while decoding
|
|
3
|
+
* Flight into a React tree. Vista SSR/SSG run in plain Node, so this shim maps
|
|
4
|
+
* webpack specifiers (including file:// URLs) onto require().
|
|
5
|
+
*/
|
|
6
|
+
export declare function installSSRWebpackShim(): void;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.installSSRWebpackShim = installSSRWebpackShim;
|
|
4
|
+
const url_1 = require("url");
|
|
5
|
+
/**
|
|
6
|
+
* react-server-dom-webpack/client.node calls __webpack_require__ while decoding
|
|
7
|
+
* Flight into a React tree. Vista SSR/SSG run in plain Node, so this shim maps
|
|
8
|
+
* webpack specifiers (including file:// URLs) onto require().
|
|
9
|
+
*/
|
|
10
|
+
function installSSRWebpackShim() {
|
|
11
|
+
if (typeof globalThis.__webpack_require__ === 'function') {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
globalThis.__webpack_require__ = function ssrWebpackRequire(specifier) {
|
|
15
|
+
let modulePath = specifier;
|
|
16
|
+
if (specifier.startsWith('file://')) {
|
|
17
|
+
try {
|
|
18
|
+
modulePath = (0, url_1.fileURLToPath)(specifier);
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
modulePath = specifier;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return require(modulePath);
|
|
25
|
+
};
|
|
26
|
+
globalThis.__webpack_chunk_load__ = function ssrChunkLoad(_chunkId) {
|
|
27
|
+
return Promise.resolve();
|
|
28
|
+
};
|
|
29
|
+
}
|
|
@@ -34,6 +34,8 @@ export interface StaticGeneratorResult {
|
|
|
34
34
|
/** The prerender manifest */
|
|
35
35
|
manifest: PrerenderManifest;
|
|
36
36
|
}
|
|
37
|
+
/** Embed Flight on SSG HTML so the client can hydrate without a live /rsc server. */
|
|
38
|
+
export declare function injectInlineFlightBootstrap(html: string, flightText: string): string;
|
|
37
39
|
/**
|
|
38
40
|
* Run static generation for all eligible routes.
|
|
39
41
|
*/
|
|
@@ -12,12 +12,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.injectInlineFlightBootstrap = injectInlineFlightBootstrap;
|
|
15
16
|
exports.generateStaticPages = generateStaticPages;
|
|
16
17
|
exports.revalidatePath = revalidatePath;
|
|
17
18
|
const path_1 = __importDefault(require("path"));
|
|
18
19
|
const fs_1 = __importDefault(require("fs"));
|
|
19
20
|
const child_process_1 = require("child_process");
|
|
20
21
|
const constants_1 = require("../constants");
|
|
22
|
+
const hydration_chunks_1 = require("./hydration-chunks");
|
|
21
23
|
const static_cache_1 = require("./static-cache");
|
|
22
24
|
const module_compile_hook_1 = require("./module-compile-hook");
|
|
23
25
|
const request_context_1 = require("./request-context");
|
|
@@ -28,6 +30,7 @@ const config_1 = require("../config");
|
|
|
28
30
|
const ppr_1 = require("./ppr");
|
|
29
31
|
const vista_import_map_1 = require("./vista-import-map");
|
|
30
32
|
const project_alias_resolver_1 = require("./project-alias-resolver");
|
|
33
|
+
const app_dir_1 = require("./app-dir");
|
|
31
34
|
const CjsModule = require('module');
|
|
32
35
|
let staticRuntimeReady = false;
|
|
33
36
|
let reactResolutionInstalled = false;
|
|
@@ -260,7 +263,7 @@ async function prerenderPage(urlPath, route, params, cwd, vistaDirRoot, appPprEn
|
|
|
260
263
|
return React.createElement(component, props, child);
|
|
261
264
|
};
|
|
262
265
|
const renderStaticSubtree = async (input) => {
|
|
263
|
-
const appDir =
|
|
266
|
+
const appDir = (0, app_dir_1.resolveAppDir)(cwd);
|
|
264
267
|
const RouteModule = require(input.entryFilePath);
|
|
265
268
|
const RouteComponent = RouteModule.default;
|
|
266
269
|
if (!RouteComponent) {
|
|
@@ -353,7 +356,7 @@ async function prerenderPage(urlPath, route, params, cwd, vistaDirRoot, appPprEn
|
|
|
353
356
|
metadataHtml = '';
|
|
354
357
|
}
|
|
355
358
|
const element = await renderStaticSubtree({
|
|
356
|
-
subtreeRootDir:
|
|
359
|
+
subtreeRootDir: (0, app_dir_1.resolveAppDir)(cwd),
|
|
357
360
|
entryFilePath: route.pagePath,
|
|
358
361
|
pathname: urlPath,
|
|
359
362
|
params: params || {},
|
|
@@ -365,7 +368,7 @@ async function prerenderPage(urlPath, route, params, cwd, vistaDirRoot, appPprEn
|
|
|
365
368
|
if (pprEnabled && route.loadingPath) {
|
|
366
369
|
try {
|
|
367
370
|
const shellElement = await renderStaticSubtree({
|
|
368
|
-
subtreeRootDir:
|
|
371
|
+
subtreeRootDir: (0, app_dir_1.resolveAppDir)(cwd),
|
|
369
372
|
entryFilePath: route.loadingPath,
|
|
370
373
|
pathname: urlPath,
|
|
371
374
|
params: params || {},
|
|
@@ -408,6 +411,30 @@ function injectBeforeClosingTag(html, tagName, injection) {
|
|
|
408
411
|
}
|
|
409
412
|
return html;
|
|
410
413
|
}
|
|
414
|
+
function buildInlineFlightBootstrapScript(flightText) {
|
|
415
|
+
return `<script>window.${constants_1.RSC_DATA_FLAG}=${JSON.stringify(flightText)};</script>`;
|
|
416
|
+
}
|
|
417
|
+
/** Embed Flight on SSG HTML so the client can hydrate without a live /rsc server. */
|
|
418
|
+
function injectInlineFlightBootstrap(html, flightText) {
|
|
419
|
+
if (!flightText || html.includes(`window.${constants_1.RSC_DATA_FLAG}=`)) {
|
|
420
|
+
return html;
|
|
421
|
+
}
|
|
422
|
+
const script = ` ${buildInlineFlightBootstrapScript(flightText)}\n`;
|
|
423
|
+
const deferIdx = html.search(/<script\s+defer\b/i);
|
|
424
|
+
if (deferIdx !== -1) {
|
|
425
|
+
return `${html.slice(0, deferIdx)}${script}${html.slice(deferIdx)}`;
|
|
426
|
+
}
|
|
427
|
+
return injectBeforeClosingTag(html, 'body', `\n${script}`);
|
|
428
|
+
}
|
|
429
|
+
async function attachFlightPayload(page, flightData, _cwd) {
|
|
430
|
+
if (!flightData)
|
|
431
|
+
return;
|
|
432
|
+
page.flightData = flightData;
|
|
433
|
+
page.html = injectInlineFlightBootstrap(page.html, flightData);
|
|
434
|
+
if (page.shellHtml) {
|
|
435
|
+
page.shellHtml = injectInlineFlightBootstrap(page.shellHtml, flightData);
|
|
436
|
+
}
|
|
437
|
+
}
|
|
411
438
|
function getCSSLinks(cwd) {
|
|
412
439
|
const links = ['<link rel="stylesheet" href="/styles.css" />'];
|
|
413
440
|
const chunksDir = path_1.default.join(cwd, constants_1.BUILD_DIR, 'static', 'chunks');
|
|
@@ -425,32 +452,12 @@ function getCSSLinks(cwd) {
|
|
|
425
452
|
return links.join('\n ');
|
|
426
453
|
}
|
|
427
454
|
function getChunkScripts(cwd) {
|
|
428
|
-
const chunksDir = path_1.default.join(cwd, constants_1.BUILD_DIR, 'static', 'chunks');
|
|
429
455
|
try {
|
|
430
|
-
|
|
431
|
-
return '';
|
|
432
|
-
}
|
|
433
|
-
const files = fs_1.default
|
|
434
|
-
.readdirSync(chunksDir)
|
|
435
|
-
.filter((entry) => entry.endsWith('.js') && !entry.endsWith('.map') && !entry.includes('.hot-update.'));
|
|
436
|
-
const priority = ['webpack.js', 'framework.js', 'vendor.js'];
|
|
437
|
-
files.sort((a, b) => {
|
|
438
|
-
const ai = priority.indexOf(a);
|
|
439
|
-
const bi = priority.indexOf(b);
|
|
440
|
-
if (ai !== -1 && bi !== -1)
|
|
441
|
-
return ai - bi;
|
|
442
|
-
if (ai !== -1)
|
|
443
|
-
return -1;
|
|
444
|
-
if (bi !== -1)
|
|
445
|
-
return 1;
|
|
446
|
-
return a.localeCompare(b);
|
|
447
|
-
});
|
|
448
|
-
return files
|
|
456
|
+
return (0, hydration_chunks_1.listHydrationChunkFiles)(cwd, false)
|
|
449
457
|
.map((file) => `<script defer src="${constants_1.STATIC_CHUNKS_PATH}${file}"></script>`)
|
|
450
458
|
.join('\n ');
|
|
451
459
|
}
|
|
452
460
|
catch {
|
|
453
|
-
// Ignore chunk discovery failures during static generation.
|
|
454
461
|
return '';
|
|
455
462
|
}
|
|
456
463
|
}
|
|
@@ -659,10 +666,7 @@ async function generateStaticPages(options) {
|
|
|
659
666
|
const page = await prerenderPage(urlPath, route, undefined, cwd, vistaDirRoot, appPprEnabled);
|
|
660
667
|
if (page) {
|
|
661
668
|
if (flightUpstream) {
|
|
662
|
-
|
|
663
|
-
if (flightData) {
|
|
664
|
-
page.flightData = flightData;
|
|
665
|
-
}
|
|
669
|
+
await attachFlightPayload(page, await flightUpstream.fetchFlight(urlPath), cwd);
|
|
666
670
|
}
|
|
667
671
|
(0, static_cache_1.setCachedPage)(urlPath, page);
|
|
668
672
|
(0, static_cache_1.writeStaticPageToDisk)(vistaDirRoot, urlPath, page);
|
|
@@ -685,10 +689,7 @@ async function generateStaticPages(options) {
|
|
|
685
689
|
const page = await prerenderPage(urlPath, route, params, cwd, vistaDirRoot, appPprEnabled);
|
|
686
690
|
if (page) {
|
|
687
691
|
if (flightUpstream) {
|
|
688
|
-
|
|
689
|
-
if (flightData) {
|
|
690
|
-
page.flightData = flightData;
|
|
691
|
-
}
|
|
692
|
+
await attachFlightPayload(page, await flightUpstream.fetchFlight(urlPath), cwd);
|
|
692
693
|
}
|
|
693
694
|
(0, static_cache_1.setCachedPage)(urlPath, page);
|
|
694
695
|
(0, static_cache_1.writeStaticPageToDisk)(vistaDirRoot, urlPath, page);
|
|
@@ -15,6 +15,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
exports.validateAppStructure = validateAppStructure;
|
|
16
16
|
const fs_1 = __importDefault(require("fs"));
|
|
17
17
|
const path_1 = __importDefault(require("path"));
|
|
18
|
+
const app_dir_1 = require("./app-dir");
|
|
18
19
|
// ============================================================================
|
|
19
20
|
// Constants
|
|
20
21
|
// ============================================================================
|
|
@@ -364,7 +365,7 @@ function walkRouteDirectories(dir, callback) {
|
|
|
364
365
|
}
|
|
365
366
|
function validateAppStructure(input) {
|
|
366
367
|
const { cwd, notFoundRoute } = input;
|
|
367
|
-
const appDir =
|
|
368
|
+
const appDir = (0, app_dir_1.resolveAppDir)(cwd);
|
|
368
369
|
const issues = [];
|
|
369
370
|
// 1. Root exists
|
|
370
371
|
checkRootExists(appDir, issues);
|
|
@@ -48,6 +48,8 @@ class StructureWatcher extends events_1.EventEmitter {
|
|
|
48
48
|
const watchPaths = [
|
|
49
49
|
path_1.default.join(this.cwd, 'app', '**', '*'),
|
|
50
50
|
path_1.default.join(this.cwd, 'components', '**', '*'),
|
|
51
|
+
path_1.default.join(this.cwd, 'src', 'app', '**', '*'),
|
|
52
|
+
path_1.default.join(this.cwd, 'src', 'components', '**', '*'),
|
|
51
53
|
path_1.default.join(this.cwd, 'vista.config.ts'),
|
|
52
54
|
path_1.default.join(this.cwd, 'vista.config.js'),
|
|
53
55
|
];
|