@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.
- package/bin/vista.js +184 -177
- package/dist/ai/agent.d.ts +37 -0
- package/dist/ai/agent.js +385 -0
- package/dist/ai/embeddings.d.ts +11 -0
- package/dist/ai/embeddings.js +71 -0
- package/dist/ai/index.d.ts +10 -0
- package/dist/ai/index.js +26 -0
- package/dist/ai/memory.d.ts +16 -0
- package/dist/ai/memory.js +39 -0
- package/dist/ai/observability.d.ts +21 -0
- package/dist/ai/observability.js +69 -0
- package/dist/ai/providers/anthropic.d.ts +2 -0
- package/dist/ai/providers/anthropic.js +190 -0
- package/dist/ai/providers/base.d.ts +7 -0
- package/dist/ai/providers/base.js +85 -0
- package/dist/ai/providers/gemini.d.ts +2 -0
- package/dist/ai/providers/gemini.js +194 -0
- package/dist/ai/providers/index.d.ts +5 -0
- package/dist/ai/providers/index.js +21 -0
- package/dist/ai/providers/mock.d.ts +8 -0
- package/dist/ai/providers/mock.js +77 -0
- package/dist/ai/providers/openai.d.ts +2 -0
- package/dist/ai/providers/openai.js +211 -0
- package/dist/ai/rag.d.ts +35 -0
- package/dist/ai/rag.js +110 -0
- package/dist/ai/react/index.d.ts +1 -0
- package/dist/ai/react/index.js +17 -0
- package/dist/ai/react/react-server.d.ts +1 -0
- package/dist/ai/react/react-server.js +17 -0
- package/dist/ai/react/use-agent.d.ts +23 -0
- package/dist/ai/react/use-agent.js +138 -0
- package/dist/ai/stream.d.ts +24 -0
- package/dist/ai/stream.js +109 -0
- package/dist/ai/tool.d.ts +11 -0
- package/dist/ai/tool.js +47 -0
- package/dist/ai/types.d.ts +117 -0
- package/dist/ai/types.js +5 -0
- package/dist/auth/core.d.ts +140 -0
- package/dist/auth/core.js +165 -0
- package/dist/auth/index.d.ts +20 -8
- package/dist/auth/index.js +369 -16
- package/dist/auth/react-server.d.ts +1 -0
- package/dist/auth/react-server.js +10 -0
- package/dist/auth/react.d.ts +18 -0
- package/dist/auth/react.js +71 -0
- package/dist/bin/build-rsc.js +602 -604
- package/dist/bin/build.js +389 -388
- package/dist/bin/deploy-output.d.ts +2 -7
- package/dist/bin/deploy-output.js +3 -76
- package/dist/bin/deploy.d.ts +7 -0
- package/dist/bin/deploy.js +102 -0
- package/dist/bin/dev-error-overlay-snippet.js +778 -552
- package/dist/bin/devtools-indicator-snippet.js +387 -387
- package/dist/bin/generate.js +510 -248
- package/dist/build/manifest.d.ts +169 -139
- package/dist/build/manifest.js +423 -367
- package/dist/build/rsc/client-manifest.d.ts +62 -52
- package/dist/build/rsc/client-manifest.js +295 -193
- package/dist/build/rsc/client-reference-plugin.d.ts +37 -37
- package/dist/build/rsc/client-reference-plugin.js +160 -160
- package/dist/build/rsc/native-scanner.d.ts +135 -123
- package/dist/build/rsc/native-scanner.js +203 -170
- package/dist/build/rsc/react-client-reference-manifest.d.ts +28 -22
- package/dist/build/rsc/react-client-reference-manifest.js +240 -219
- package/dist/build/rsc/rsc-renderer.d.ts +99 -99
- package/dist/build/rsc/rsc-renderer.js +263 -263
- package/dist/build/rsc/server-component-loader.d.ts +19 -19
- package/dist/build/rsc/server-component-loader.js +91 -91
- package/dist/build/rsc/server-manifest.d.ts +17 -0
- package/dist/build/rsc/server-manifest.js +20 -0
- package/dist/build/standalone.js +337 -334
- package/dist/build/webpack/plugins/vista-flight-plugin.js +5 -5
- package/dist/client/dynamic.react-server.d.ts +2 -0
- package/dist/client/dynamic.react-server.js +23 -0
- package/dist/client/link.react-server.d.ts +2 -0
- package/dist/client/link.react-server.js +11 -0
- package/dist/client/navigation.react-server.d.ts +1 -0
- package/dist/client/navigation.react-server.js +17 -0
- package/dist/client/router.react-server.d.ts +1 -0
- package/dist/client/router.react-server.js +17 -0
- package/dist/client/rsc-router.react-server.d.ts +1 -0
- package/dist/client/rsc-router.react-server.js +17 -0
- package/dist/client/script.react-server.d.ts +2 -0
- package/dist/client/script.react-server.js +23 -0
- package/dist/components/client-island.d.ts +34 -34
- package/dist/components/client-island.js +75 -75
- package/dist/config.d.ts +17 -0
- package/dist/config.js +60 -1
- package/dist/deploy/adapters/cloudflare.d.ts +2 -0
- package/dist/deploy/adapters/cloudflare.js +124 -0
- package/dist/deploy/adapters/docker.d.ts +2 -0
- package/dist/deploy/adapters/docker.js +112 -0
- package/dist/deploy/adapters/index.d.ts +15 -0
- package/dist/deploy/adapters/index.js +24 -0
- package/dist/deploy/adapters/netlify.d.ts +2 -0
- package/dist/deploy/adapters/netlify.js +115 -0
- package/dist/deploy/adapters/render.d.ts +2 -0
- package/dist/deploy/adapters/render.js +95 -0
- package/dist/deploy/adapters/vercel.d.ts +7 -0
- package/dist/deploy/adapters/vercel.js +164 -0
- package/dist/deploy/cli-runner.d.ts +8 -0
- package/dist/deploy/cli-runner.js +58 -0
- package/dist/deploy/detect.d.ts +6 -0
- package/dist/deploy/detect.js +77 -0
- package/dist/deploy/index.d.ts +24 -0
- package/dist/deploy/index.js +112 -0
- package/dist/deploy/preflight.d.ts +8 -0
- package/dist/deploy/preflight.js +80 -0
- package/dist/deploy/types.d.ts +48 -0
- package/dist/deploy/types.js +2 -0
- package/dist/deploy/utils.d.ts +18 -0
- package/dist/deploy/utils.js +70 -0
- package/dist/dev-error.d.ts +14 -0
- package/dist/dev-error.js +1763 -705
- package/dist/index.d.ts +23 -21
- package/dist/index.js +61 -57
- package/dist/server/cookie-parse.d.ts +4 -0
- package/dist/server/cookie-parse.js +14 -0
- package/dist/server/engine.js +7 -26
- package/dist/server/index.d.ts +109 -102
- package/dist/server/index.js +315 -286
- package/dist/server/middleware-runner.d.ts +125 -57
- package/dist/server/middleware-runner.js +615 -218
- package/dist/server/middleware-security.d.ts +36 -0
- package/dist/server/middleware-security.js +183 -0
- package/dist/server/module-compile-hook.js +695 -662
- package/dist/server/route-handler-registry.d.ts +65 -0
- package/dist/server/route-handler-registry.js +195 -0
- package/dist/server/route-patterns.d.ts +67 -0
- package/dist/server/route-patterns.js +186 -0
- package/dist/server/rsc-engine.js +75 -92
- package/dist/server/rsc-module-system.d.ts +33 -33
- package/dist/server/rsc-module-system.js +87 -87
- package/dist/server/rsc-upstream.js +892 -888
- package/dist/server/static-generator.js +10 -10
- package/dist/server/typed-api-runtime.d.ts +18 -0
- package/dist/server/typed-api-runtime.js +635 -507
- package/dist/server/vista-import-map.js +134 -123
- package/dist/stack/index.d.ts +34 -32
- package/dist/stack/index.js +49 -45
- package/dist/stack/server/caller.d.ts +13 -0
- package/dist/stack/server/caller.js +42 -0
- package/dist/stack/server/executor.d.ts +40 -36
- package/dist/stack/server/executor.js +222 -174
- package/dist/stack/server/index.d.ts +11 -10
- package/dist/stack/server/index.js +24 -23
- package/dist/stack/server/procedure.d.ts +20 -18
- package/dist/stack/server/procedure.js +66 -58
- package/dist/stack/server/types.d.ts +113 -100
- package/dist/theme/react-server.d.ts +10 -0
- package/dist/theme/react-server.js +16 -0
- package/package.json +28 -3
- package/LICENSE +0 -21
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Vista Client Reference Plugin
|
|
3
|
-
*
|
|
4
|
-
* Webpack plugin that transforms server component imports in the client bundle.
|
|
5
|
-
*
|
|
6
|
-
* When a client bundle imports a server component, this plugin:
|
|
7
|
-
* 1. Replaces the import with a client reference proxy
|
|
8
|
-
* 2. The proxy throws an error if used on the client (server components can't run on client)
|
|
9
|
-
* 3. For valid patterns (passing server component as children), the reference works
|
|
10
|
-
*
|
|
11
|
-
* This ensures:
|
|
12
|
-
* - Server code never leaks to the client bundle
|
|
13
|
-
* - Server components contribute 0kb to client JavaScript
|
|
14
|
-
* - Clear error messages when misusing server components
|
|
15
|
-
*/
|
|
16
|
-
import webpack from 'webpack';
|
|
17
|
-
export interface ClientReferencePluginOptions {
|
|
18
|
-
/** Path to the app directory */
|
|
19
|
-
appDir: string;
|
|
20
|
-
/** Path to client manifest JSON */
|
|
21
|
-
clientManifestPath: string;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Client Reference Plugin
|
|
25
|
-
*
|
|
26
|
-
* Transforms imports of server components in the client bundle
|
|
27
|
-
*/
|
|
28
|
-
export declare class ClientReferencePlugin {
|
|
29
|
-
private appDir;
|
|
30
|
-
private clientManifestPath;
|
|
31
|
-
private clientManifest;
|
|
32
|
-
constructor(options: ClientReferencePluginOptions);
|
|
33
|
-
apply(compiler: webpack.Compiler): void;
|
|
34
|
-
private loadManifest;
|
|
35
|
-
private getComponentId;
|
|
36
|
-
private generateRuntimeManifest;
|
|
37
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Vista Client Reference Plugin
|
|
3
|
+
*
|
|
4
|
+
* Webpack plugin that transforms server component imports in the client bundle.
|
|
5
|
+
*
|
|
6
|
+
* When a client bundle imports a server component, this plugin:
|
|
7
|
+
* 1. Replaces the import with a client reference proxy
|
|
8
|
+
* 2. The proxy throws an error if used on the client (server components can't run on client)
|
|
9
|
+
* 3. For valid patterns (passing server component as children), the reference works
|
|
10
|
+
*
|
|
11
|
+
* This ensures:
|
|
12
|
+
* - Server code never leaks to the client bundle
|
|
13
|
+
* - Server components contribute 0kb to client JavaScript
|
|
14
|
+
* - Clear error messages when misusing server components
|
|
15
|
+
*/
|
|
16
|
+
import webpack from 'webpack';
|
|
17
|
+
export interface ClientReferencePluginOptions {
|
|
18
|
+
/** Path to the app directory */
|
|
19
|
+
appDir: string;
|
|
20
|
+
/** Path to client manifest JSON */
|
|
21
|
+
clientManifestPath: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Client Reference Plugin
|
|
25
|
+
*
|
|
26
|
+
* Transforms imports of server components in the client bundle
|
|
27
|
+
*/
|
|
28
|
+
export declare class ClientReferencePlugin {
|
|
29
|
+
private appDir;
|
|
30
|
+
private clientManifestPath;
|
|
31
|
+
private clientManifest;
|
|
32
|
+
constructor(options: ClientReferencePluginOptions);
|
|
33
|
+
apply(compiler: webpack.Compiler): void;
|
|
34
|
+
private loadManifest;
|
|
35
|
+
private getComponentId;
|
|
36
|
+
private generateRuntimeManifest;
|
|
37
|
+
}
|
|
@@ -1,160 +1,160 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Vista Client Reference Plugin
|
|
4
|
-
*
|
|
5
|
-
* Webpack plugin that transforms server component imports in the client bundle.
|
|
6
|
-
*
|
|
7
|
-
* When a client bundle imports a server component, this plugin:
|
|
8
|
-
* 1. Replaces the import with a client reference proxy
|
|
9
|
-
* 2. The proxy throws an error if used on the client (server components can't run on client)
|
|
10
|
-
* 3. For valid patterns (passing server component as children), the reference works
|
|
11
|
-
*
|
|
12
|
-
* This ensures:
|
|
13
|
-
* - Server code never leaks to the client bundle
|
|
14
|
-
* - Server components contribute 0kb to client JavaScript
|
|
15
|
-
* - Clear error messages when misusing server components
|
|
16
|
-
*/
|
|
17
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
18
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
|
-
};
|
|
20
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
exports.ClientReferencePlugin = void 0;
|
|
22
|
-
const webpack_1 = __importDefault(require("webpack"));
|
|
23
|
-
const path_1 = __importDefault(require("path"));
|
|
24
|
-
const fs_1 = __importDefault(require("fs"));
|
|
25
|
-
/**
|
|
26
|
-
* Check if a file is a client component by reading 'use client' directive
|
|
27
|
-
*/
|
|
28
|
-
function isClientComponent(filePath) {
|
|
29
|
-
try {
|
|
30
|
-
const content = fs_1.default.readFileSync(filePath, 'utf-8');
|
|
31
|
-
const trimmed = content.trim();
|
|
32
|
-
return trimmed.startsWith("'use client'") || trimmed.startsWith('"use client"');
|
|
33
|
-
}
|
|
34
|
-
catch {
|
|
35
|
-
return false;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Client Reference Plugin
|
|
40
|
-
*
|
|
41
|
-
* Transforms imports of server components in the client bundle
|
|
42
|
-
*/
|
|
43
|
-
class ClientReferencePlugin {
|
|
44
|
-
appDir;
|
|
45
|
-
clientManifestPath;
|
|
46
|
-
clientManifest = null;
|
|
47
|
-
constructor(options) {
|
|
48
|
-
this.appDir = options.appDir;
|
|
49
|
-
this.clientManifestPath = options.clientManifestPath;
|
|
50
|
-
}
|
|
51
|
-
apply(compiler) {
|
|
52
|
-
const pluginName = 'VistaClientReferencePlugin';
|
|
53
|
-
// Load client manifest
|
|
54
|
-
compiler.hooks.beforeCompile.tap(pluginName, () => {
|
|
55
|
-
this.loadManifest();
|
|
56
|
-
});
|
|
57
|
-
// Provide virtual module for server component proxies
|
|
58
|
-
compiler.hooks.normalModuleFactory.tap(pluginName, (nmf) => {
|
|
59
|
-
nmf.hooks.beforeResolve.tap(pluginName, (resolveData) => {
|
|
60
|
-
if (!resolveData)
|
|
61
|
-
return;
|
|
62
|
-
// Check if this is importing a server component from client code
|
|
63
|
-
const request = resolveData.request;
|
|
64
|
-
if (request === 'vista/server-component-proxy') {
|
|
65
|
-
// Virtual module - allow it to continue
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
nmf.hooks.afterResolve.tap(pluginName, (resolveData) => {
|
|
70
|
-
if (!resolveData || !resolveData.createData)
|
|
71
|
-
return;
|
|
72
|
-
const resourcePath = resolveData.createData.resource;
|
|
73
|
-
if (!resourcePath)
|
|
74
|
-
return;
|
|
75
|
-
// Check if this is a file in the app directory
|
|
76
|
-
if (!resourcePath.startsWith(this.appDir))
|
|
77
|
-
return;
|
|
78
|
-
// Check if this is a TypeScript/JavaScript file
|
|
79
|
-
if (!/\.[jt]sx?$/.test(resourcePath))
|
|
80
|
-
return;
|
|
81
|
-
// Check if this is a server component (NOT a client component)
|
|
82
|
-
if (!isClientComponent(resourcePath)) {
|
|
83
|
-
// This is a server component being imported in client bundle
|
|
84
|
-
// We need to replace it with a proxy
|
|
85
|
-
// Mark it for replacement (use any to add custom properties)
|
|
86
|
-
resolveData.createData.vistaServerComponent = true;
|
|
87
|
-
resolveData.createData.vistaComponentId = this.getComponentId(resourcePath);
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
});
|
|
91
|
-
// Transform the module content for server components
|
|
92
|
-
compiler.hooks.compilation.tap(pluginName, (compilation) => {
|
|
93
|
-
// Add the server component proxy to the beginning of affected modules
|
|
94
|
-
compilation.hooks.succeedModule.tap(pluginName, (module) => {
|
|
95
|
-
if (module.vistaServerComponent) {
|
|
96
|
-
// This module is a server component - it should be replaced with a proxy
|
|
97
|
-
// In practice, we handle this via the loader
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
});
|
|
101
|
-
// Add a loader to handle server component replacement
|
|
102
|
-
compiler.options.module?.rules?.push({
|
|
103
|
-
test: /\.[jt]sx?$/,
|
|
104
|
-
include: this.appDir,
|
|
105
|
-
enforce: 'pre',
|
|
106
|
-
use: [
|
|
107
|
-
{
|
|
108
|
-
loader: require.resolve('./server-component-loader'),
|
|
109
|
-
options: {
|
|
110
|
-
appDir: this.appDir,
|
|
111
|
-
clientManifestPath: this.clientManifestPath,
|
|
112
|
-
},
|
|
113
|
-
},
|
|
114
|
-
],
|
|
115
|
-
});
|
|
116
|
-
compiler.hooks.compilation.tap(pluginName, (compilation) => {
|
|
117
|
-
compilation.hooks.processAssets.tap({
|
|
118
|
-
name: pluginName,
|
|
119
|
-
stage: webpack_1.default.Compilation.PROCESS_ASSETS_STAGE_ADDITIONAL,
|
|
120
|
-
}, () => {
|
|
121
|
-
if (!this.clientManifest)
|
|
122
|
-
return;
|
|
123
|
-
const runtimeManifest = this.generateRuntimeManifest();
|
|
124
|
-
const manifestSource = JSON.stringify(runtimeManifest, null, 2);
|
|
125
|
-
compilation.emitAsset('client-reference-manifest.json', new webpack_1.default.sources.RawSource(manifestSource));
|
|
126
|
-
});
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
loadManifest() {
|
|
130
|
-
try {
|
|
131
|
-
if (fs_1.default.existsSync(this.clientManifestPath)) {
|
|
132
|
-
const content = fs_1.default.readFileSync(this.clientManifestPath, 'utf-8');
|
|
133
|
-
this.clientManifest = JSON.parse(content);
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
catch (e) {
|
|
137
|
-
console.warn('[Vista] Failed to load client manifest:', e);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
getComponentId(filePath) {
|
|
141
|
-
const relative = path_1.default.relative(this.appDir, filePath);
|
|
142
|
-
return `server:${relative.replace(/\\/g, '/').replace(/\.[jt]sx?$/, '')}`;
|
|
143
|
-
}
|
|
144
|
-
generateRuntimeManifest() {
|
|
145
|
-
if (!this.clientManifest)
|
|
146
|
-
return {};
|
|
147
|
-
return {
|
|
148
|
-
clientModules: Object.keys(this.clientManifest.clientModules).reduce((acc, key) => {
|
|
149
|
-
const entry = this.clientManifest.clientModules[key];
|
|
150
|
-
acc[key] = {
|
|
151
|
-
id: entry.id,
|
|
152
|
-
chunks: [entry.chunkName],
|
|
153
|
-
name: entry.exports[0] || 'default',
|
|
154
|
-
};
|
|
155
|
-
return acc;
|
|
156
|
-
}, {}),
|
|
157
|
-
};
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
exports.ClientReferencePlugin = ClientReferencePlugin;
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Vista Client Reference Plugin
|
|
4
|
+
*
|
|
5
|
+
* Webpack plugin that transforms server component imports in the client bundle.
|
|
6
|
+
*
|
|
7
|
+
* When a client bundle imports a server component, this plugin:
|
|
8
|
+
* 1. Replaces the import with a client reference proxy
|
|
9
|
+
* 2. The proxy throws an error if used on the client (server components can't run on client)
|
|
10
|
+
* 3. For valid patterns (passing server component as children), the reference works
|
|
11
|
+
*
|
|
12
|
+
* This ensures:
|
|
13
|
+
* - Server code never leaks to the client bundle
|
|
14
|
+
* - Server components contribute 0kb to client JavaScript
|
|
15
|
+
* - Clear error messages when misusing server components
|
|
16
|
+
*/
|
|
17
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
18
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
|
+
};
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.ClientReferencePlugin = void 0;
|
|
22
|
+
const webpack_1 = __importDefault(require("webpack"));
|
|
23
|
+
const path_1 = __importDefault(require("path"));
|
|
24
|
+
const fs_1 = __importDefault(require("fs"));
|
|
25
|
+
/**
|
|
26
|
+
* Check if a file is a client component by reading 'use client' directive
|
|
27
|
+
*/
|
|
28
|
+
function isClientComponent(filePath) {
|
|
29
|
+
try {
|
|
30
|
+
const content = fs_1.default.readFileSync(filePath, 'utf-8');
|
|
31
|
+
const trimmed = content.trim();
|
|
32
|
+
return trimmed.startsWith("'use client'") || trimmed.startsWith('"use client"');
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Client Reference Plugin
|
|
40
|
+
*
|
|
41
|
+
* Transforms imports of server components in the client bundle
|
|
42
|
+
*/
|
|
43
|
+
class ClientReferencePlugin {
|
|
44
|
+
appDir;
|
|
45
|
+
clientManifestPath;
|
|
46
|
+
clientManifest = null;
|
|
47
|
+
constructor(options) {
|
|
48
|
+
this.appDir = options.appDir;
|
|
49
|
+
this.clientManifestPath = options.clientManifestPath;
|
|
50
|
+
}
|
|
51
|
+
apply(compiler) {
|
|
52
|
+
const pluginName = 'VistaClientReferencePlugin';
|
|
53
|
+
// Load client manifest
|
|
54
|
+
compiler.hooks.beforeCompile.tap(pluginName, () => {
|
|
55
|
+
this.loadManifest();
|
|
56
|
+
});
|
|
57
|
+
// Provide virtual module for server component proxies
|
|
58
|
+
compiler.hooks.normalModuleFactory.tap(pluginName, (nmf) => {
|
|
59
|
+
nmf.hooks.beforeResolve.tap(pluginName, (resolveData) => {
|
|
60
|
+
if (!resolveData)
|
|
61
|
+
return;
|
|
62
|
+
// Check if this is importing a server component from client code
|
|
63
|
+
const request = resolveData.request;
|
|
64
|
+
if (request === 'vista/server-component-proxy') {
|
|
65
|
+
// Virtual module - allow it to continue
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
nmf.hooks.afterResolve.tap(pluginName, (resolveData) => {
|
|
70
|
+
if (!resolveData || !resolveData.createData)
|
|
71
|
+
return;
|
|
72
|
+
const resourcePath = resolveData.createData.resource;
|
|
73
|
+
if (!resourcePath)
|
|
74
|
+
return;
|
|
75
|
+
// Check if this is a file in the app directory
|
|
76
|
+
if (!resourcePath.startsWith(this.appDir))
|
|
77
|
+
return;
|
|
78
|
+
// Check if this is a TypeScript/JavaScript file
|
|
79
|
+
if (!/\.[jt]sx?$/.test(resourcePath))
|
|
80
|
+
return;
|
|
81
|
+
// Check if this is a server component (NOT a client component)
|
|
82
|
+
if (!isClientComponent(resourcePath)) {
|
|
83
|
+
// This is a server component being imported in client bundle
|
|
84
|
+
// We need to replace it with a proxy
|
|
85
|
+
// Mark it for replacement (use any to add custom properties)
|
|
86
|
+
resolveData.createData.vistaServerComponent = true;
|
|
87
|
+
resolveData.createData.vistaComponentId = this.getComponentId(resourcePath);
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
// Transform the module content for server components
|
|
92
|
+
compiler.hooks.compilation.tap(pluginName, (compilation) => {
|
|
93
|
+
// Add the server component proxy to the beginning of affected modules
|
|
94
|
+
compilation.hooks.succeedModule.tap(pluginName, (module) => {
|
|
95
|
+
if (module.vistaServerComponent) {
|
|
96
|
+
// This module is a server component - it should be replaced with a proxy
|
|
97
|
+
// In practice, we handle this via the loader
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
// Add a loader to handle server component replacement
|
|
102
|
+
compiler.options.module?.rules?.push({
|
|
103
|
+
test: /\.[jt]sx?$/,
|
|
104
|
+
include: this.appDir,
|
|
105
|
+
enforce: 'pre',
|
|
106
|
+
use: [
|
|
107
|
+
{
|
|
108
|
+
loader: require.resolve('./server-component-loader'),
|
|
109
|
+
options: {
|
|
110
|
+
appDir: this.appDir,
|
|
111
|
+
clientManifestPath: this.clientManifestPath,
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
],
|
|
115
|
+
});
|
|
116
|
+
compiler.hooks.compilation.tap(pluginName, (compilation) => {
|
|
117
|
+
compilation.hooks.processAssets.tap({
|
|
118
|
+
name: pluginName,
|
|
119
|
+
stage: webpack_1.default.Compilation.PROCESS_ASSETS_STAGE_ADDITIONAL,
|
|
120
|
+
}, () => {
|
|
121
|
+
if (!this.clientManifest)
|
|
122
|
+
return;
|
|
123
|
+
const runtimeManifest = this.generateRuntimeManifest();
|
|
124
|
+
const manifestSource = JSON.stringify(runtimeManifest, null, 2);
|
|
125
|
+
compilation.emitAsset('client-reference-manifest.json', new webpack_1.default.sources.RawSource(manifestSource));
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
loadManifest() {
|
|
130
|
+
try {
|
|
131
|
+
if (fs_1.default.existsSync(this.clientManifestPath)) {
|
|
132
|
+
const content = fs_1.default.readFileSync(this.clientManifestPath, 'utf-8');
|
|
133
|
+
this.clientManifest = JSON.parse(content);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
catch (e) {
|
|
137
|
+
console.warn('[Vista] Failed to load client manifest:', e);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
getComponentId(filePath) {
|
|
141
|
+
const relative = path_1.default.relative(this.appDir, filePath);
|
|
142
|
+
return `server:${relative.replace(/\\/g, '/').replace(/\.[jt]sx?$/, '')}`;
|
|
143
|
+
}
|
|
144
|
+
generateRuntimeManifest() {
|
|
145
|
+
if (!this.clientManifest)
|
|
146
|
+
return {};
|
|
147
|
+
return {
|
|
148
|
+
clientModules: Object.keys(this.clientManifest.clientModules).reduce((acc, key) => {
|
|
149
|
+
const entry = this.clientManifest.clientModules[key];
|
|
150
|
+
acc[key] = {
|
|
151
|
+
id: entry.id,
|
|
152
|
+
chunks: [entry.chunkName],
|
|
153
|
+
name: entry.exports[0] || 'default',
|
|
154
|
+
};
|
|
155
|
+
return acc;
|
|
156
|
+
}, {}),
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
exports.ClientReferencePlugin = ClientReferencePlugin;
|
|
@@ -1,123 +1,135 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Vista RSC Native Scanner
|
|
3
|
-
*
|
|
4
|
-
* Uses Rust-powered native bindings for blazing fast component scanning.
|
|
5
|
-
* Falls back to TypeScript implementation if native module unavailable.
|
|
6
|
-
*/
|
|
7
|
-
export interface NapiScannedComponent {
|
|
8
|
-
absolutePath: string;
|
|
9
|
-
relativePath: string;
|
|
10
|
-
isClient: boolean;
|
|
11
|
-
directiveLine: number;
|
|
12
|
-
componentType: string;
|
|
13
|
-
exports: string[];
|
|
14
|
-
clientHooksUsed: string[];
|
|
15
|
-
hasMetadata: boolean;
|
|
16
|
-
hasGenerateMetadata: boolean;
|
|
17
|
-
}
|
|
18
|
-
export interface NapiServerComponentError {
|
|
19
|
-
file: string;
|
|
20
|
-
message: string;
|
|
21
|
-
hooks: string[];
|
|
22
|
-
}
|
|
23
|
-
export interface NapiScanResult {
|
|
24
|
-
clientComponents: NapiScannedComponent[];
|
|
25
|
-
serverComponents: NapiScannedComponent[];
|
|
26
|
-
pages: NapiScannedComponent[];
|
|
27
|
-
layouts: NapiScannedComponent[];
|
|
28
|
-
apiRoutes: NapiScannedComponent[];
|
|
29
|
-
errors: NapiServerComponentError[];
|
|
30
|
-
totalFiles: number;
|
|
31
|
-
scanTimeMs: number;
|
|
32
|
-
}
|
|
33
|
-
export interface NapiClientModuleEntry {
|
|
34
|
-
id: string;
|
|
35
|
-
path: string;
|
|
36
|
-
absolutePath: string;
|
|
37
|
-
chunkName: string;
|
|
38
|
-
exports: string[];
|
|
39
|
-
asyncLoad: boolean;
|
|
40
|
-
}
|
|
41
|
-
export interface NapiClientManifest {
|
|
42
|
-
buildId: string;
|
|
43
|
-
clientModules: NapiClientModuleEntry[];
|
|
44
|
-
}
|
|
45
|
-
export interface NapiRouteEntry {
|
|
46
|
-
pattern: string;
|
|
47
|
-
pagePath: string;
|
|
48
|
-
layoutPaths: string[];
|
|
49
|
-
loadingPath: string | null;
|
|
50
|
-
errorPath: string | null;
|
|
51
|
-
routeType: string;
|
|
52
|
-
}
|
|
53
|
-
export interface NapiServerModuleEntry {
|
|
54
|
-
id: string;
|
|
55
|
-
path: string;
|
|
56
|
-
absolutePath: string;
|
|
57
|
-
componentType: string;
|
|
58
|
-
hasMetadata: boolean;
|
|
59
|
-
hasGenerateMetadata: boolean;
|
|
60
|
-
}
|
|
61
|
-
export interface NapiServerManifest {
|
|
62
|
-
buildId: string;
|
|
63
|
-
serverModules: NapiServerModuleEntry[];
|
|
64
|
-
routes: NapiRouteEntry[];
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
*
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
*
|
|
77
|
-
*/
|
|
78
|
-
export declare function
|
|
79
|
-
/**
|
|
80
|
-
* Generate
|
|
81
|
-
*/
|
|
82
|
-
export declare function
|
|
83
|
-
/**
|
|
84
|
-
* Generate
|
|
85
|
-
*/
|
|
86
|
-
export declare function
|
|
87
|
-
/**
|
|
88
|
-
*
|
|
89
|
-
*/
|
|
90
|
-
export declare function
|
|
91
|
-
/**
|
|
92
|
-
*
|
|
93
|
-
*/
|
|
94
|
-
export declare function
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Vista RSC Native Scanner
|
|
3
|
+
*
|
|
4
|
+
* Uses Rust-powered native bindings for blazing fast component scanning.
|
|
5
|
+
* Falls back to TypeScript implementation if native module unavailable.
|
|
6
|
+
*/
|
|
7
|
+
export interface NapiScannedComponent {
|
|
8
|
+
absolutePath: string;
|
|
9
|
+
relativePath: string;
|
|
10
|
+
isClient: boolean;
|
|
11
|
+
directiveLine: number;
|
|
12
|
+
componentType: string;
|
|
13
|
+
exports: string[];
|
|
14
|
+
clientHooksUsed: string[];
|
|
15
|
+
hasMetadata: boolean;
|
|
16
|
+
hasGenerateMetadata: boolean;
|
|
17
|
+
}
|
|
18
|
+
export interface NapiServerComponentError {
|
|
19
|
+
file: string;
|
|
20
|
+
message: string;
|
|
21
|
+
hooks: string[];
|
|
22
|
+
}
|
|
23
|
+
export interface NapiScanResult {
|
|
24
|
+
clientComponents: NapiScannedComponent[];
|
|
25
|
+
serverComponents: NapiScannedComponent[];
|
|
26
|
+
pages: NapiScannedComponent[];
|
|
27
|
+
layouts: NapiScannedComponent[];
|
|
28
|
+
apiRoutes: NapiScannedComponent[];
|
|
29
|
+
errors: NapiServerComponentError[];
|
|
30
|
+
totalFiles: number;
|
|
31
|
+
scanTimeMs: number;
|
|
32
|
+
}
|
|
33
|
+
export interface NapiClientModuleEntry {
|
|
34
|
+
id: string;
|
|
35
|
+
path: string;
|
|
36
|
+
absolutePath: string;
|
|
37
|
+
chunkName: string;
|
|
38
|
+
exports: string[];
|
|
39
|
+
asyncLoad: boolean;
|
|
40
|
+
}
|
|
41
|
+
export interface NapiClientManifest {
|
|
42
|
+
buildId: string;
|
|
43
|
+
clientModules: NapiClientModuleEntry[];
|
|
44
|
+
}
|
|
45
|
+
export interface NapiRouteEntry {
|
|
46
|
+
pattern: string;
|
|
47
|
+
pagePath: string;
|
|
48
|
+
layoutPaths: string[];
|
|
49
|
+
loadingPath: string | null;
|
|
50
|
+
errorPath: string | null;
|
|
51
|
+
routeType: string;
|
|
52
|
+
}
|
|
53
|
+
export interface NapiServerModuleEntry {
|
|
54
|
+
id: string;
|
|
55
|
+
path: string;
|
|
56
|
+
absolutePath: string;
|
|
57
|
+
componentType: string;
|
|
58
|
+
hasMetadata: boolean;
|
|
59
|
+
hasGenerateMetadata: boolean;
|
|
60
|
+
}
|
|
61
|
+
export interface NapiServerManifest {
|
|
62
|
+
buildId: string;
|
|
63
|
+
serverModules: NapiServerModuleEntry[];
|
|
64
|
+
routes: NapiRouteEntry[];
|
|
65
|
+
}
|
|
66
|
+
export interface NapiClientScanRoot {
|
|
67
|
+
dir: string;
|
|
68
|
+
prefix: string;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Check if native module is available
|
|
72
|
+
*/
|
|
73
|
+
export declare function isNativeAvailable(): boolean;
|
|
74
|
+
/**
|
|
75
|
+
* Scan app directory using Rust native code
|
|
76
|
+
* Returns null if native module is not available
|
|
77
|
+
*/
|
|
78
|
+
export declare function scanAppNative(appDir: string): NapiScanResult | null;
|
|
79
|
+
/**
|
|
80
|
+
* Generate client manifest using Rust native code
|
|
81
|
+
*/
|
|
82
|
+
export declare function generateClientManifestNative(appDir: string, buildId: string): NapiClientManifest | null;
|
|
83
|
+
/**
|
|
84
|
+
* Generate client manifest from an explicit project root plus `app/`
|
|
85
|
+
*/
|
|
86
|
+
export declare function generateClientManifestForProjectNative(cwd: string, appDir: string, buildId: string): NapiClientManifest | null;
|
|
87
|
+
/**
|
|
88
|
+
* Discover project-level client scan roots using Rust native code
|
|
89
|
+
*/
|
|
90
|
+
export declare function discoverProjectClientRootsNative(cwd: string): NapiClientScanRoot[] | null;
|
|
91
|
+
/**
|
|
92
|
+
* Generate server manifest using Rust native code
|
|
93
|
+
*/
|
|
94
|
+
export declare function generateServerManifestNative(appDir: string, buildId: string): NapiServerManifest | null;
|
|
95
|
+
/**
|
|
96
|
+
* Generate unique mount ID for client component
|
|
97
|
+
*/
|
|
98
|
+
export declare function generateMountIdNative(): string | null;
|
|
99
|
+
/**
|
|
100
|
+
* Reset mount ID counter (call at start of each request)
|
|
101
|
+
*/
|
|
102
|
+
export declare function resetMountCounterNative(): boolean;
|
|
103
|
+
/**
|
|
104
|
+
* Convert NAPI scan result to internal format
|
|
105
|
+
*/
|
|
106
|
+
export declare function convertScanResult(result: NapiScanResult): {
|
|
107
|
+
clientComponents: {
|
|
108
|
+
absolutePath: string;
|
|
109
|
+
relativePath: string;
|
|
110
|
+
isClient: boolean;
|
|
111
|
+
directiveLine: number;
|
|
112
|
+
componentType: string;
|
|
113
|
+
exports: string[];
|
|
114
|
+
clientHooksUsed: string[];
|
|
115
|
+
hasMetadata: boolean;
|
|
116
|
+
hasGenerateMetadata: boolean;
|
|
117
|
+
}[];
|
|
118
|
+
serverComponents: {
|
|
119
|
+
absolutePath: string;
|
|
120
|
+
relativePath: string;
|
|
121
|
+
isClient: boolean;
|
|
122
|
+
directiveLine: number;
|
|
123
|
+
componentType: string;
|
|
124
|
+
exports: string[];
|
|
125
|
+
clientHooksUsed: any[];
|
|
126
|
+
hasMetadata: boolean;
|
|
127
|
+
hasGenerateMetadata: boolean;
|
|
128
|
+
}[];
|
|
129
|
+
pages: NapiScannedComponent[];
|
|
130
|
+
layouts: NapiScannedComponent[];
|
|
131
|
+
apiRoutes: NapiScannedComponent[];
|
|
132
|
+
errors: NapiServerComponentError[];
|
|
133
|
+
totalFiles: number;
|
|
134
|
+
scanTimeMs: number;
|
|
135
|
+
};
|