@vistagenic/vista 0.2.16 → 0.3.2

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.
Files changed (153) hide show
  1. package/bin/vista.js +184 -177
  2. package/dist/ai/agent.d.ts +37 -0
  3. package/dist/ai/agent.js +385 -0
  4. package/dist/ai/embeddings.d.ts +11 -0
  5. package/dist/ai/embeddings.js +71 -0
  6. package/dist/ai/index.d.ts +10 -0
  7. package/dist/ai/index.js +26 -0
  8. package/dist/ai/memory.d.ts +16 -0
  9. package/dist/ai/memory.js +39 -0
  10. package/dist/ai/observability.d.ts +21 -0
  11. package/dist/ai/observability.js +69 -0
  12. package/dist/ai/providers/anthropic.d.ts +2 -0
  13. package/dist/ai/providers/anthropic.js +190 -0
  14. package/dist/ai/providers/base.d.ts +7 -0
  15. package/dist/ai/providers/base.js +85 -0
  16. package/dist/ai/providers/gemini.d.ts +2 -0
  17. package/dist/ai/providers/gemini.js +194 -0
  18. package/dist/ai/providers/index.d.ts +5 -0
  19. package/dist/ai/providers/index.js +21 -0
  20. package/dist/ai/providers/mock.d.ts +8 -0
  21. package/dist/ai/providers/mock.js +77 -0
  22. package/dist/ai/providers/openai.d.ts +2 -0
  23. package/dist/ai/providers/openai.js +211 -0
  24. package/dist/ai/rag.d.ts +35 -0
  25. package/dist/ai/rag.js +110 -0
  26. package/dist/ai/react/index.d.ts +1 -0
  27. package/dist/ai/react/index.js +17 -0
  28. package/dist/ai/react/react-server.d.ts +1 -0
  29. package/dist/ai/react/react-server.js +17 -0
  30. package/dist/ai/react/use-agent.d.ts +23 -0
  31. package/dist/ai/react/use-agent.js +138 -0
  32. package/dist/ai/stream.d.ts +24 -0
  33. package/dist/ai/stream.js +109 -0
  34. package/dist/ai/tool.d.ts +11 -0
  35. package/dist/ai/tool.js +47 -0
  36. package/dist/ai/types.d.ts +117 -0
  37. package/dist/ai/types.js +5 -0
  38. package/dist/auth/core.d.ts +140 -0
  39. package/dist/auth/core.js +165 -0
  40. package/dist/auth/index.d.ts +20 -8
  41. package/dist/auth/index.js +369 -16
  42. package/dist/auth/react-server.d.ts +1 -0
  43. package/dist/auth/react-server.js +10 -0
  44. package/dist/auth/react.d.ts +18 -0
  45. package/dist/auth/react.js +71 -0
  46. package/dist/bin/build-rsc.js +602 -604
  47. package/dist/bin/build.js +389 -388
  48. package/dist/bin/deploy-output.d.ts +2 -7
  49. package/dist/bin/deploy-output.js +3 -76
  50. package/dist/bin/deploy.d.ts +7 -0
  51. package/dist/bin/deploy.js +102 -0
  52. package/dist/bin/dev-error-overlay-snippet.js +778 -552
  53. package/dist/bin/devtools-indicator-snippet.js +387 -387
  54. package/dist/bin/generate.js +510 -248
  55. package/dist/build/manifest.d.ts +169 -139
  56. package/dist/build/manifest.js +423 -367
  57. package/dist/build/rsc/client-manifest.d.ts +62 -52
  58. package/dist/build/rsc/client-manifest.js +295 -193
  59. package/dist/build/rsc/client-reference-plugin.d.ts +37 -37
  60. package/dist/build/rsc/client-reference-plugin.js +160 -160
  61. package/dist/build/rsc/native-scanner.d.ts +135 -123
  62. package/dist/build/rsc/native-scanner.js +203 -170
  63. package/dist/build/rsc/react-client-reference-manifest.d.ts +28 -22
  64. package/dist/build/rsc/react-client-reference-manifest.js +240 -219
  65. package/dist/build/rsc/rsc-renderer.d.ts +99 -99
  66. package/dist/build/rsc/rsc-renderer.js +263 -263
  67. package/dist/build/rsc/server-component-loader.d.ts +19 -19
  68. package/dist/build/rsc/server-component-loader.js +91 -91
  69. package/dist/build/rsc/server-manifest.d.ts +17 -0
  70. package/dist/build/rsc/server-manifest.js +20 -0
  71. package/dist/build/standalone.js +337 -334
  72. package/dist/build/webpack/plugins/vista-flight-plugin.js +5 -5
  73. package/dist/client/dynamic.react-server.d.ts +2 -0
  74. package/dist/client/dynamic.react-server.js +23 -0
  75. package/dist/client/link.react-server.d.ts +2 -0
  76. package/dist/client/link.react-server.js +11 -0
  77. package/dist/client/navigation.react-server.d.ts +1 -0
  78. package/dist/client/navigation.react-server.js +17 -0
  79. package/dist/client/router.react-server.d.ts +1 -0
  80. package/dist/client/router.react-server.js +17 -0
  81. package/dist/client/rsc-router.react-server.d.ts +1 -0
  82. package/dist/client/rsc-router.react-server.js +17 -0
  83. package/dist/client/script.react-server.d.ts +2 -0
  84. package/dist/client/script.react-server.js +23 -0
  85. package/dist/components/client-island.d.ts +34 -34
  86. package/dist/components/client-island.js +75 -75
  87. package/dist/config.d.ts +17 -0
  88. package/dist/config.js +60 -1
  89. package/dist/deploy/adapters/cloudflare.d.ts +2 -0
  90. package/dist/deploy/adapters/cloudflare.js +124 -0
  91. package/dist/deploy/adapters/docker.d.ts +2 -0
  92. package/dist/deploy/adapters/docker.js +112 -0
  93. package/dist/deploy/adapters/index.d.ts +15 -0
  94. package/dist/deploy/adapters/index.js +24 -0
  95. package/dist/deploy/adapters/netlify.d.ts +2 -0
  96. package/dist/deploy/adapters/netlify.js +115 -0
  97. package/dist/deploy/adapters/render.d.ts +2 -0
  98. package/dist/deploy/adapters/render.js +95 -0
  99. package/dist/deploy/adapters/vercel.d.ts +7 -0
  100. package/dist/deploy/adapters/vercel.js +164 -0
  101. package/dist/deploy/cli-runner.d.ts +8 -0
  102. package/dist/deploy/cli-runner.js +58 -0
  103. package/dist/deploy/detect.d.ts +6 -0
  104. package/dist/deploy/detect.js +77 -0
  105. package/dist/deploy/index.d.ts +24 -0
  106. package/dist/deploy/index.js +112 -0
  107. package/dist/deploy/preflight.d.ts +8 -0
  108. package/dist/deploy/preflight.js +80 -0
  109. package/dist/deploy/types.d.ts +48 -0
  110. package/dist/deploy/types.js +2 -0
  111. package/dist/deploy/utils.d.ts +18 -0
  112. package/dist/deploy/utils.js +70 -0
  113. package/dist/dev-error.d.ts +14 -0
  114. package/dist/dev-error.js +1763 -705
  115. package/dist/index.d.ts +23 -21
  116. package/dist/index.js +61 -57
  117. package/dist/server/cookie-parse.d.ts +4 -0
  118. package/dist/server/cookie-parse.js +14 -0
  119. package/dist/server/engine.js +7 -26
  120. package/dist/server/index.d.ts +109 -102
  121. package/dist/server/index.js +315 -286
  122. package/dist/server/middleware-runner.d.ts +125 -57
  123. package/dist/server/middleware-runner.js +615 -218
  124. package/dist/server/middleware-security.d.ts +36 -0
  125. package/dist/server/middleware-security.js +183 -0
  126. package/dist/server/module-compile-hook.js +695 -662
  127. package/dist/server/route-handler-registry.d.ts +65 -0
  128. package/dist/server/route-handler-registry.js +195 -0
  129. package/dist/server/route-patterns.d.ts +67 -0
  130. package/dist/server/route-patterns.js +186 -0
  131. package/dist/server/rsc-engine.js +75 -92
  132. package/dist/server/rsc-module-system.d.ts +33 -33
  133. package/dist/server/rsc-module-system.js +87 -87
  134. package/dist/server/rsc-upstream.js +892 -888
  135. package/dist/server/static-generator.js +10 -10
  136. package/dist/server/typed-api-runtime.d.ts +18 -0
  137. package/dist/server/typed-api-runtime.js +635 -507
  138. package/dist/server/vista-import-map.js +134 -123
  139. package/dist/stack/index.d.ts +34 -32
  140. package/dist/stack/index.js +49 -45
  141. package/dist/stack/server/caller.d.ts +13 -0
  142. package/dist/stack/server/caller.js +42 -0
  143. package/dist/stack/server/executor.d.ts +40 -36
  144. package/dist/stack/server/executor.js +222 -174
  145. package/dist/stack/server/index.d.ts +11 -10
  146. package/dist/stack/server/index.js +24 -23
  147. package/dist/stack/server/procedure.d.ts +20 -18
  148. package/dist/stack/server/procedure.js +66 -58
  149. package/dist/stack/server/types.d.ts +113 -100
  150. package/dist/theme/react-server.d.ts +10 -0
  151. package/dist/theme/react-server.js +16 -0
  152. package/package.json +28 -3
  153. package/LICENSE +0 -21
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.normalizeResolvedTarget = normalizeResolvedTarget;
7
+ exports.resolveDeployTarget = resolveDeployTarget;
8
+ exports.resolveEffectiveOutput = resolveEffectiveOutput;
9
+ exports.listKnownTargets = listKnownTargets;
10
+ const fs_1 = __importDefault(require("fs"));
11
+ const path_1 = __importDefault(require("path"));
12
+ const config_1 = require("../config");
13
+ const PLATFORM_FILES = [
14
+ { target: 'render', file: 'render.yaml' },
15
+ { target: 'vercel', file: 'vercel.json' },
16
+ { target: 'cloudflare', file: 'wrangler.toml' },
17
+ { target: 'netlify', file: 'netlify.toml' },
18
+ { target: 'docker', file: 'Dockerfile' },
19
+ ];
20
+ function detectFromEnv() {
21
+ if (process.env.VERCEL === '1' || process.env.NOW_REGION)
22
+ return 'vercel';
23
+ if (process.env.CF_PAGES === '1' || process.env.CLOUDFLARE_PAGES)
24
+ return 'cloudflare';
25
+ if (process.env.RENDER === 'true' || process.env.RENDER_SERVICE_ID)
26
+ return 'render';
27
+ if (process.env.NETLIFY === 'true' || process.env.NETLIFY_SITE_ID)
28
+ return 'netlify';
29
+ return null;
30
+ }
31
+ function detectFromProjectFiles(cwd) {
32
+ for (const entry of PLATFORM_FILES) {
33
+ if (fs_1.default.existsSync(path_1.default.join(cwd, entry.file))) {
34
+ return entry.target;
35
+ }
36
+ }
37
+ return null;
38
+ }
39
+ function normalizeResolvedTarget(raw) {
40
+ const value = String(raw ?? '')
41
+ .trim()
42
+ .toLowerCase();
43
+ if (value === 'render' ||
44
+ value === 'vercel' ||
45
+ value === 'cloudflare' ||
46
+ value === 'netlify' ||
47
+ value === 'docker') {
48
+ return value;
49
+ }
50
+ return null;
51
+ }
52
+ function resolveDeployTarget(cwd, deployConfig, cliTarget) {
53
+ const explicitCli = normalizeResolvedTarget(cliTarget);
54
+ if (explicitCli)
55
+ return explicitCli;
56
+ if (deployConfig.target !== 'auto') {
57
+ const fromConfig = normalizeResolvedTarget(deployConfig.target);
58
+ if (fromConfig)
59
+ return fromConfig;
60
+ }
61
+ const fromEnv = detectFromEnv();
62
+ if (fromEnv)
63
+ return fromEnv;
64
+ const fromFiles = detectFromProjectFiles(cwd);
65
+ if (fromFiles)
66
+ return fromFiles;
67
+ throw new Error('[vista:deploy] Unable to detect deployment target. Pass --target <render|vercel|cloudflare|netlify|docker> or set deploy.target in vista.config.ts.');
68
+ }
69
+ function resolveEffectiveOutput(deployConfig, target) {
70
+ if (deployConfig.output !== 'standalone') {
71
+ return deployConfig.output;
72
+ }
73
+ return (0, config_1.inferDeployOutputForTarget)(target);
74
+ }
75
+ function listKnownTargets() {
76
+ return ['auto', 'render', 'vercel', 'cloudflare', 'netlify', 'docker'];
77
+ }
@@ -0,0 +1,24 @@
1
+ import type { DeployResult } from './types';
2
+ export { writeVercelBuildOutput, isVercelBuildEnvironment, hasUserVercelConfig } from './adapters/vercel';
3
+ export { resolveDeployTarget, listKnownTargets } from './detect';
4
+ export type { DeployContext, DeployResult, DeployAdapter, ResolvedDeployTarget } from './types';
5
+ export interface RunDeployOptions {
6
+ cwd?: string;
7
+ target?: string | null;
8
+ dryRun?: boolean;
9
+ skipBuild?: boolean;
10
+ prod?: boolean;
11
+ preview?: boolean;
12
+ force?: boolean;
13
+ debug?: boolean;
14
+ log?: (message: string) => void;
15
+ warn?: (message: string) => void;
16
+ error?: (message: string) => void;
17
+ build?: (cwd: string) => Promise<void>;
18
+ }
19
+ export declare function runDeploy(options?: RunDeployOptions): Promise<DeployResult>;
20
+ export declare function generateDeploymentOutputs(options: {
21
+ cwd: string;
22
+ vistaDir: string;
23
+ debug?: boolean;
24
+ }): void;
@@ -0,0 +1,112 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.listKnownTargets = exports.resolveDeployTarget = exports.hasUserVercelConfig = exports.isVercelBuildEnvironment = exports.writeVercelBuildOutput = void 0;
7
+ exports.runDeploy = runDeploy;
8
+ exports.generateDeploymentOutputs = generateDeploymentOutputs;
9
+ const path_1 = __importDefault(require("path"));
10
+ const constants_1 = require("../constants");
11
+ const config_1 = require("../config");
12
+ const adapters_1 = require("./adapters");
13
+ const detect_1 = require("./detect");
14
+ const preflight_1 = require("./preflight");
15
+ var vercel_1 = require("./adapters/vercel");
16
+ Object.defineProperty(exports, "writeVercelBuildOutput", { enumerable: true, get: function () { return vercel_1.writeVercelBuildOutput; } });
17
+ Object.defineProperty(exports, "isVercelBuildEnvironment", { enumerable: true, get: function () { return vercel_1.isVercelBuildEnvironment; } });
18
+ Object.defineProperty(exports, "hasUserVercelConfig", { enumerable: true, get: function () { return vercel_1.hasUserVercelConfig; } });
19
+ var detect_2 = require("./detect");
20
+ Object.defineProperty(exports, "resolveDeployTarget", { enumerable: true, get: function () { return detect_2.resolveDeployTarget; } });
21
+ Object.defineProperty(exports, "listKnownTargets", { enumerable: true, get: function () { return detect_2.listKnownTargets; } });
22
+ function createContext(options) {
23
+ const cwd = options.cwd ?? process.cwd();
24
+ const config = (0, config_1.loadConfig)(cwd);
25
+ const deployConfig = (0, config_1.resolveDeployConfig)(config);
26
+ const target = (0, detect_1.resolveDeployTarget)(cwd, deployConfig, options.target ?? null);
27
+ return {
28
+ cwd,
29
+ vistaDir: path_1.default.join(cwd, constants_1.BUILD_DIR),
30
+ config,
31
+ deployConfig,
32
+ target,
33
+ dryRun: Boolean(options.dryRun),
34
+ skipBuild: Boolean(options.skipBuild),
35
+ prod: options.preview ? false : options.prod !== false,
36
+ preview: Boolean(options.preview),
37
+ force: Boolean(options.force),
38
+ debug: options.debug,
39
+ log: options.log,
40
+ warn: options.warn,
41
+ error: options.error,
42
+ };
43
+ }
44
+ function printResult(ctx, result) {
45
+ const log = ctx.log ?? console.log;
46
+ const warn = ctx.warn ?? console.warn;
47
+ log('');
48
+ log(`[vista:deploy] Target: ${result.target}`);
49
+ log(`[vista:deploy] Status: ${result.status}`);
50
+ if (result.url) {
51
+ log(`[vista:deploy] URL: ${result.url}`);
52
+ }
53
+ if (result.artifactPaths?.length) {
54
+ log('[vista:deploy] Artifacts:');
55
+ for (const artifact of result.artifactPaths) {
56
+ log(` - ${artifact}`);
57
+ }
58
+ }
59
+ if (result.warnings?.length) {
60
+ for (const message of result.warnings) {
61
+ warn(`[vista:deploy] Warning: ${message}`);
62
+ }
63
+ }
64
+ if (result.instructions?.length) {
65
+ log('[vista:deploy] Next steps:');
66
+ for (const instruction of result.instructions) {
67
+ log(` - ${instruction}`);
68
+ }
69
+ }
70
+ log('');
71
+ }
72
+ async function runDeploy(options = {}) {
73
+ const ctx = createContext(options);
74
+ const adapter = (0, adapters_1.getDeployAdapter)(ctx.target);
75
+ const log = ctx.log ?? console.log;
76
+ const error = ctx.error ?? console.error;
77
+ if (!options.skipBuild) {
78
+ if (options.build) {
79
+ log('[vista:deploy] Running production build...');
80
+ await options.build(ctx.cwd);
81
+ }
82
+ else {
83
+ error('[vista:deploy] Internal error: build callback is required.');
84
+ return { status: 'failed', target: ctx.target, warnings: ['Missing build callback.'] };
85
+ }
86
+ }
87
+ const artifactErrors = (0, preflight_1.validateBuildArtifacts)(ctx);
88
+ if (artifactErrors.length > 0) {
89
+ for (const message of artifactErrors) {
90
+ error(`[vista:deploy] ${message}`);
91
+ }
92
+ return { status: 'failed', target: ctx.target, warnings: artifactErrors };
93
+ }
94
+ const preflightMessages = await adapter.preflight(ctx);
95
+ const { errors, warnings } = (0, preflight_1.splitPreflightMessages)(preflightMessages);
96
+ if (errors.length > 0) {
97
+ for (const message of errors) {
98
+ error(`[vista:deploy] ${message}`);
99
+ }
100
+ return { status: 'failed', target: ctx.target, warnings: [...warnings, ...errors] };
101
+ }
102
+ for (const message of warnings) {
103
+ (ctx.warn ?? console.warn)(`[vista:deploy] Warning: ${message}`);
104
+ }
105
+ const result = ctx.dryRun ? await adapter.emit(ctx) : await adapter.deploy(ctx);
106
+ printResult(ctx, result);
107
+ return result;
108
+ }
109
+ function generateDeploymentOutputs(options) {
110
+ const { writeVercelBuildOutput } = require('./adapters/vercel');
111
+ writeVercelBuildOutput({ ...options, force: false });
112
+ }
@@ -0,0 +1,8 @@
1
+ import type { DeployContext } from './types';
2
+ export declare function validateBuildArtifacts(ctx: DeployContext): string[];
3
+ export declare function runStaticHostPreflight(ctx: DeployContext): Promise<string[]>;
4
+ export declare function runStandalonePreflight(ctx: DeployContext): Promise<string[]>;
5
+ export declare function splitPreflightMessages(messages: string[]): {
6
+ errors: string[];
7
+ warnings: string[];
8
+ };
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.validateBuildArtifacts = validateBuildArtifacts;
7
+ exports.runStaticHostPreflight = runStaticHostPreflight;
8
+ exports.runStandalonePreflight = runStandalonePreflight;
9
+ exports.splitPreflightMessages = splitPreflightMessages;
10
+ const fs_1 = __importDefault(require("fs"));
11
+ const path_1 = __importDefault(require("path"));
12
+ const config_1 = require("../config");
13
+ const artifact_validator_1 = require("../server/artifact-validator");
14
+ const utils_1 = require("./utils");
15
+ function hasDynamicOnlyRoutes(vistaDir) {
16
+ const routesManifest = (0, utils_1.readJsonSafe)(path_1.default.join(vistaDir, 'routes-manifest.json'));
17
+ const prerenderManifest = (0, utils_1.readJsonSafe)(path_1.default.join(vistaDir, 'prerender-manifest.json'));
18
+ const dynamicCount = routesManifest?.dynamicRoutes?.length ?? 0;
19
+ const staticCount = routesManifest?.staticRoutes?.length ?? 0;
20
+ const prerenderedCount = Object.keys(prerenderManifest?.routes ?? {}).length;
21
+ const dynamicPrerenderCount = Object.keys(prerenderManifest?.dynamicRoutes ?? {}).length;
22
+ if (dynamicCount > 0 && staticCount === 0 && prerenderedCount === 0) {
23
+ return true;
24
+ }
25
+ if (dynamicPrerenderCount > 0 && prerenderedCount === 0) {
26
+ return true;
27
+ }
28
+ return false;
29
+ }
30
+ function validateBuildArtifacts(ctx) {
31
+ const missing = (0, artifact_validator_1.validateVistaArtifacts)(ctx.cwd, 'rsc');
32
+ if (missing.length > 0) {
33
+ return missing.map((entry) => `Missing build artifact: ${entry}`);
34
+ }
35
+ return [];
36
+ }
37
+ async function runStaticHostPreflight(ctx) {
38
+ const warnings = [];
39
+ const errors = [];
40
+ const staticPagesDir = path_1.default.join(ctx.vistaDir, 'static', 'pages');
41
+ if (!fs_1.default.existsSync(staticPagesDir)) {
42
+ errors.push('No pre-rendered pages found at .vista/static/pages. Static hosts require SSG output from "vista build".');
43
+ }
44
+ if (hasDynamicOnlyRoutes(ctx.vistaDir)) {
45
+ errors.push('This app appears to rely on dynamic server rendering without static fallbacks. Deploy to Render or Docker for full runtime support.');
46
+ }
47
+ const typedApi = (0, config_1.resolveTypedApiConfig)(ctx.config);
48
+ if (typedApi.enabled) {
49
+ errors.push('Typed API is enabled. Static CDN hosts cannot run typed API runtime. Use deploy.target "render" or "docker".');
50
+ }
51
+ const appApiDir = path_1.default.join(ctx.cwd, 'app', 'api');
52
+ if (fs_1.default.existsSync(appApiDir)) {
53
+ warnings.push('Found app/api routes. Server-side API routes are not supported on static CDN deploy targets.');
54
+ }
55
+ if (ctx.config.images && ctx.config.images.unoptimized !== true) {
56
+ warnings.push('Consider setting images.unoptimized: true in vista.config.ts for static hosts without /_vista/image optimization.');
57
+ }
58
+ return [...errors, ...warnings.map((entry) => `warning:${entry}`)];
59
+ }
60
+ async function runStandalonePreflight(ctx) {
61
+ const errors = [];
62
+ const standaloneServer = path_1.default.join(ctx.vistaDir, 'standalone', 'server.js');
63
+ if (!fs_1.default.existsSync(standaloneServer)) {
64
+ errors.push('Missing .vista/standalone/server.js. Run "vista build" before deploying to Node hosts.');
65
+ }
66
+ return errors;
67
+ }
68
+ function splitPreflightMessages(messages) {
69
+ const errors = [];
70
+ const warnings = [];
71
+ for (const message of messages) {
72
+ if (message.startsWith('warning:')) {
73
+ warnings.push(message.slice('warning:'.length));
74
+ }
75
+ else {
76
+ errors.push(message);
77
+ }
78
+ }
79
+ return { errors, warnings };
80
+ }
@@ -0,0 +1,48 @@
1
+ import type { DeployTarget, ResolvedDeployConfig, VistaConfig } from '../config';
2
+ export type ResolvedDeployTarget = Exclude<DeployTarget, 'auto'>;
3
+ export type DeployResultStatus = 'deployed' | 'emitted' | 'failed';
4
+ export interface DeployContext {
5
+ cwd: string;
6
+ vistaDir: string;
7
+ config: VistaConfig;
8
+ deployConfig: ResolvedDeployConfig;
9
+ target: ResolvedDeployTarget;
10
+ dryRun: boolean;
11
+ skipBuild: boolean;
12
+ prod: boolean;
13
+ preview: boolean;
14
+ force: boolean;
15
+ debug?: boolean;
16
+ log?: (message: string) => void;
17
+ warn?: (message: string) => void;
18
+ error?: (message: string) => void;
19
+ }
20
+ export interface DeployResult {
21
+ status: DeployResultStatus;
22
+ target: ResolvedDeployTarget;
23
+ url?: string;
24
+ artifactPaths?: string[];
25
+ instructions?: string[];
26
+ warnings?: string[];
27
+ }
28
+ export interface DeployAdapter {
29
+ id: ResolvedDeployTarget;
30
+ requiredOutput: 'standalone' | 'static';
31
+ supportsFullRuntime: boolean;
32
+ preflight(ctx: DeployContext): Promise<string[]>;
33
+ emit(ctx: DeployContext): Promise<DeployResult>;
34
+ deploy(ctx: DeployContext): Promise<DeployResult>;
35
+ }
36
+ export interface CliRunResult {
37
+ ok: boolean;
38
+ stdout: string;
39
+ stderr: string;
40
+ command: string;
41
+ missingCli?: boolean;
42
+ }
43
+ export interface BuildHookOptions {
44
+ cwd: string;
45
+ vistaDir: string;
46
+ debug?: boolean;
47
+ force?: boolean;
48
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,18 @@
1
+ export declare function ensureDir(absolutePath: string): void;
2
+ export declare function copyDirectoryRecursive(sourceDir: string, targetDir: string): void;
3
+ export declare function copyFileIfPresent(sourceFile: string, targetFile: string): void;
4
+ export declare function writeFileIfAllowed(targetFile: string, content: string, force: boolean): {
5
+ written: boolean;
6
+ skipped: boolean;
7
+ };
8
+ export declare function readJsonSafe<T>(absolutePath: string): T | null;
9
+ export declare const STATIC_HOST_ROUTE_RULES: ({
10
+ handle: "filesystem";
11
+ src?: undefined;
12
+ dest?: undefined;
13
+ } | {
14
+ src: string;
15
+ dest: string;
16
+ handle?: undefined;
17
+ })[];
18
+ export declare function copyStaticHostAssets(cwd: string, vistaDir: string, targetDir: string): void;
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.STATIC_HOST_ROUTE_RULES = void 0;
7
+ exports.ensureDir = ensureDir;
8
+ exports.copyDirectoryRecursive = copyDirectoryRecursive;
9
+ exports.copyFileIfPresent = copyFileIfPresent;
10
+ exports.writeFileIfAllowed = writeFileIfAllowed;
11
+ exports.readJsonSafe = readJsonSafe;
12
+ exports.copyStaticHostAssets = copyStaticHostAssets;
13
+ const fs_1 = __importDefault(require("fs"));
14
+ const path_1 = __importDefault(require("path"));
15
+ function ensureDir(absolutePath) {
16
+ fs_1.default.mkdirSync(absolutePath, { recursive: true });
17
+ }
18
+ function copyDirectoryRecursive(sourceDir, targetDir) {
19
+ if (!fs_1.default.existsSync(sourceDir))
20
+ return;
21
+ ensureDir(targetDir);
22
+ const entries = fs_1.default.readdirSync(sourceDir, { withFileTypes: true });
23
+ for (const entry of entries) {
24
+ const from = path_1.default.join(sourceDir, entry.name);
25
+ const to = path_1.default.join(targetDir, entry.name);
26
+ if (entry.isDirectory()) {
27
+ copyDirectoryRecursive(from, to);
28
+ }
29
+ else if (entry.isFile()) {
30
+ fs_1.default.copyFileSync(from, to);
31
+ }
32
+ }
33
+ }
34
+ function copyFileIfPresent(sourceFile, targetFile) {
35
+ if (!fs_1.default.existsSync(sourceFile))
36
+ return;
37
+ ensureDir(path_1.default.dirname(targetFile));
38
+ fs_1.default.copyFileSync(sourceFile, targetFile);
39
+ }
40
+ function writeFileIfAllowed(targetFile, content, force) {
41
+ if (fs_1.default.existsSync(targetFile) && !force) {
42
+ return { written: false, skipped: true };
43
+ }
44
+ ensureDir(path_1.default.dirname(targetFile));
45
+ fs_1.default.writeFileSync(targetFile, content, 'utf8');
46
+ return { written: true, skipped: false };
47
+ }
48
+ function readJsonSafe(absolutePath) {
49
+ try {
50
+ return JSON.parse(fs_1.default.readFileSync(absolutePath, 'utf8'));
51
+ }
52
+ catch {
53
+ return null;
54
+ }
55
+ }
56
+ exports.STATIC_HOST_ROUTE_RULES = [
57
+ { handle: 'filesystem' },
58
+ { src: '^/_vista/(.*)$', dest: '/$1' },
59
+ { src: '^/(?:rsc|_rsc)/?$', dest: '/static/pages/index.rsc' },
60
+ { src: '^/(?:rsc|_rsc)/(.+)$', dest: '/static/pages/$1.rsc' },
61
+ { src: '^/$', dest: '/static/pages/index.html' },
62
+ { src: '^/(.+)$', dest: '/static/pages/$1.html' },
63
+ ];
64
+ function copyStaticHostAssets(cwd, vistaDir, targetDir) {
65
+ copyDirectoryRecursive(path_1.default.join(cwd, 'public'), targetDir);
66
+ copyDirectoryRecursive(path_1.default.join(vistaDir, 'static'), path_1.default.join(targetDir, 'static'));
67
+ const clientCssPath = path_1.default.join(vistaDir, 'client.css');
68
+ copyFileIfPresent(clientCssPath, path_1.default.join(targetDir, 'client.css'));
69
+ copyFileIfPresent(clientCssPath, path_1.default.join(targetDir, 'styles.css'));
70
+ }
@@ -4,18 +4,32 @@
4
4
  * Standalone dev error UI with Next.js-style pagination and controls.
5
5
  */
6
6
  import React from 'react';
7
+ export interface VistaErrorLocation {
8
+ file: string;
9
+ line?: number;
10
+ column?: number;
11
+ codeFrame?: string;
12
+ kind?: 'source' | 'server' | 'client' | 'log';
13
+ }
7
14
  export interface VistaError {
8
15
  type: 'build' | 'runtime' | 'hydration';
16
+ source?: 'server' | 'client';
9
17
  message: string;
10
18
  stack?: string;
11
19
  file?: string;
12
20
  line?: number;
13
21
  column?: number;
14
22
  codeFrame?: string;
23
+ related?: VistaErrorLocation[];
24
+ hint?: string;
15
25
  }
16
26
  interface ErrorOverlayProps {
17
27
  errors: VistaError[];
18
28
  }
29
+ export declare function fromCaughtError(error: unknown, options?: {
30
+ type?: VistaError['type'];
31
+ source?: 'server' | 'client';
32
+ }): VistaError;
19
33
  /**
20
34
  * Render a full HTML error page.
21
35
  * Engines should send this directly: `res.status(500).send(renderErrorHTML(...))`.