@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
package/dist/bin/build.js
CHANGED
|
@@ -1,150 +1,151 @@
|
|
|
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.compiler = void 0;
|
|
7
|
-
exports.buildClient = buildClient;
|
|
8
|
-
const path_1 = __importDefault(require("path"));
|
|
9
|
-
const fs_1 = __importDefault(require("fs"));
|
|
10
|
-
const webpack_1 = __importDefault(require("webpack"));
|
|
11
|
-
const webpack_config_1 = require("./webpack.config");
|
|
12
|
-
const file_scanner_1 = require("./file-scanner");
|
|
13
|
-
const manifest_1 = require("../build/manifest");
|
|
14
|
-
const config_1 = require("../config");
|
|
15
|
-
const constants_1 = require("../constants");
|
|
16
|
-
const structure_validator_1 = require("../server/structure-validator");
|
|
17
|
-
const structure_log_1 = require("../server/structure-log");
|
|
18
|
-
const devtools_indicator_snippet_1 = require("./devtools-indicator-snippet");
|
|
19
|
-
const dev_error_overlay_snippet_1 = require("./dev-error-overlay-snippet");
|
|
20
|
-
const deploy_output_1 = require("./deploy-output");
|
|
21
|
-
const module_boundary_validator_1 = require("../server/module-boundary-validator");
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
//
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
const
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
const
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
//
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
props
|
|
111
|
-
props.push(`
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
.
|
|
117
|
-
.replace(
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
.
|
|
124
|
-
.replace(
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
.
|
|
131
|
-
.replace(
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
.
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
//
|
|
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.compiler = void 0;
|
|
7
|
+
exports.buildClient = buildClient;
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const fs_1 = __importDefault(require("fs"));
|
|
10
|
+
const webpack_1 = __importDefault(require("webpack"));
|
|
11
|
+
const webpack_config_1 = require("./webpack.config");
|
|
12
|
+
const file_scanner_1 = require("./file-scanner");
|
|
13
|
+
const manifest_1 = require("../build/manifest");
|
|
14
|
+
const config_1 = require("../config");
|
|
15
|
+
const constants_1 = require("../constants");
|
|
16
|
+
const structure_validator_1 = require("../server/structure-validator");
|
|
17
|
+
const structure_log_1 = require("../server/structure-log");
|
|
18
|
+
const devtools_indicator_snippet_1 = require("./devtools-indicator-snippet");
|
|
19
|
+
const dev_error_overlay_snippet_1 = require("./dev-error-overlay-snippet");
|
|
20
|
+
const deploy_output_1 = require("./deploy-output");
|
|
21
|
+
const module_boundary_validator_1 = require("../server/module-boundary-validator");
|
|
22
|
+
const client_manifest_1 = require("../build/rsc/client-manifest");
|
|
23
|
+
const _debug = !!process.env.VISTA_DEBUG;
|
|
24
|
+
// Helper to run PostCSS
|
|
25
|
+
function runPostCSS(cwd, vistaDir) {
|
|
26
|
+
const globalsCss = path_1.default.join(cwd, 'app/globals.css');
|
|
27
|
+
if (fs_1.default.existsSync(globalsCss)) {
|
|
28
|
+
if (_debug)
|
|
29
|
+
console.log('Building CSS with PostCSS...');
|
|
30
|
+
const { execSync } = require('child_process');
|
|
31
|
+
try {
|
|
32
|
+
const cssOut = path_1.default.join(vistaDir, 'client.css');
|
|
33
|
+
execSync(`npx postcss app/globals.css -o "${cssOut}"`, {
|
|
34
|
+
stdio: _debug ? 'inherit' : 'pipe',
|
|
35
|
+
cwd,
|
|
36
|
+
});
|
|
37
|
+
if (_debug)
|
|
38
|
+
console.log('CSS Built Successfully!');
|
|
39
|
+
}
|
|
40
|
+
catch (cssErr) {
|
|
41
|
+
console.error('CSS Build failed (PostCSS error).');
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
function collectRouteArtifactEntries(node, segments = [], entries = []) {
|
|
46
|
+
const nextSegments = [...segments];
|
|
47
|
+
if (node.segment) {
|
|
48
|
+
if (node.kind === 'dynamic') {
|
|
49
|
+
nextSegments.push(`:${node.segment}`);
|
|
50
|
+
}
|
|
51
|
+
else if (node.kind === 'catch-all') {
|
|
52
|
+
nextSegments.push(`:${node.segment}*`);
|
|
53
|
+
}
|
|
54
|
+
else if (node.kind !== 'group') {
|
|
55
|
+
nextSegments.push(node.segment);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
if (node.indexPath) {
|
|
59
|
+
const pattern = nextSegments.length === 0 ? '/' : `/${nextSegments.join('/')}`;
|
|
60
|
+
const type = pattern.includes('*')
|
|
61
|
+
? 'catch-all'
|
|
62
|
+
: pattern.includes(':')
|
|
63
|
+
? 'dynamic'
|
|
64
|
+
: 'static';
|
|
65
|
+
entries.push({
|
|
66
|
+
pattern,
|
|
67
|
+
pagePath: String(node.indexPath),
|
|
68
|
+
type,
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
if (Array.isArray(node.children)) {
|
|
72
|
+
node.children.forEach((child) => collectRouteArtifactEntries(child, nextSegments, entries));
|
|
73
|
+
}
|
|
74
|
+
return entries;
|
|
75
|
+
}
|
|
76
|
+
// Generate Client Entry File - TRUE RSC
|
|
77
|
+
// Only imports components with 'use client' directive
|
|
78
|
+
function generateClientEntry(cwd, vistaDir, clientComponents, isDev = false) {
|
|
79
|
+
const devToolsBootId = `legacy-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;
|
|
80
|
+
const appDir = path_1.default.join(cwd, 'app');
|
|
81
|
+
// Generate imports ONLY for client components
|
|
82
|
+
const clientImports = [];
|
|
83
|
+
const clientRegistrations = [];
|
|
84
|
+
clientComponents.forEach((comp, index) => {
|
|
85
|
+
const relativePath = './' + path_1.default.relative(vistaDir, comp.absolutePath).replace(/\\/g, '/');
|
|
86
|
+
const componentName = `ClientComponent_${index}`;
|
|
87
|
+
const componentId = comp.relativePath.replace(/\\/g, '/').replace(/\.(tsx|ts|jsx|js)$/, '');
|
|
88
|
+
// Extract just the component name (e.g., "Navbar" from "components/Navbar")
|
|
89
|
+
const baseName = path_1.default.basename(comp.relativePath).replace(/\.(tsx|ts|jsx|js)$/, '');
|
|
90
|
+
const lowercaseName = baseName.toLowerCase();
|
|
91
|
+
clientImports.push(`import ${componentName} from "${relativePath}";`);
|
|
92
|
+
// Register by full path (for standard RSC)
|
|
93
|
+
clientRegistrations.push(` "${componentId}": ${componentName},`);
|
|
94
|
+
// Also register by lowercase name (for <Client> wrapper compatibility)
|
|
95
|
+
clientRegistrations.push(` "${lowercaseName}": ${componentName},`);
|
|
96
|
+
});
|
|
97
|
+
// Get Route Tree from Rust (but DON'T bundle server components)
|
|
98
|
+
const { getRouteTree } = require('./file-scanner');
|
|
99
|
+
let routeTree;
|
|
100
|
+
try {
|
|
101
|
+
routeTree = getRouteTree(appDir);
|
|
102
|
+
}
|
|
103
|
+
catch (e) {
|
|
104
|
+
console.error('Failed to generate route tree:', e);
|
|
105
|
+
process.exit(1);
|
|
106
|
+
}
|
|
107
|
+
// For RSC, we only serialize the STRUCTURE, not the components
|
|
108
|
+
// Components are loaded separately
|
|
109
|
+
function serializeRouteStructure(node) {
|
|
110
|
+
const props = [];
|
|
111
|
+
props.push(`segment: "${node.segment}"`);
|
|
112
|
+
props.push(`kind: "${node.kind}"`);
|
|
113
|
+
// Store paths as strings, NOT require() - server renders these
|
|
114
|
+
if (node.indexPath) {
|
|
115
|
+
const componentId = path_1.default
|
|
116
|
+
.relative(appDir, node.indexPath)
|
|
117
|
+
.replace(/\\/g, '/')
|
|
118
|
+
.replace(/\.(tsx|ts|jsx|js)$/, '');
|
|
119
|
+
props.push(`indexId: "${componentId}"`);
|
|
120
|
+
}
|
|
121
|
+
if (node.layoutPath) {
|
|
122
|
+
const componentId = path_1.default
|
|
123
|
+
.relative(appDir, node.layoutPath)
|
|
124
|
+
.replace(/\\/g, '/')
|
|
125
|
+
.replace(/\.(tsx|ts|jsx|js)$/, '');
|
|
126
|
+
props.push(`layoutId: "${componentId}"`);
|
|
127
|
+
}
|
|
128
|
+
if (node.loadingPath) {
|
|
129
|
+
const componentId = path_1.default
|
|
130
|
+
.relative(appDir, node.loadingPath)
|
|
131
|
+
.replace(/\\/g, '/')
|
|
132
|
+
.replace(/\.(tsx|ts|jsx|js)$/, '');
|
|
133
|
+
props.push(`loadingId: "${componentId}"`);
|
|
134
|
+
}
|
|
135
|
+
if (node.children && node.children.length > 0) {
|
|
136
|
+
const childrenStr = node.children
|
|
137
|
+
.map((child) => serializeRouteStructure(child))
|
|
138
|
+
.join(',\n');
|
|
139
|
+
props.push(`children: [\n${childrenStr}\n]`);
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
props.push(`children: []`);
|
|
143
|
+
}
|
|
144
|
+
return `{\n${props.join(',\n')}\n}`;
|
|
145
|
+
}
|
|
146
|
+
const routeStructure = serializeRouteStructure(routeTree);
|
|
147
|
+
// TRUE RSC CLIENT ENTRY
|
|
148
|
+
// Only client components are imported here
|
|
148
149
|
const clientEntryContent = `
|
|
149
150
|
// Vista Client Entry - TRUE RSC
|
|
150
151
|
// Only client components are bundled here
|
|
@@ -206,253 +207,253 @@ if ((module as any).hot) {
|
|
|
206
207
|
}
|
|
207
208
|
|
|
208
209
|
// Server-Side Live Reload (for server component changes)
|
|
209
|
-
${isDev
|
|
210
|
-
? `
|
|
211
|
-
${(0, devtools_indicator_snippet_1.getDevToolsIndicatorBootstrapSource)(devToolsBootId)}
|
|
212
|
-
${(0, dev_error_overlay_snippet_1.getDevErrorOverlayBootstrapSource)()}
|
|
213
|
-
|
|
214
|
-
const sse = new EventSource('${constants_1.SSE_ENDPOINT}');
|
|
215
|
-
sse.onmessage = (event) => {
|
|
216
|
-
if (event.data === 'reload') {
|
|
217
|
-
const errorOverlay = window.__VISTA_DEV_ERROR_OVERLAY__;
|
|
218
|
-
if (errorOverlay && typeof errorOverlay.clear === 'function') {
|
|
219
|
-
errorOverlay.clear();
|
|
220
|
-
}
|
|
221
|
-
console.log('[Vista] Server component changed, reloading...');
|
|
222
|
-
const indicator = window.__VISTA_DEVTOOLS_INDICATOR__;
|
|
223
|
-
if (indicator && typeof indicator.pulse === 'function') {
|
|
224
|
-
indicator.pulse('hmr', 460);
|
|
225
|
-
}
|
|
226
|
-
setTimeout(() => window.location.reload(), 80);
|
|
227
|
-
return;
|
|
228
|
-
}
|
|
210
|
+
${isDev
|
|
211
|
+
? `
|
|
212
|
+
${(0, devtools_indicator_snippet_1.getDevToolsIndicatorBootstrapSource)(devToolsBootId)}
|
|
213
|
+
${(0, dev_error_overlay_snippet_1.getDevErrorOverlayBootstrapSource)()}
|
|
214
|
+
|
|
215
|
+
const sse = new EventSource('${constants_1.SSE_ENDPOINT}');
|
|
216
|
+
sse.onmessage = (event) => {
|
|
217
|
+
if (event.data === 'reload') {
|
|
218
|
+
const errorOverlay = window.__VISTA_DEV_ERROR_OVERLAY__;
|
|
219
|
+
if (errorOverlay && typeof errorOverlay.clear === 'function') {
|
|
220
|
+
errorOverlay.clear();
|
|
221
|
+
}
|
|
222
|
+
console.log('[Vista] Server component changed, reloading...');
|
|
223
|
+
const indicator = window.__VISTA_DEVTOOLS_INDICATOR__;
|
|
224
|
+
if (indicator && typeof indicator.pulse === 'function') {
|
|
225
|
+
indicator.pulse('hmr', 460);
|
|
226
|
+
}
|
|
227
|
+
setTimeout(() => window.location.reload(), 80);
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
229
230
|
|
|
230
|
-
try {
|
|
231
|
-
const data = JSON.parse(event.data);
|
|
232
|
-
if (data.type === 'error' || data.type === 'structure-error') {
|
|
233
|
-
const errorOverlay = window.__VISTA_DEV_ERROR_OVERLAY__;
|
|
234
|
-
if (errorOverlay && typeof errorOverlay.show === 'function') {
|
|
235
|
-
errorOverlay.show(data.errors || data.message);
|
|
236
|
-
}
|
|
237
|
-
} else if (data.type === 'ok' || data.type === 'structure-ok') {
|
|
238
|
-
const errorOverlay = window.__VISTA_DEV_ERROR_OVERLAY__;
|
|
239
|
-
if (errorOverlay && typeof errorOverlay.clear === 'function') {
|
|
240
|
-
errorOverlay.clear();
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
} catch (e) {
|
|
244
|
-
// Ignore JSON parse errors for non-JSON messages
|
|
245
|
-
}
|
|
246
|
-
};
|
|
231
|
+
try {
|
|
232
|
+
const data = JSON.parse(event.data);
|
|
233
|
+
if (data.type === 'error' || data.type === 'structure-error') {
|
|
234
|
+
const errorOverlay = window.__VISTA_DEV_ERROR_OVERLAY__;
|
|
235
|
+
if (errorOverlay && typeof errorOverlay.show === 'function') {
|
|
236
|
+
errorOverlay.show(data.errors || data.message);
|
|
237
|
+
}
|
|
238
|
+
} else if (data.type === 'ok' || data.type === 'structure-ok') {
|
|
239
|
+
const errorOverlay = window.__VISTA_DEV_ERROR_OVERLAY__;
|
|
240
|
+
if (errorOverlay && typeof errorOverlay.clear === 'function') {
|
|
241
|
+
errorOverlay.clear();
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
} catch (e) {
|
|
245
|
+
// Ignore JSON parse errors for non-JSON messages
|
|
246
|
+
}
|
|
247
|
+
};
|
|
247
248
|
|
|
248
249
|
sse.onerror = (e) => {
|
|
249
250
|
console.log('[Vista] SSE connection lost');
|
|
250
251
|
};
|
|
251
|
-
`
|
|
252
|
+
`
|
|
252
253
|
: '// SSE reload disabled in production'}
|
|
253
254
|
|
|
254
255
|
// Export for debugging
|
|
255
256
|
(window as any).${constants_1.CLIENT_COMPONENTS_FLAG} = CLIENT_COMPONENTS;
|
|
256
|
-
`;
|
|
257
|
-
fs_1.default.writeFileSync(path_1.default.join(vistaDir, 'client.tsx'), clientEntryContent);
|
|
258
|
-
if (_debug) {
|
|
259
|
-
console.log(`[Vista JS RSC] Generated client entry with ${clientComponents.length} client component(s)`);
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
// Webpack Compiler Instance (reused for watch mode)
|
|
263
|
-
let compiler = null;
|
|
264
|
-
exports.compiler = compiler;
|
|
265
|
-
async function buildClient(watch = false, onRebuild) {
|
|
266
|
-
const cwd = process.cwd();
|
|
267
|
-
const vistaDirs = (0, manifest_1.createVistaDirectories)(cwd);
|
|
268
|
-
const vistaDir = vistaDirs.root;
|
|
269
|
-
const buildId = (0, manifest_1.getBuildId)(vistaDir, !watch);
|
|
270
|
-
if (_debug)
|
|
271
|
-
console.log(`Building Client (Watch Mode: ${watch}, Bundler: Webpack + SWC)...`);
|
|
272
|
-
// ========================================================================
|
|
273
|
-
// Pre-build Structure Validation
|
|
274
|
-
// ========================================================================
|
|
275
|
-
const vistaConfig = (0, config_1.loadConfig)(cwd);
|
|
276
|
-
const engineVariant = (0, config_1.resolveAndApplyEngineVariant)(vistaConfig);
|
|
277
|
-
const structureConfig = (0, config_1.resolveStructureValidationConfig)(vistaConfig);
|
|
278
|
-
const cacheComponentsConfig = (0, config_1.resolveCacheComponentsConfig)(vistaConfig);
|
|
279
|
-
if (_debug)
|
|
280
|
-
console.log(`[vista:build] Engine variant: ${engineVariant}`);
|
|
281
|
-
if (structureConfig.enabled) {
|
|
282
|
-
const result = (0, structure_validator_1.validateAppStructure)({ cwd });
|
|
283
|
-
(0, structure_log_1.logValidationResult)(result, structureConfig.logLevel);
|
|
284
|
-
if (result.state === 'error' && structureConfig.mode === 'strict') {
|
|
285
|
-
console.error((0, structure_log_1.formatBuildFailTable)(result));
|
|
286
|
-
process.exit(1);
|
|
287
|
-
}
|
|
288
|
-
// Warnings: continue build, already logged above.
|
|
289
|
-
}
|
|
290
|
-
// Scan app directory using Rust bindings to get client components
|
|
291
|
-
const appDir = path_1.default.join(cwd, 'app');
|
|
292
|
-
const
|
|
293
|
-
let clientComponents = [];
|
|
294
|
-
if (fs_1.default.existsSync(appDir)) {
|
|
295
|
-
if (_debug) {
|
|
296
|
-
console.log(`[Vista JS] Using ${(0, file_scanner_1.isNativeAvailable)() ? 'Rust native' : 'JS fallback'} scanner (v${(0, file_scanner_1.getVersion)()})`);
|
|
297
|
-
}
|
|
298
|
-
const scanResult = (0, file_scanner_1.scanAppDirectory)(appDir);
|
|
299
|
-
if (_debug) {
|
|
300
|
-
console.log(`[Vista JS] Found ${scanResult.clientComponents.length} client components, ${scanResult.serverComponents.length} server components in app/`);
|
|
301
|
-
}
|
|
302
|
-
// Store client components for entry generation
|
|
303
|
-
clientComponents = scanResult.clientComponents.map((c) => ({
|
|
304
|
-
relativePath: c.relativePath,
|
|
305
|
-
absolutePath: c.absolutePath,
|
|
306
|
-
}));
|
|
307
|
-
// Log client components
|
|
308
|
-
if (scanResult.clientComponents.length > 0 && _debug) {
|
|
309
|
-
console.log(`[Vista JS] Client components ('use client') from app/:`);
|
|
310
|
-
scanResult.clientComponents.forEach((c) => {
|
|
311
|
-
console.log(` - ${c.relativePath}`);
|
|
312
|
-
});
|
|
313
|
-
}
|
|
314
|
-
const moduleBoundaryIssues = (0, module_boundary_validator_1.validateModuleBoundaries)({
|
|
315
|
-
appDir,
|
|
316
|
-
extraRoots:
|
|
317
|
-
cacheComponentsEnabled: cacheComponentsConfig.enabled,
|
|
318
|
-
}).issues;
|
|
319
|
-
if (moduleBoundaryIssues.length > 0) {
|
|
320
|
-
console.log('');
|
|
321
|
-
console.log('\x1b[41m\x1b[37m ERROR \x1b[0m \x1b[31mServer/Segment Validation Error\x1b[0m');
|
|
322
|
-
console.log('');
|
|
323
|
-
for (const issue of moduleBoundaryIssues) {
|
|
324
|
-
console.log(`\x1b[31m✗\x1b[0m ${path_1.default.relative(cwd, issue.filePath)}`);
|
|
325
|
-
console.log(` ${issue.message}`);
|
|
326
|
-
console.log('');
|
|
327
|
-
if (issue.fix) {
|
|
328
|
-
console.log(` \x1b[36mTo fix:\x1b[0m ${issue.fix}`);
|
|
329
|
-
console.log('');
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
if (!watch) {
|
|
333
|
-
console.log('\x1b[31mBuild failed due to server/segment violations.\x1b[0m');
|
|
334
|
-
process.exit(1);
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
if (
|
|
350
|
-
console.log(`[Vista JS] Client components ('use client') from
|
|
351
|
-
|
|
352
|
-
console.log(` -
|
|
353
|
-
});
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
if (_debug)
|
|
357
|
-
console.log(`[Vista JS] Total client components: ${clientComponents.length}`);
|
|
358
|
-
// Write canonical artifact manifests for legacy mode.
|
|
359
|
-
try {
|
|
360
|
-
const { getRouteTree } = require('./file-scanner');
|
|
361
|
-
const routeTree = getRouteTree(appDir);
|
|
362
|
-
const routes = collectRouteArtifactEntries(routeTree);
|
|
363
|
-
(0, manifest_1.writeCanonicalVistaArtifacts)(cwd, vistaDir, buildId, routes);
|
|
364
|
-
}
|
|
365
|
-
catch (error) {
|
|
366
|
-
// Keep build behavior resilient in environments where route scan fails.
|
|
367
|
-
(0, manifest_1.writeCanonicalVistaArtifacts)(cwd, vistaDir, buildId, []);
|
|
368
|
-
console.warn(`[vista:build] Failed to derive route artifacts: ${error.message}`);
|
|
369
|
-
}
|
|
370
|
-
(0, manifest_1.writeReservedVistaArtifacts)(vistaDir, {
|
|
371
|
-
buildId,
|
|
372
|
-
engineVariant,
|
|
373
|
-
imagesConfig: vistaConfig.images,
|
|
374
|
-
});
|
|
375
|
-
// Generate client entry - TRUE RSC: only client components
|
|
376
|
-
generateClientEntry(cwd, vistaDir, clientComponents, watch);
|
|
377
|
-
// Create Webpack config
|
|
378
|
-
const config = (0, webpack_config_1.createWebpackConfig)({
|
|
379
|
-
cwd,
|
|
380
|
-
isDev: watch,
|
|
381
|
-
engineVariant,
|
|
382
|
-
cacheComponentsEnabled: cacheComponentsConfig.enabled,
|
|
383
|
-
});
|
|
384
|
-
// Create Webpack compiler
|
|
385
|
-
exports.compiler = compiler = (0, webpack_1.default)(config);
|
|
386
|
-
if (watch) {
|
|
387
|
-
// In watch mode, we return the compiler for use with dev middleware
|
|
388
|
-
// Initial CSS build
|
|
389
|
-
runPostCSS(cwd, vistaDir);
|
|
390
|
-
// Watch CSS + source files that may affect Tailwind output.
|
|
391
|
-
const chokidar = require('chokidar');
|
|
392
|
-
try {
|
|
393
|
-
const styleWatchRoots = ['app', 'components', 'content', 'lib', 'ctx', 'data']
|
|
394
|
-
.map((entry) => path_1.default.join(cwd, entry))
|
|
395
|
-
.filter((entry) => fs_1.default.existsSync(entry));
|
|
396
|
-
let cssTimer = null;
|
|
397
|
-
const scheduleCSSBuild = () => {
|
|
398
|
-
if (cssTimer)
|
|
399
|
-
clearTimeout(cssTimer);
|
|
400
|
-
cssTimer = setTimeout(() => {
|
|
401
|
-
if (_debug)
|
|
402
|
-
console.log('Style source changed, rebuilding CSS...');
|
|
403
|
-
runPostCSS(cwd, vistaDir);
|
|
404
|
-
}, 120);
|
|
405
|
-
};
|
|
406
|
-
chokidar
|
|
407
|
-
.watch(styleWatchRoots, {
|
|
408
|
-
ignoreInitial: true,
|
|
409
|
-
ignored: (watchedPath) => watchedPath.includes(`${path_1.default.sep}node_modules${path_1.default.sep}`) ||
|
|
410
|
-
watchedPath.includes(`${path_1.default.sep}.git${path_1.default.sep}`) ||
|
|
411
|
-
watchedPath.includes(`${path_1.default.sep}.vista${path_1.default.sep}`),
|
|
412
|
-
})
|
|
413
|
-
.on('all', (_event, changedPath) => {
|
|
414
|
-
if (/\.(?:css|[cm]?[jt]sx?|md|mdx)$/i.test(changedPath)) {
|
|
415
|
-
scheduleCSSBuild();
|
|
416
|
-
}
|
|
417
|
-
});
|
|
418
|
-
}
|
|
419
|
-
catch (e) {
|
|
420
|
-
// chokidar not installed, skip CSS watch
|
|
421
|
-
}
|
|
422
|
-
if (_debug)
|
|
423
|
-
console.log('Webpack compiler ready for dev middleware.');
|
|
424
|
-
return compiler;
|
|
425
|
-
}
|
|
426
|
-
else {
|
|
427
|
-
// Production build
|
|
428
|
-
return new Promise((resolve, reject) => {
|
|
429
|
-
compiler.run((err, stats) => {
|
|
430
|
-
if (err) {
|
|
431
|
-
console.error('Webpack build error:', err);
|
|
432
|
-
reject(err);
|
|
433
|
-
return;
|
|
434
|
-
}
|
|
435
|
-
if (stats?.hasErrors()) {
|
|
436
|
-
console.error('Webpack compilation errors:', stats.toString('errors-only'));
|
|
437
|
-
reject(new Error('Compilation failed'));
|
|
438
|
-
return;
|
|
439
|
-
}
|
|
440
|
-
console.log('Webpack build complete!');
|
|
441
|
-
console.log(stats?.toString('minimal'));
|
|
442
|
-
// Build CSS
|
|
443
|
-
runPostCSS(cwd, vistaDir);
|
|
444
|
-
(0, deploy_output_1.generateDeploymentOutputs)({
|
|
445
|
-
cwd,
|
|
446
|
-
vistaDir,
|
|
447
|
-
debug: _debug,
|
|
448
|
-
});
|
|
449
|
-
(0, manifest_1.pruneEmptyVistaDirectories)(vistaDir);
|
|
450
|
-
compiler.close((closeErr) => {
|
|
451
|
-
if (closeErr)
|
|
452
|
-
console.error('Error closing compiler:', closeErr);
|
|
453
|
-
resolve(null);
|
|
454
|
-
});
|
|
455
|
-
});
|
|
456
|
-
});
|
|
457
|
-
}
|
|
458
|
-
}
|
|
257
|
+
`;
|
|
258
|
+
fs_1.default.writeFileSync(path_1.default.join(vistaDir, 'client.tsx'), clientEntryContent);
|
|
259
|
+
if (_debug) {
|
|
260
|
+
console.log(`[Vista JS RSC] Generated client entry with ${clientComponents.length} client component(s)`);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
// Webpack Compiler Instance (reused for watch mode)
|
|
264
|
+
let compiler = null;
|
|
265
|
+
exports.compiler = compiler;
|
|
266
|
+
async function buildClient(watch = false, onRebuild) {
|
|
267
|
+
const cwd = process.cwd();
|
|
268
|
+
const vistaDirs = (0, manifest_1.createVistaDirectories)(cwd);
|
|
269
|
+
const vistaDir = vistaDirs.root;
|
|
270
|
+
const buildId = (0, manifest_1.getBuildId)(vistaDir, !watch);
|
|
271
|
+
if (_debug)
|
|
272
|
+
console.log(`Building Client (Watch Mode: ${watch}, Bundler: Webpack + SWC)...`);
|
|
273
|
+
// ========================================================================
|
|
274
|
+
// Pre-build Structure Validation
|
|
275
|
+
// ========================================================================
|
|
276
|
+
const vistaConfig = (0, config_1.loadConfig)(cwd);
|
|
277
|
+
const engineVariant = (0, config_1.resolveAndApplyEngineVariant)(vistaConfig);
|
|
278
|
+
const structureConfig = (0, config_1.resolveStructureValidationConfig)(vistaConfig);
|
|
279
|
+
const cacheComponentsConfig = (0, config_1.resolveCacheComponentsConfig)(vistaConfig);
|
|
280
|
+
if (_debug)
|
|
281
|
+
console.log(`[vista:build] Engine variant: ${engineVariant}`);
|
|
282
|
+
if (structureConfig.enabled) {
|
|
283
|
+
const result = (0, structure_validator_1.validateAppStructure)({ cwd });
|
|
284
|
+
(0, structure_log_1.logValidationResult)(result, structureConfig.logLevel);
|
|
285
|
+
if (result.state === 'error' && structureConfig.mode === 'strict') {
|
|
286
|
+
console.error((0, structure_log_1.formatBuildFailTable)(result));
|
|
287
|
+
process.exit(1);
|
|
288
|
+
}
|
|
289
|
+
// Warnings: continue build, already logged above.
|
|
290
|
+
}
|
|
291
|
+
// Scan app directory using Rust bindings to get client components
|
|
292
|
+
const appDir = path_1.default.join(cwd, 'app');
|
|
293
|
+
const additionalClientRoots = (0, client_manifest_1.discoverProjectClientRoots)(cwd).filter((root) => path_1.default.resolve(root.dir) !== path_1.default.resolve(appDir));
|
|
294
|
+
let clientComponents = [];
|
|
295
|
+
if (fs_1.default.existsSync(appDir)) {
|
|
296
|
+
if (_debug) {
|
|
297
|
+
console.log(`[Vista JS] Using ${(0, file_scanner_1.isNativeAvailable)() ? 'Rust native' : 'JS fallback'} scanner (v${(0, file_scanner_1.getVersion)()})`);
|
|
298
|
+
}
|
|
299
|
+
const scanResult = (0, file_scanner_1.scanAppDirectory)(appDir);
|
|
300
|
+
if (_debug) {
|
|
301
|
+
console.log(`[Vista JS] Found ${scanResult.clientComponents.length} client components, ${scanResult.serverComponents.length} server components in app/`);
|
|
302
|
+
}
|
|
303
|
+
// Store client components for entry generation
|
|
304
|
+
clientComponents = scanResult.clientComponents.map((c) => ({
|
|
305
|
+
relativePath: c.relativePath,
|
|
306
|
+
absolutePath: c.absolutePath,
|
|
307
|
+
}));
|
|
308
|
+
// Log client components
|
|
309
|
+
if (scanResult.clientComponents.length > 0 && _debug) {
|
|
310
|
+
console.log(`[Vista JS] Client components ('use client') from app/:`);
|
|
311
|
+
scanResult.clientComponents.forEach((c) => {
|
|
312
|
+
console.log(` - ${c.relativePath}`);
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
const moduleBoundaryIssues = (0, module_boundary_validator_1.validateModuleBoundaries)({
|
|
316
|
+
appDir,
|
|
317
|
+
extraRoots: additionalClientRoots.map((root) => root.dir),
|
|
318
|
+
cacheComponentsEnabled: cacheComponentsConfig.enabled,
|
|
319
|
+
}).issues;
|
|
320
|
+
if (moduleBoundaryIssues.length > 0) {
|
|
321
|
+
console.log('');
|
|
322
|
+
console.log('\x1b[41m\x1b[37m ERROR \x1b[0m \x1b[31mServer/Segment Validation Error\x1b[0m');
|
|
323
|
+
console.log('');
|
|
324
|
+
for (const issue of moduleBoundaryIssues) {
|
|
325
|
+
console.log(`\x1b[31m✗\x1b[0m ${path_1.default.relative(cwd, issue.filePath)}`);
|
|
326
|
+
console.log(` ${issue.message}`);
|
|
327
|
+
console.log('');
|
|
328
|
+
if (issue.fix) {
|
|
329
|
+
console.log(` \x1b[36mTo fix:\x1b[0m ${issue.fix}`);
|
|
330
|
+
console.log('');
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
if (!watch) {
|
|
334
|
+
console.log('\x1b[31mBuild failed due to server/segment violations.\x1b[0m');
|
|
335
|
+
process.exit(1);
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
for (const root of additionalClientRoots) {
|
|
340
|
+
if (_debug)
|
|
341
|
+
console.log(`[Vista JS] Scanning ${root.prefix} directory...`);
|
|
342
|
+
const extraScan = (0, file_scanner_1.scanAppDirectory)(root.dir);
|
|
343
|
+
clientComponents = [
|
|
344
|
+
...clientComponents,
|
|
345
|
+
...extraScan.clientComponents.map((c) => ({
|
|
346
|
+
relativePath: `${root.prefix}${c.relativePath}`,
|
|
347
|
+
absolutePath: c.absolutePath,
|
|
348
|
+
})),
|
|
349
|
+
];
|
|
350
|
+
if (extraScan.clientComponents.length > 0 && _debug) {
|
|
351
|
+
console.log(`[Vista JS] Client components ('use client') from ${root.prefix}:`);
|
|
352
|
+
extraScan.clientComponents.forEach((c) => {
|
|
353
|
+
console.log(` - ${root.prefix}${c.relativePath}`);
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
if (_debug)
|
|
358
|
+
console.log(`[Vista JS] Total client components: ${clientComponents.length}`);
|
|
359
|
+
// Write canonical artifact manifests for legacy mode.
|
|
360
|
+
try {
|
|
361
|
+
const { getRouteTree } = require('./file-scanner');
|
|
362
|
+
const routeTree = getRouteTree(appDir);
|
|
363
|
+
const routes = collectRouteArtifactEntries(routeTree);
|
|
364
|
+
(0, manifest_1.writeCanonicalVistaArtifacts)(cwd, vistaDir, buildId, routes);
|
|
365
|
+
}
|
|
366
|
+
catch (error) {
|
|
367
|
+
// Keep build behavior resilient in environments where route scan fails.
|
|
368
|
+
(0, manifest_1.writeCanonicalVistaArtifacts)(cwd, vistaDir, buildId, []);
|
|
369
|
+
console.warn(`[vista:build] Failed to derive route artifacts: ${error.message}`);
|
|
370
|
+
}
|
|
371
|
+
(0, manifest_1.writeReservedVistaArtifacts)(vistaDir, {
|
|
372
|
+
buildId,
|
|
373
|
+
engineVariant,
|
|
374
|
+
imagesConfig: vistaConfig.images,
|
|
375
|
+
});
|
|
376
|
+
// Generate client entry - TRUE RSC: only client components
|
|
377
|
+
generateClientEntry(cwd, vistaDir, clientComponents, watch);
|
|
378
|
+
// Create Webpack config
|
|
379
|
+
const config = (0, webpack_config_1.createWebpackConfig)({
|
|
380
|
+
cwd,
|
|
381
|
+
isDev: watch,
|
|
382
|
+
engineVariant,
|
|
383
|
+
cacheComponentsEnabled: cacheComponentsConfig.enabled,
|
|
384
|
+
});
|
|
385
|
+
// Create Webpack compiler
|
|
386
|
+
exports.compiler = compiler = (0, webpack_1.default)(config);
|
|
387
|
+
if (watch) {
|
|
388
|
+
// In watch mode, we return the compiler for use with dev middleware
|
|
389
|
+
// Initial CSS build
|
|
390
|
+
runPostCSS(cwd, vistaDir);
|
|
391
|
+
// Watch CSS + source files that may affect Tailwind output.
|
|
392
|
+
const chokidar = require('chokidar');
|
|
393
|
+
try {
|
|
394
|
+
const styleWatchRoots = ['app', 'components', 'content', 'lib', 'ctx', 'data']
|
|
395
|
+
.map((entry) => path_1.default.join(cwd, entry))
|
|
396
|
+
.filter((entry) => fs_1.default.existsSync(entry));
|
|
397
|
+
let cssTimer = null;
|
|
398
|
+
const scheduleCSSBuild = () => {
|
|
399
|
+
if (cssTimer)
|
|
400
|
+
clearTimeout(cssTimer);
|
|
401
|
+
cssTimer = setTimeout(() => {
|
|
402
|
+
if (_debug)
|
|
403
|
+
console.log('Style source changed, rebuilding CSS...');
|
|
404
|
+
runPostCSS(cwd, vistaDir);
|
|
405
|
+
}, 120);
|
|
406
|
+
};
|
|
407
|
+
chokidar
|
|
408
|
+
.watch(styleWatchRoots, {
|
|
409
|
+
ignoreInitial: true,
|
|
410
|
+
ignored: (watchedPath) => watchedPath.includes(`${path_1.default.sep}node_modules${path_1.default.sep}`) ||
|
|
411
|
+
watchedPath.includes(`${path_1.default.sep}.git${path_1.default.sep}`) ||
|
|
412
|
+
watchedPath.includes(`${path_1.default.sep}.vista${path_1.default.sep}`),
|
|
413
|
+
})
|
|
414
|
+
.on('all', (_event, changedPath) => {
|
|
415
|
+
if (/\.(?:css|[cm]?[jt]sx?|md|mdx)$/i.test(changedPath)) {
|
|
416
|
+
scheduleCSSBuild();
|
|
417
|
+
}
|
|
418
|
+
});
|
|
419
|
+
}
|
|
420
|
+
catch (e) {
|
|
421
|
+
// chokidar not installed, skip CSS watch
|
|
422
|
+
}
|
|
423
|
+
if (_debug)
|
|
424
|
+
console.log('Webpack compiler ready for dev middleware.');
|
|
425
|
+
return compiler;
|
|
426
|
+
}
|
|
427
|
+
else {
|
|
428
|
+
// Production build
|
|
429
|
+
return new Promise((resolve, reject) => {
|
|
430
|
+
compiler.run((err, stats) => {
|
|
431
|
+
if (err) {
|
|
432
|
+
console.error('Webpack build error:', err);
|
|
433
|
+
reject(err);
|
|
434
|
+
return;
|
|
435
|
+
}
|
|
436
|
+
if (stats?.hasErrors()) {
|
|
437
|
+
console.error('Webpack compilation errors:', stats.toString('errors-only'));
|
|
438
|
+
reject(new Error('Compilation failed'));
|
|
439
|
+
return;
|
|
440
|
+
}
|
|
441
|
+
console.log('Webpack build complete!');
|
|
442
|
+
console.log(stats?.toString('minimal'));
|
|
443
|
+
// Build CSS
|
|
444
|
+
runPostCSS(cwd, vistaDir);
|
|
445
|
+
(0, deploy_output_1.generateDeploymentOutputs)({
|
|
446
|
+
cwd,
|
|
447
|
+
vistaDir,
|
|
448
|
+
debug: _debug,
|
|
449
|
+
});
|
|
450
|
+
(0, manifest_1.pruneEmptyVistaDirectories)(vistaDir);
|
|
451
|
+
compiler.close((closeErr) => {
|
|
452
|
+
if (closeErr)
|
|
453
|
+
console.error('Error closing compiler:', closeErr);
|
|
454
|
+
resolve(null);
|
|
455
|
+
});
|
|
456
|
+
});
|
|
457
|
+
});
|
|
458
|
+
}
|
|
459
|
+
}
|