@vistagenic/vista 0.3.0 → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/vista.js +79 -109
- package/dist/ai/embeddings.d.ts +11 -11
- package/dist/ai/embeddings.js +71 -71
- package/dist/ai/index.d.ts +10 -10
- package/dist/ai/index.js +26 -26
- package/dist/ai/providers/base.js +85 -85
- package/dist/ai/react/react-server.d.ts +1 -1
- package/dist/ai/react/react-server.js +17 -17
- package/dist/ai/react/use-agent.js +138 -138
- package/dist/auth/core.d.ts +140 -140
- package/dist/auth/core.js +165 -165
- package/dist/auth/index.d.ts +20 -20
- package/dist/auth/index.js +369 -369
- package/dist/auth/react-server.d.ts +1 -1
- package/dist/auth/react-server.js +10 -10
- package/dist/auth/react.d.ts +18 -18
- package/dist/auth/react.js +71 -71
- package/dist/bin/build-rsc-flashpack.js +6 -0
- package/dist/bin/build-rsc.js +537 -492
- package/dist/bin/build.js +355 -353
- package/dist/bin/dev-error-overlay-snippet.js +379 -153
- package/dist/bin/generate.js +513 -510
- package/dist/bin/webpack.config.js +4 -3
- package/dist/build/manifest.d.ts +169 -169
- package/dist/build/manifest.js +423 -423
- package/dist/build/rsc/client-manifest.d.ts +62 -62
- package/dist/build/rsc/client-manifest.js +295 -295
- package/dist/build/rsc/compiler.js +5 -4
- package/dist/build/rsc/native-scanner.d.ts +135 -135
- package/dist/build/rsc/native-scanner.js +203 -203
- package/dist/build/rsc/react-client-reference-manifest.d.ts +28 -28
- package/dist/build/rsc/react-client-reference-manifest.js +240 -240
- package/dist/build/standalone.js +260 -254
- package/dist/client/dynamic.react-server.d.ts +2 -2
- package/dist/client/dynamic.react-server.js +23 -23
- package/dist/client/link.react-server.d.ts +2 -2
- package/dist/client/link.react-server.js +11 -11
- package/dist/client/navigation.react-server.d.ts +1 -1
- package/dist/client/navigation.react-server.js +17 -17
- package/dist/client/router.react-server.d.ts +1 -1
- package/dist/client/router.react-server.js +17 -17
- package/dist/client/rsc-router.react-server.d.ts +1 -1
- package/dist/client/rsc-router.react-server.js +17 -17
- package/dist/client/script.react-server.d.ts +2 -2
- package/dist/client/script.react-server.js +23 -23
- package/dist/config.d.ts +1 -1
- package/dist/config.js +1 -7
- package/dist/deploy/adapters/cloudflare.js +43 -19
- package/dist/deploy/adapters/docker.d.ts +1 -0
- package/dist/deploy/adapters/docker.js +5 -4
- package/dist/deploy/adapters/netlify.js +62 -17
- package/dist/deploy/adapters/vercel.js +80 -50
- package/dist/deploy/preflight.js +4 -3
- package/dist/deploy/runtime-pack.d.ts +11 -0
- package/dist/deploy/runtime-pack.js +300 -0
- package/dist/deploy/utils.d.ts +1 -1
- package/dist/deploy/utils.js +31 -2
- package/dist/dev-error.d.ts +14 -0
- package/dist/dev-error.js +1394 -336
- package/dist/flashpack/command.js +1 -0
- package/dist/flashpack/runtime.js +2 -1
- package/dist/index.d.ts +23 -23
- package/dist/index.js +61 -61
- package/dist/server/app-dir.d.ts +22 -0
- package/dist/server/app-dir.js +77 -0
- package/dist/server/cookie-parse.d.ts +4 -4
- package/dist/server/cookie-parse.js +14 -14
- package/dist/server/engine.js +6 -12
- package/dist/server/image-optimizer.js +2 -1
- package/dist/server/index.d.ts +109 -109
- package/dist/server/index.js +315 -315
- package/dist/server/middleware-runner.d.ts +125 -125
- package/dist/server/middleware-runner.js +607 -615
- package/dist/server/middleware-security.d.ts +36 -36
- package/dist/server/middleware-security.js +183 -183
- package/dist/server/module-compile-hook.js +695 -695
- package/dist/server/root-resolver.js +6 -5
- package/dist/server/rsc-engine-flashpack.d.ts +3 -1
- package/dist/server/rsc-engine-flashpack.js +12 -1
- package/dist/server/rsc-engine.d.ts +6 -1
- package/dist/server/rsc-engine.js +203 -229
- package/dist/server/rsc-upstream.js +893 -892
- package/dist/server/static-generator.js +4 -3
- package/dist/server/structure-validator.js +2 -1
- package/dist/server/structure-watch.js +2 -0
- package/dist/server/typed-api-runtime.js +639 -635
- package/dist/server/vista-import-map.js +134 -134
- package/dist/stack/index.d.ts +34 -34
- package/dist/stack/index.js +49 -49
- package/dist/stack/server/caller.d.ts +13 -13
- package/dist/stack/server/caller.js +42 -42
- package/dist/stack/server/executor.d.ts +40 -40
- package/dist/stack/server/executor.js +222 -222
- package/dist/stack/server/index.d.ts +11 -11
- package/dist/stack/server/index.js +24 -24
- package/dist/stack/server/procedure.d.ts +20 -20
- package/dist/stack/server/procedure.js +66 -66
- package/dist/stack/server/types.d.ts +113 -113
- package/dist/theme/react-server.d.ts +10 -10
- package/dist/theme/react-server.js +16 -16
- package/package.json +178 -178
package/dist/build/standalone.js
CHANGED
|
@@ -1,168 +1,168 @@
|
|
|
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.generateStandaloneOutput = generateStandaloneOutput;
|
|
7
|
-
const fs_1 = __importDefault(require("fs"));
|
|
8
|
-
const path_1 = __importDefault(require("path"));
|
|
9
|
-
const url_1 = require("url");
|
|
10
|
-
const manifest_1 = require("./manifest");
|
|
11
|
-
const EXCLUDED_DIRECTORIES = new Set([
|
|
12
|
-
'.git',
|
|
13
|
-
'.vista',
|
|
14
|
-
'.flash',
|
|
15
|
-
'.turbo',
|
|
16
|
-
'.next',
|
|
17
|
-
'.vercel',
|
|
18
|
-
'node_modules',
|
|
19
|
-
'coverage',
|
|
20
|
-
]);
|
|
21
|
-
const EXCLUDED_FILE_SUFFIXES = ['.log', '.tsbuildinfo'];
|
|
22
|
-
function ensureDir(absolutePath) {
|
|
23
|
-
fs_1.default.mkdirSync(absolutePath, { recursive: true });
|
|
24
|
-
}
|
|
25
|
-
function isExcludedDirectory(name) {
|
|
26
|
-
return EXCLUDED_DIRECTORIES.has(name);
|
|
27
|
-
}
|
|
28
|
-
function isExcludedFile(name) {
|
|
29
|
-
return EXCLUDED_FILE_SUFFIXES.some((suffix) => name.endsWith(suffix));
|
|
30
|
-
}
|
|
31
|
-
function copyDirectoryRecursive(sourceDir, targetDir) {
|
|
32
|
-
if (!fs_1.default.existsSync(sourceDir)) {
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
ensureDir(targetDir);
|
|
36
|
-
for (const entry of fs_1.default.readdirSync(sourceDir, { withFileTypes: true })) {
|
|
37
|
-
if (entry.isDirectory()) {
|
|
38
|
-
copyDirectoryRecursive(path_1.default.join(sourceDir, entry.name), path_1.default.join(targetDir, entry.name));
|
|
39
|
-
continue;
|
|
40
|
-
}
|
|
41
|
-
if (!entry.isFile()) {
|
|
42
|
-
continue;
|
|
43
|
-
}
|
|
44
|
-
ensureDir(targetDir);
|
|
45
|
-
fs_1.default.copyFileSync(path_1.default.join(sourceDir, entry.name), path_1.default.join(targetDir, entry.name));
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
function copyProjectSnapshot(sourceRoot, targetRoot) {
|
|
49
|
-
const copiedFiles = [];
|
|
50
|
-
const copiedDirectories = [];
|
|
51
|
-
const visit = (currentSource, currentTarget) => {
|
|
52
|
-
ensureDir(currentTarget);
|
|
53
|
-
const relativeDir = path_1.default.relative(sourceRoot, currentSource) || '.';
|
|
54
|
-
copiedDirectories.push(relativeDir.replace(/\\/g, '/'));
|
|
55
|
-
for (const entry of fs_1.default.readdirSync(currentSource, { withFileTypes: true })) {
|
|
56
|
-
if (entry.isDirectory()) {
|
|
57
|
-
if (isExcludedDirectory(entry.name)) {
|
|
58
|
-
continue;
|
|
59
|
-
}
|
|
60
|
-
visit(path_1.default.join(currentSource, entry.name), path_1.default.join(currentTarget, entry.name));
|
|
61
|
-
continue;
|
|
62
|
-
}
|
|
63
|
-
if (!entry.isFile() || isExcludedFile(entry.name)) {
|
|
64
|
-
continue;
|
|
65
|
-
}
|
|
66
|
-
const sourceFile = path_1.default.join(currentSource, entry.name);
|
|
67
|
-
const targetFile = path_1.default.join(currentTarget, entry.name);
|
|
68
|
-
ensureDir(path_1.default.dirname(targetFile));
|
|
69
|
-
fs_1.default.copyFileSync(sourceFile, targetFile);
|
|
70
|
-
copiedFiles.push(path_1.default.relative(sourceRoot, sourceFile).replace(/\\/g, '/'));
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
visit(sourceRoot, targetRoot);
|
|
74
|
-
copiedFiles.sort();
|
|
75
|
-
copiedDirectories.sort();
|
|
76
|
-
return { copiedFiles, copiedDirectories };
|
|
77
|
-
}
|
|
78
|
-
function resolveFrameworkDistRoot(cwd) {
|
|
79
|
-
const candidates = [];
|
|
80
|
-
try {
|
|
81
|
-
const packageJsonPath = require.resolve('@vistagenic/vista/package.json', { paths: [cwd] });
|
|
82
|
-
candidates.push(path_1.default.join(path_1.default.dirname(packageJsonPath), 'dist'));
|
|
83
|
-
}
|
|
84
|
-
catch {
|
|
85
|
-
// fall through
|
|
86
|
-
}
|
|
87
|
-
candidates.push(path_1.default.resolve(__dirname, '..', '..', 'dist'));
|
|
88
|
-
for (const candidate of candidates) {
|
|
89
|
-
if (fs_1.default.existsSync(candidate)) {
|
|
90
|
-
return candidate;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
throw new Error('[vista:build] Unable to locate the Vista runtime dist directory.');
|
|
94
|
-
}
|
|
95
|
-
function isWithinRoot(candidatePath, rootPath) {
|
|
96
|
-
const relative = path_1.default.relative(rootPath, candidatePath);
|
|
97
|
-
return relative === '' || (!relative.startsWith('..') && !path_1.default.isAbsolute(relative));
|
|
98
|
-
}
|
|
99
|
-
function rebaseAbsolutePath(absolutePath, context) {
|
|
100
|
-
const normalizedAbsolute = path_1.default.resolve(absolutePath);
|
|
101
|
-
if (isWithinRoot(normalizedAbsolute, context.projectRoot)) {
|
|
102
|
-
return path_1.default.join(context.runtimeRoot, path_1.default.relative(context.projectRoot, normalizedAbsolute));
|
|
103
|
-
}
|
|
104
|
-
if (isWithinRoot(normalizedAbsolute, context.frameworkDistRoot)) {
|
|
105
|
-
return path_1.default.join(context.frameworkRuntimeRoot, path_1.default.relative(context.frameworkDistRoot, normalizedAbsolute));
|
|
106
|
-
}
|
|
107
|
-
return absolutePath;
|
|
108
|
-
}
|
|
109
|
-
function rewriteStringValue(value, context) {
|
|
110
|
-
if (value.startsWith('file://')) {
|
|
111
|
-
try {
|
|
112
|
-
const parsed = new URL(value);
|
|
113
|
-
const preserveEmptyHash = value.endsWith('#') && parsed.hash === '';
|
|
114
|
-
const decoded = (0, url_1.fileURLToPath)(parsed);
|
|
115
|
-
const rebased = rebaseAbsolutePath(decoded, context);
|
|
116
|
-
if (rebased === decoded) {
|
|
117
|
-
return value;
|
|
118
|
-
}
|
|
119
|
-
const nextUrl = (0, url_1.pathToFileURL)(rebased);
|
|
120
|
-
nextUrl.hash = parsed.hash;
|
|
121
|
-
const rewritten = nextUrl
|
|
122
|
-
.toString()
|
|
123
|
-
.replace(/^file:\/\/\/([A-Z]):/, (_match, driveLetter) => {
|
|
124
|
-
return `file:///${driveLetter.toLowerCase()}:`;
|
|
125
|
-
});
|
|
126
|
-
return preserveEmptyHash && !rewritten.endsWith('#') ? `${rewritten}#` : rewritten;
|
|
127
|
-
}
|
|
128
|
-
catch {
|
|
129
|
-
return value;
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
if (!path_1.default.isAbsolute(value)) {
|
|
133
|
-
return value;
|
|
134
|
-
}
|
|
135
|
-
const rebased = rebaseAbsolutePath(value, context);
|
|
136
|
-
if (rebased === value) {
|
|
137
|
-
return value;
|
|
138
|
-
}
|
|
139
|
-
if (value.includes('\\')) {
|
|
140
|
-
return rebased;
|
|
141
|
-
}
|
|
142
|
-
return rebased.replace(/\\/g, '/');
|
|
143
|
-
}
|
|
144
|
-
function rewriteManifestValue(value, context) {
|
|
145
|
-
if (typeof value === 'string') {
|
|
146
|
-
return rewriteStringValue(value, context);
|
|
147
|
-
}
|
|
148
|
-
if (Array.isArray(value)) {
|
|
149
|
-
return value.map((entry) => rewriteManifestValue(entry, context));
|
|
150
|
-
}
|
|
151
|
-
if (value && typeof value === 'object') {
|
|
152
|
-
const next = {};
|
|
153
|
-
for (const [rawKey, rawValue] of Object.entries(value)) {
|
|
154
|
-
const nextKey = rewriteStringValue(rawKey, context);
|
|
155
|
-
next[nextKey] = rewriteManifestValue(rawValue, context);
|
|
156
|
-
}
|
|
157
|
-
return next;
|
|
158
|
-
}
|
|
159
|
-
return value;
|
|
160
|
-
}
|
|
161
|
-
function writeJsonFile(absolutePath, payload) {
|
|
162
|
-
ensureDir(path_1.default.dirname(absolutePath));
|
|
163
|
-
fs_1.default.writeFileSync(absolutePath, JSON.stringify(payload, null, 2));
|
|
164
|
-
}
|
|
165
|
-
function writeStandaloneServerEntry(standaloneDir) {
|
|
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.generateStandaloneOutput = generateStandaloneOutput;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const url_1 = require("url");
|
|
10
|
+
const manifest_1 = require("./manifest");
|
|
11
|
+
const EXCLUDED_DIRECTORIES = new Set([
|
|
12
|
+
'.git',
|
|
13
|
+
'.vista',
|
|
14
|
+
'.flash',
|
|
15
|
+
'.turbo',
|
|
16
|
+
'.next',
|
|
17
|
+
'.vercel',
|
|
18
|
+
'node_modules',
|
|
19
|
+
'coverage',
|
|
20
|
+
]);
|
|
21
|
+
const EXCLUDED_FILE_SUFFIXES = ['.log', '.tsbuildinfo'];
|
|
22
|
+
function ensureDir(absolutePath) {
|
|
23
|
+
fs_1.default.mkdirSync(absolutePath, { recursive: true });
|
|
24
|
+
}
|
|
25
|
+
function isExcludedDirectory(name) {
|
|
26
|
+
return EXCLUDED_DIRECTORIES.has(name);
|
|
27
|
+
}
|
|
28
|
+
function isExcludedFile(name) {
|
|
29
|
+
return EXCLUDED_FILE_SUFFIXES.some((suffix) => name.endsWith(suffix));
|
|
30
|
+
}
|
|
31
|
+
function copyDirectoryRecursive(sourceDir, targetDir) {
|
|
32
|
+
if (!fs_1.default.existsSync(sourceDir)) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
ensureDir(targetDir);
|
|
36
|
+
for (const entry of fs_1.default.readdirSync(sourceDir, { withFileTypes: true })) {
|
|
37
|
+
if (entry.isDirectory()) {
|
|
38
|
+
copyDirectoryRecursive(path_1.default.join(sourceDir, entry.name), path_1.default.join(targetDir, entry.name));
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
if (!entry.isFile()) {
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
ensureDir(targetDir);
|
|
45
|
+
fs_1.default.copyFileSync(path_1.default.join(sourceDir, entry.name), path_1.default.join(targetDir, entry.name));
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function copyProjectSnapshot(sourceRoot, targetRoot) {
|
|
49
|
+
const copiedFiles = [];
|
|
50
|
+
const copiedDirectories = [];
|
|
51
|
+
const visit = (currentSource, currentTarget) => {
|
|
52
|
+
ensureDir(currentTarget);
|
|
53
|
+
const relativeDir = path_1.default.relative(sourceRoot, currentSource) || '.';
|
|
54
|
+
copiedDirectories.push(relativeDir.replace(/\\/g, '/'));
|
|
55
|
+
for (const entry of fs_1.default.readdirSync(currentSource, { withFileTypes: true })) {
|
|
56
|
+
if (entry.isDirectory()) {
|
|
57
|
+
if (isExcludedDirectory(entry.name)) {
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
visit(path_1.default.join(currentSource, entry.name), path_1.default.join(currentTarget, entry.name));
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
if (!entry.isFile() || isExcludedFile(entry.name)) {
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
const sourceFile = path_1.default.join(currentSource, entry.name);
|
|
67
|
+
const targetFile = path_1.default.join(currentTarget, entry.name);
|
|
68
|
+
ensureDir(path_1.default.dirname(targetFile));
|
|
69
|
+
fs_1.default.copyFileSync(sourceFile, targetFile);
|
|
70
|
+
copiedFiles.push(path_1.default.relative(sourceRoot, sourceFile).replace(/\\/g, '/'));
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
visit(sourceRoot, targetRoot);
|
|
74
|
+
copiedFiles.sort();
|
|
75
|
+
copiedDirectories.sort();
|
|
76
|
+
return { copiedFiles, copiedDirectories };
|
|
77
|
+
}
|
|
78
|
+
function resolveFrameworkDistRoot(cwd) {
|
|
79
|
+
const candidates = [];
|
|
80
|
+
try {
|
|
81
|
+
const packageJsonPath = require.resolve('@vistagenic/vista/package.json', { paths: [cwd] });
|
|
82
|
+
candidates.push(path_1.default.join(path_1.default.dirname(packageJsonPath), 'dist'));
|
|
83
|
+
}
|
|
84
|
+
catch {
|
|
85
|
+
// fall through
|
|
86
|
+
}
|
|
87
|
+
candidates.push(path_1.default.resolve(__dirname, '..', '..', 'dist'));
|
|
88
|
+
for (const candidate of candidates) {
|
|
89
|
+
if (fs_1.default.existsSync(candidate)) {
|
|
90
|
+
return candidate;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
throw new Error('[vista:build] Unable to locate the Vista runtime dist directory.');
|
|
94
|
+
}
|
|
95
|
+
function isWithinRoot(candidatePath, rootPath) {
|
|
96
|
+
const relative = path_1.default.relative(rootPath, candidatePath);
|
|
97
|
+
return relative === '' || (!relative.startsWith('..') && !path_1.default.isAbsolute(relative));
|
|
98
|
+
}
|
|
99
|
+
function rebaseAbsolutePath(absolutePath, context) {
|
|
100
|
+
const normalizedAbsolute = path_1.default.resolve(absolutePath);
|
|
101
|
+
if (isWithinRoot(normalizedAbsolute, context.projectRoot)) {
|
|
102
|
+
return path_1.default.join(context.runtimeRoot, path_1.default.relative(context.projectRoot, normalizedAbsolute));
|
|
103
|
+
}
|
|
104
|
+
if (isWithinRoot(normalizedAbsolute, context.frameworkDistRoot)) {
|
|
105
|
+
return path_1.default.join(context.frameworkRuntimeRoot, path_1.default.relative(context.frameworkDistRoot, normalizedAbsolute));
|
|
106
|
+
}
|
|
107
|
+
return absolutePath;
|
|
108
|
+
}
|
|
109
|
+
function rewriteStringValue(value, context) {
|
|
110
|
+
if (value.startsWith('file://')) {
|
|
111
|
+
try {
|
|
112
|
+
const parsed = new URL(value);
|
|
113
|
+
const preserveEmptyHash = value.endsWith('#') && parsed.hash === '';
|
|
114
|
+
const decoded = (0, url_1.fileURLToPath)(parsed);
|
|
115
|
+
const rebased = rebaseAbsolutePath(decoded, context);
|
|
116
|
+
if (rebased === decoded) {
|
|
117
|
+
return value;
|
|
118
|
+
}
|
|
119
|
+
const nextUrl = (0, url_1.pathToFileURL)(rebased);
|
|
120
|
+
nextUrl.hash = parsed.hash;
|
|
121
|
+
const rewritten = nextUrl
|
|
122
|
+
.toString()
|
|
123
|
+
.replace(/^file:\/\/\/([A-Z]):/, (_match, driveLetter) => {
|
|
124
|
+
return `file:///${driveLetter.toLowerCase()}:`;
|
|
125
|
+
});
|
|
126
|
+
return preserveEmptyHash && !rewritten.endsWith('#') ? `${rewritten}#` : rewritten;
|
|
127
|
+
}
|
|
128
|
+
catch {
|
|
129
|
+
return value;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
if (!path_1.default.isAbsolute(value)) {
|
|
133
|
+
return value;
|
|
134
|
+
}
|
|
135
|
+
const rebased = rebaseAbsolutePath(value, context);
|
|
136
|
+
if (rebased === value) {
|
|
137
|
+
return value;
|
|
138
|
+
}
|
|
139
|
+
if (value.includes('\\')) {
|
|
140
|
+
return rebased;
|
|
141
|
+
}
|
|
142
|
+
return rebased.replace(/\\/g, '/');
|
|
143
|
+
}
|
|
144
|
+
function rewriteManifestValue(value, context) {
|
|
145
|
+
if (typeof value === 'string') {
|
|
146
|
+
return rewriteStringValue(value, context);
|
|
147
|
+
}
|
|
148
|
+
if (Array.isArray(value)) {
|
|
149
|
+
return value.map((entry) => rewriteManifestValue(entry, context));
|
|
150
|
+
}
|
|
151
|
+
if (value && typeof value === 'object') {
|
|
152
|
+
const next = {};
|
|
153
|
+
for (const [rawKey, rawValue] of Object.entries(value)) {
|
|
154
|
+
const nextKey = rewriteStringValue(rawKey, context);
|
|
155
|
+
next[nextKey] = rewriteManifestValue(rawValue, context);
|
|
156
|
+
}
|
|
157
|
+
return next;
|
|
158
|
+
}
|
|
159
|
+
return value;
|
|
160
|
+
}
|
|
161
|
+
function writeJsonFile(absolutePath, payload) {
|
|
162
|
+
ensureDir(path_1.default.dirname(absolutePath));
|
|
163
|
+
fs_1.default.writeFileSync(absolutePath, JSON.stringify(payload, null, 2));
|
|
164
|
+
}
|
|
165
|
+
function writeStandaloneServerEntry(standaloneDir) {
|
|
166
166
|
const serverEntry = `#!/usr/bin/env node
|
|
167
167
|
const path = require('path');
|
|
168
168
|
const fs = require('fs');
|
|
@@ -236,102 +236,108 @@ function startStandaloneServer(options = {}) {
|
|
|
236
236
|
: path.join(__dirname, 'runtime', 'vista', 'server', 'rsc-engine.js');
|
|
237
237
|
const runtime = require(runtimeEntry);
|
|
238
238
|
const start = runtime.startRSCServer || runtime.default;
|
|
239
|
-
|
|
239
|
+
const listen = options.listen !== false;
|
|
240
|
+
return start({
|
|
240
241
|
port: options.port || process.env.PORT || 3003,
|
|
241
242
|
projectRoot,
|
|
242
243
|
runtimeRoot,
|
|
244
|
+
listen,
|
|
243
245
|
});
|
|
244
246
|
}
|
|
245
247
|
|
|
246
|
-
|
|
248
|
+
function createRequestListener(options = {}) {
|
|
249
|
+
return startStandaloneServer({ ...options, listen: false });
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
module.exports = { startStandaloneServer, createRequestListener };
|
|
247
253
|
|
|
248
254
|
if (require.main === module) {
|
|
249
255
|
startStandaloneServer();
|
|
250
256
|
}
|
|
251
|
-
`;
|
|
252
|
-
fs_1.default.writeFileSync(path_1.default.join(standaloneDir, 'server.js'), serverEntry, 'utf-8');
|
|
253
|
-
}
|
|
254
|
-
function generateStandaloneOutput(options) {
|
|
255
|
-
const { cwd, vistaDir, buildId, serverManifest, debug = false } = options;
|
|
256
|
-
const standaloneDir = path_1.default.join(vistaDir, 'standalone');
|
|
257
|
-
const runtimeProjectRoot = path_1.default.join(standaloneDir, 'project');
|
|
258
|
-
const frameworkRuntimeRoot = path_1.default.join(standaloneDir, 'runtime', 'vista');
|
|
259
|
-
const runtimeManifestPath = path_1.default.join(vistaDir, 'server', 'runtime-manifest.json');
|
|
260
|
-
const fileTracePath = path_1.default.join(vistaDir, 'server', 'file-trace.json');
|
|
261
|
-
fs_1.default.rmSync(standaloneDir, { recursive: true, force: true });
|
|
262
|
-
ensureDir(standaloneDir);
|
|
263
|
-
const snapshotTrace = copyProjectSnapshot(cwd, runtimeProjectRoot);
|
|
264
|
-
const frameworkDistRoot = resolveFrameworkDistRoot(cwd);
|
|
265
|
-
copyDirectoryRecursive(frameworkDistRoot, frameworkRuntimeRoot);
|
|
266
|
-
writeStandaloneServerEntry(standaloneDir);
|
|
267
|
-
const rewriteContext = {
|
|
268
|
-
projectRoot: cwd,
|
|
269
|
-
runtimeRoot: runtimeProjectRoot,
|
|
270
|
-
frameworkDistRoot,
|
|
271
|
-
frameworkRuntimeRoot,
|
|
272
|
-
};
|
|
273
|
-
const rebasedServerManifest = rewriteManifestValue(serverManifest, rewriteContext);
|
|
274
|
-
writeJsonFile(path_1.default.join(vistaDir, 'server', 'server-manifest.json'), rebasedServerManifest);
|
|
275
|
-
const manifestFiles = [
|
|
276
|
-
'client-manifest.json',
|
|
277
|
-
'app-path-routes-manifest.json',
|
|
278
|
-
'routes-manifest.json',
|
|
279
|
-
'react-client-manifest.json',
|
|
280
|
-
'react-server-manifest.json',
|
|
281
|
-
'react-ssr-manifest.json',
|
|
282
|
-
];
|
|
283
|
-
const rewrittenArtifacts = ['server/server-manifest.json'];
|
|
284
|
-
for (const relativePath of manifestFiles) {
|
|
285
|
-
const absolutePath = path_1.default.join(vistaDir, relativePath);
|
|
286
|
-
if (!fs_1.default.existsSync(absolutePath)) {
|
|
287
|
-
continue;
|
|
288
|
-
}
|
|
289
|
-
const payload = JSON.parse(fs_1.default.readFileSync(absolutePath, 'utf-8'));
|
|
290
|
-
writeJsonFile(absolutePath, rewriteManifestValue(payload, rewriteContext));
|
|
291
|
-
rewrittenArtifacts.push(relativePath);
|
|
292
|
-
}
|
|
293
|
-
const runtimeManifest = {
|
|
294
|
-
schemaVersion: 1,
|
|
295
|
-
buildId,
|
|
296
|
-
generatedAt: new Date().toISOString(),
|
|
297
|
-
runtimeRootRelative: path_1.default.relative(cwd, runtimeProjectRoot).replace(/\\/g, '/'),
|
|
298
|
-
frameworkRuntimeRelative: path_1.default.relative(cwd, frameworkRuntimeRoot).replace(/\\/g, '/'),
|
|
299
|
-
standaloneServerRelative: path_1.default.relative(cwd, path_1.default.join(standaloneDir, 'server.js')).replace(/\\/g, '/'),
|
|
300
|
-
fileTraceRelative: path_1.default.relative(cwd, fileTracePath).replace(/\\/g, '/'),
|
|
301
|
-
dependencyRootsRelative: [],
|
|
302
|
-
};
|
|
303
|
-
const frameworkNodeModules = path_1.default.join(path_1.default.dirname(frameworkDistRoot), 'node_modules');
|
|
304
|
-
if (fs_1.default.existsSync(frameworkNodeModules)) {
|
|
305
|
-
runtimeManifest.dependencyRootsRelative.push(path_1.default.relative(cwd, frameworkNodeModules).replace(/\\/g, '/'));
|
|
306
|
-
}
|
|
307
|
-
const fileTrace = {
|
|
308
|
-
schemaVersion: 1,
|
|
309
|
-
buildId,
|
|
310
|
-
generatedAt: new Date().toISOString(),
|
|
311
|
-
projectRoot: cwd,
|
|
312
|
-
runtimeRootRelative: runtimeManifest.runtimeRootRelative,
|
|
313
|
-
frameworkRuntimeRelative: runtimeManifest.frameworkRuntimeRelative,
|
|
314
|
-
copiedFiles: snapshotTrace.copiedFiles,
|
|
315
|
-
copiedDirectories: snapshotTrace.copiedDirectories,
|
|
316
|
-
rewrittenArtifacts,
|
|
317
|
-
};
|
|
318
|
-
writeJsonFile(runtimeManifestPath, runtimeManifest);
|
|
319
|
-
writeJsonFile(fileTracePath, fileTrace);
|
|
320
|
-
(0, manifest_1.writeVistaTrace)(vistaDir, fileTrace);
|
|
321
|
-
(0, manifest_1.generateRequiredServerFilesManifest)(cwd, vistaDir, [
|
|
322
|
-
`${path_1.default.basename(vistaDir)}/server/runtime-manifest.json`,
|
|
323
|
-
`${path_1.default.basename(vistaDir)}/server/file-trace.json`,
|
|
324
|
-
`${path_1.default.basename(vistaDir)}/standalone/server.js`,
|
|
325
|
-
], runtimeProjectRoot);
|
|
326
|
-
(0, manifest_1.writeArtifactManifest)(vistaDir, buildId, {
|
|
327
|
-
serverManifest: 'server/server-manifest.json',
|
|
328
|
-
runtimeManifest: 'server/runtime-manifest.json',
|
|
329
|
-
fileTrace: 'server/file-trace.json',
|
|
330
|
-
standaloneServer: 'standalone/server.js',
|
|
331
|
-
types: 'types/routes.d.ts',
|
|
332
|
-
trace: 'trace',
|
|
333
|
-
});
|
|
334
|
-
if (debug) {
|
|
335
|
-
console.log(`[vista:build] Standalone output ready (${snapshotTrace.copiedFiles.length} files, ${snapshotTrace.copiedDirectories.length} directories)`);
|
|
336
|
-
}
|
|
337
|
-
}
|
|
257
|
+
`;
|
|
258
|
+
fs_1.default.writeFileSync(path_1.default.join(standaloneDir, 'server.js'), serverEntry, 'utf-8');
|
|
259
|
+
}
|
|
260
|
+
function generateStandaloneOutput(options) {
|
|
261
|
+
const { cwd, vistaDir, buildId, serverManifest, debug = false } = options;
|
|
262
|
+
const standaloneDir = path_1.default.join(vistaDir, 'standalone');
|
|
263
|
+
const runtimeProjectRoot = path_1.default.join(standaloneDir, 'project');
|
|
264
|
+
const frameworkRuntimeRoot = path_1.default.join(standaloneDir, 'runtime', 'vista');
|
|
265
|
+
const runtimeManifestPath = path_1.default.join(vistaDir, 'server', 'runtime-manifest.json');
|
|
266
|
+
const fileTracePath = path_1.default.join(vistaDir, 'server', 'file-trace.json');
|
|
267
|
+
fs_1.default.rmSync(standaloneDir, { recursive: true, force: true });
|
|
268
|
+
ensureDir(standaloneDir);
|
|
269
|
+
const snapshotTrace = copyProjectSnapshot(cwd, runtimeProjectRoot);
|
|
270
|
+
const frameworkDistRoot = resolveFrameworkDistRoot(cwd);
|
|
271
|
+
copyDirectoryRecursive(frameworkDistRoot, frameworkRuntimeRoot);
|
|
272
|
+
writeStandaloneServerEntry(standaloneDir);
|
|
273
|
+
const rewriteContext = {
|
|
274
|
+
projectRoot: cwd,
|
|
275
|
+
runtimeRoot: runtimeProjectRoot,
|
|
276
|
+
frameworkDistRoot,
|
|
277
|
+
frameworkRuntimeRoot,
|
|
278
|
+
};
|
|
279
|
+
const rebasedServerManifest = rewriteManifestValue(serverManifest, rewriteContext);
|
|
280
|
+
writeJsonFile(path_1.default.join(vistaDir, 'server', 'server-manifest.json'), rebasedServerManifest);
|
|
281
|
+
const manifestFiles = [
|
|
282
|
+
'client-manifest.json',
|
|
283
|
+
'app-path-routes-manifest.json',
|
|
284
|
+
'routes-manifest.json',
|
|
285
|
+
'react-client-manifest.json',
|
|
286
|
+
'react-server-manifest.json',
|
|
287
|
+
'react-ssr-manifest.json',
|
|
288
|
+
];
|
|
289
|
+
const rewrittenArtifacts = ['server/server-manifest.json'];
|
|
290
|
+
for (const relativePath of manifestFiles) {
|
|
291
|
+
const absolutePath = path_1.default.join(vistaDir, relativePath);
|
|
292
|
+
if (!fs_1.default.existsSync(absolutePath)) {
|
|
293
|
+
continue;
|
|
294
|
+
}
|
|
295
|
+
const payload = JSON.parse(fs_1.default.readFileSync(absolutePath, 'utf-8'));
|
|
296
|
+
writeJsonFile(absolutePath, rewriteManifestValue(payload, rewriteContext));
|
|
297
|
+
rewrittenArtifacts.push(relativePath);
|
|
298
|
+
}
|
|
299
|
+
const runtimeManifest = {
|
|
300
|
+
schemaVersion: 1,
|
|
301
|
+
buildId,
|
|
302
|
+
generatedAt: new Date().toISOString(),
|
|
303
|
+
runtimeRootRelative: path_1.default.relative(cwd, runtimeProjectRoot).replace(/\\/g, '/'),
|
|
304
|
+
frameworkRuntimeRelative: path_1.default.relative(cwd, frameworkRuntimeRoot).replace(/\\/g, '/'),
|
|
305
|
+
standaloneServerRelative: path_1.default.relative(cwd, path_1.default.join(standaloneDir, 'server.js')).replace(/\\/g, '/'),
|
|
306
|
+
fileTraceRelative: path_1.default.relative(cwd, fileTracePath).replace(/\\/g, '/'),
|
|
307
|
+
dependencyRootsRelative: [],
|
|
308
|
+
};
|
|
309
|
+
const frameworkNodeModules = path_1.default.join(path_1.default.dirname(frameworkDistRoot), 'node_modules');
|
|
310
|
+
if (fs_1.default.existsSync(frameworkNodeModules)) {
|
|
311
|
+
runtimeManifest.dependencyRootsRelative.push(path_1.default.relative(cwd, frameworkNodeModules).replace(/\\/g, '/'));
|
|
312
|
+
}
|
|
313
|
+
const fileTrace = {
|
|
314
|
+
schemaVersion: 1,
|
|
315
|
+
buildId,
|
|
316
|
+
generatedAt: new Date().toISOString(),
|
|
317
|
+
projectRoot: cwd,
|
|
318
|
+
runtimeRootRelative: runtimeManifest.runtimeRootRelative,
|
|
319
|
+
frameworkRuntimeRelative: runtimeManifest.frameworkRuntimeRelative,
|
|
320
|
+
copiedFiles: snapshotTrace.copiedFiles,
|
|
321
|
+
copiedDirectories: snapshotTrace.copiedDirectories,
|
|
322
|
+
rewrittenArtifacts,
|
|
323
|
+
};
|
|
324
|
+
writeJsonFile(runtimeManifestPath, runtimeManifest);
|
|
325
|
+
writeJsonFile(fileTracePath, fileTrace);
|
|
326
|
+
(0, manifest_1.writeVistaTrace)(vistaDir, fileTrace);
|
|
327
|
+
(0, manifest_1.generateRequiredServerFilesManifest)(cwd, vistaDir, [
|
|
328
|
+
`${path_1.default.basename(vistaDir)}/server/runtime-manifest.json`,
|
|
329
|
+
`${path_1.default.basename(vistaDir)}/server/file-trace.json`,
|
|
330
|
+
`${path_1.default.basename(vistaDir)}/standalone/server.js`,
|
|
331
|
+
], runtimeProjectRoot);
|
|
332
|
+
(0, manifest_1.writeArtifactManifest)(vistaDir, buildId, {
|
|
333
|
+
serverManifest: 'server/server-manifest.json',
|
|
334
|
+
runtimeManifest: 'server/runtime-manifest.json',
|
|
335
|
+
fileTrace: 'server/file-trace.json',
|
|
336
|
+
standaloneServer: 'standalone/server.js',
|
|
337
|
+
types: 'types/routes.d.ts',
|
|
338
|
+
trace: 'trace',
|
|
339
|
+
});
|
|
340
|
+
if (debug) {
|
|
341
|
+
console.log(`[vista:build] Standalone output ready (${snapshotTrace.copiedFiles.length} files, ${snapshotTrace.copiedDirectories.length} directories)`);
|
|
342
|
+
}
|
|
343
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './dynamic';
|
|
2
|
-
export { default } from './dynamic';
|
|
1
|
+
export * from './dynamic';
|
|
2
|
+
export { default } from './dynamic';
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
|
-
};
|
|
19
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.default = void 0;
|
|
21
|
-
__exportStar(require("./dynamic"), exports);
|
|
22
|
-
var dynamic_1 = require("./dynamic");
|
|
23
|
-
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(dynamic_1).default; } });
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
|
+
};
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.default = void 0;
|
|
21
|
+
__exportStar(require("./dynamic"), exports);
|
|
22
|
+
var dynamic_1 = require("./dynamic");
|
|
23
|
+
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(dynamic_1).default; } });
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { default, Link, useLinkStatus, useIsActive } from './link';
|
|
2
|
-
export type { LinkProps } from './link';
|
|
1
|
+
export { default, Link, useLinkStatus, useIsActive } from './link';
|
|
2
|
+
export type { LinkProps } from './link';
|
|
@@ -1,11 +1,11 @@
|
|
|
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.useIsActive = exports.useLinkStatus = exports.Link = exports.default = void 0;
|
|
7
|
-
var link_1 = require("./link");
|
|
8
|
-
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(link_1).default; } });
|
|
9
|
-
Object.defineProperty(exports, "Link", { enumerable: true, get: function () { return link_1.Link; } });
|
|
10
|
-
Object.defineProperty(exports, "useLinkStatus", { enumerable: true, get: function () { return link_1.useLinkStatus; } });
|
|
11
|
-
Object.defineProperty(exports, "useIsActive", { enumerable: true, get: function () { return link_1.useIsActive; } });
|
|
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.useIsActive = exports.useLinkStatus = exports.Link = exports.default = void 0;
|
|
7
|
+
var link_1 = require("./link");
|
|
8
|
+
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(link_1).default; } });
|
|
9
|
+
Object.defineProperty(exports, "Link", { enumerable: true, get: function () { return link_1.Link; } });
|
|
10
|
+
Object.defineProperty(exports, "useLinkStatus", { enumerable: true, get: function () { return link_1.useLinkStatus; } });
|
|
11
|
+
Object.defineProperty(exports, "useIsActive", { enumerable: true, get: function () { return link_1.useIsActive; } });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './navigation';
|
|
1
|
+
export * from './navigation';
|