@vistagenic/vista 0.3.2 → 0.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/vista.js +79 -109
- package/dist/ai/embeddings.d.ts +11 -11
- package/dist/ai/embeddings.js +71 -71
- package/dist/ai/index.d.ts +10 -10
- package/dist/ai/index.js +26 -26
- package/dist/ai/providers/base.js +85 -85
- package/dist/ai/react/react-server.d.ts +1 -1
- package/dist/ai/react/react-server.js +17 -17
- package/dist/ai/react/use-agent.js +138 -138
- package/dist/auth/core.d.ts +140 -140
- package/dist/auth/core.js +165 -165
- package/dist/auth/index.d.ts +20 -20
- package/dist/auth/index.js +369 -369
- package/dist/auth/react-server.d.ts +1 -1
- package/dist/auth/react-server.js +10 -10
- package/dist/auth/react.d.ts +18 -18
- package/dist/auth/react.js +71 -71
- package/dist/bin/build-rsc-flashpack.js +6 -0
- package/dist/bin/build-rsc.js +555 -492
- package/dist/bin/build.js +365 -353
- package/dist/bin/generate.js +513 -510
- package/dist/bin/webpack.config.d.ts +3 -1
- package/dist/bin/webpack.config.js +7 -4
- package/dist/build/manifest.d.ts +169 -169
- package/dist/build/manifest.js +423 -423
- package/dist/build/rsc/client-manifest.d.ts +62 -62
- package/dist/build/rsc/client-manifest.js +295 -295
- package/dist/build/rsc/compiler.d.ts +3 -1
- package/dist/build/rsc/compiler.js +12 -7
- package/dist/build/rsc/native-scanner.d.ts +135 -135
- package/dist/build/rsc/native-scanner.js +203 -203
- package/dist/build/rsc/react-client-reference-manifest.d.ts +35 -28
- package/dist/build/rsc/react-client-reference-manifest.js +366 -240
- package/dist/build/standalone.js +260 -254
- package/dist/client/dynamic.react-server.d.ts +2 -2
- package/dist/client/dynamic.react-server.js +23 -23
- package/dist/client/link.js +1 -1
- package/dist/client/link.react-server.d.ts +2 -2
- package/dist/client/link.react-server.js +11 -11
- package/dist/client/navigation.js +2 -2
- package/dist/client/navigation.react-server.d.ts +1 -1
- package/dist/client/navigation.react-server.js +17 -17
- package/dist/client/router.react-server.d.ts +1 -1
- package/dist/client/router.react-server.js +17 -17
- package/dist/client/rsc-router.d.ts +1 -3
- package/dist/client/rsc-router.js +98 -45
- package/dist/client/rsc-router.react-server.d.ts +1 -1
- package/dist/client/rsc-router.react-server.js +17 -17
- package/dist/client/script.react-server.d.ts +2 -2
- package/dist/client/script.react-server.js +23 -23
- package/dist/config.d.ts +1 -1
- package/dist/config.js +1 -7
- package/dist/deploy/adapters/cloudflare.js +42 -41
- package/dist/deploy/adapters/docker.d.ts +1 -0
- package/dist/deploy/adapters/docker.js +5 -4
- package/dist/deploy/adapters/netlify.js +60 -27
- package/dist/deploy/adapters/vercel.js +80 -50
- package/dist/deploy/preflight.js +4 -3
- package/dist/deploy/runtime-pack.d.ts +11 -0
- package/dist/deploy/runtime-pack.js +300 -0
- package/dist/deploy/utils.d.ts +7 -1
- package/dist/deploy/utils.js +95 -3
- package/dist/flashpack/command.js +1 -0
- package/dist/flashpack/runtime.js +2 -1
- package/dist/image/get-img-props.js +21 -11
- package/dist/image/image-config.d.ts +2 -0
- package/dist/image/image-config.js +17 -0
- package/dist/image/index.d.ts +18 -3
- package/dist/image/index.js +1 -1
- package/dist/image/react-server.d.ts +1 -2
- package/dist/image/react-server.js +1 -1
- package/dist/index.d.ts +23 -23
- package/dist/index.js +61 -61
- package/dist/server/app-dir.d.ts +22 -0
- package/dist/server/app-dir.js +77 -0
- package/dist/server/app-router-runtime.d.ts +1 -0
- package/dist/server/app-router-runtime.js +34 -9
- package/dist/server/cookie-parse.d.ts +4 -4
- package/dist/server/cookie-parse.js +14 -14
- package/dist/server/engine.js +5 -5
- package/dist/server/hydration-chunks.d.ts +7 -0
- package/dist/server/hydration-chunks.js +49 -0
- package/dist/server/image-optimizer.js +2 -1
- package/dist/server/index.d.ts +109 -109
- package/dist/server/index.js +315 -315
- package/dist/server/middleware-runner.d.ts +125 -125
- package/dist/server/middleware-runner.js +607 -615
- package/dist/server/middleware-security.d.ts +36 -36
- package/dist/server/middleware-security.js +183 -183
- package/dist/server/module-compile-hook.js +706 -695
- package/dist/server/root-resolver.js +6 -5
- package/dist/server/rsc-engine-flashpack.d.ts +3 -1
- package/dist/server/rsc-engine-flashpack.js +12 -1
- package/dist/server/rsc-engine.d.ts +6 -1
- package/dist/server/rsc-engine.js +217 -280
- package/dist/server/rsc-upstream.js +900 -892
- package/dist/server/ssr-webpack-shim.d.ts +6 -0
- package/dist/server/ssr-webpack-shim.js +29 -0
- package/dist/server/static-generator.d.ts +2 -0
- package/dist/server/static-generator.js +33 -32
- package/dist/server/structure-validator.js +2 -1
- package/dist/server/structure-watch.js +2 -0
- package/dist/server/typed-api-runtime.js +639 -635
- package/dist/server/vista-import-map.js +134 -134
- package/dist/stack/index.d.ts +34 -34
- package/dist/stack/index.js +49 -49
- package/dist/stack/server/caller.d.ts +13 -13
- package/dist/stack/server/caller.js +42 -42
- package/dist/stack/server/executor.d.ts +40 -40
- package/dist/stack/server/executor.js +222 -222
- package/dist/stack/server/index.d.ts +11 -11
- package/dist/stack/server/index.js +24 -24
- package/dist/stack/server/procedure.d.ts +20 -20
- package/dist/stack/server/procedure.js +66 -66
- package/dist/stack/server/types.d.ts +113 -113
- package/dist/theme/react-server.d.ts +10 -10
- package/dist/theme/react-server.js +16 -16
- package/package.json +1 -1
package/dist/deploy/utils.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare function ensureDir(absolutePath: string): void;
|
|
2
|
-
export declare function copyDirectoryRecursive(sourceDir: string, targetDir: string): void;
|
|
2
|
+
export declare function copyDirectoryRecursive(sourceDir: string, targetDir: string, seen?: Set<string>): void;
|
|
3
3
|
export declare function copyFileIfPresent(sourceFile: string, targetFile: string): void;
|
|
4
4
|
export declare function writeFileIfAllowed(targetFile: string, content: string, force: boolean): {
|
|
5
5
|
written: boolean;
|
|
@@ -15,4 +15,10 @@ export declare const STATIC_HOST_ROUTE_RULES: ({
|
|
|
15
15
|
dest: string;
|
|
16
16
|
handle?: undefined;
|
|
17
17
|
})[];
|
|
18
|
+
/** Lift `.vista/static/pages/*.html` to pretty CDN paths (`docs/foo/index.html`). */
|
|
19
|
+
export declare function flattenPrerenderedPages(pagesDir: string, targetDir: string): void;
|
|
20
|
+
/** Serve Flight files at `/rsc/*.rsc` (extension avoids file/directory collisions). */
|
|
21
|
+
export declare function flattenPrerenderedFlight(pagesDir: string, targetDir: string): void;
|
|
22
|
+
/** Copy webpack assets to `/_vista/static` and flatten HTML + Flight for file-based CDNs. */
|
|
23
|
+
export declare function prepareStaticCdnOutput(targetDir: string): void;
|
|
18
24
|
export declare function copyStaticHostAssets(cwd: string, vistaDir: string, targetDir: string): void;
|
package/dist/deploy/utils.js
CHANGED
|
@@ -9,22 +9,54 @@ exports.copyDirectoryRecursive = copyDirectoryRecursive;
|
|
|
9
9
|
exports.copyFileIfPresent = copyFileIfPresent;
|
|
10
10
|
exports.writeFileIfAllowed = writeFileIfAllowed;
|
|
11
11
|
exports.readJsonSafe = readJsonSafe;
|
|
12
|
+
exports.flattenPrerenderedPages = flattenPrerenderedPages;
|
|
13
|
+
exports.flattenPrerenderedFlight = flattenPrerenderedFlight;
|
|
14
|
+
exports.prepareStaticCdnOutput = prepareStaticCdnOutput;
|
|
12
15
|
exports.copyStaticHostAssets = copyStaticHostAssets;
|
|
13
16
|
const fs_1 = __importDefault(require("fs"));
|
|
14
17
|
const path_1 = __importDefault(require("path"));
|
|
15
18
|
function ensureDir(absolutePath) {
|
|
16
19
|
fs_1.default.mkdirSync(absolutePath, { recursive: true });
|
|
17
20
|
}
|
|
18
|
-
|
|
21
|
+
const SKIP_COPY_DIRECTORY_NAMES = new Set(['.cache', '.turbo', '.vite', 'coverage']);
|
|
22
|
+
function copyDirectoryRecursive(sourceDir, targetDir, seen = new Set()) {
|
|
19
23
|
if (!fs_1.default.existsSync(sourceDir))
|
|
20
24
|
return;
|
|
25
|
+
let realSource = sourceDir;
|
|
26
|
+
try {
|
|
27
|
+
realSource = fs_1.default.realpathSync(sourceDir);
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
if (seen.has(realSource))
|
|
33
|
+
return;
|
|
34
|
+
seen.add(realSource);
|
|
21
35
|
ensureDir(targetDir);
|
|
22
36
|
const entries = fs_1.default.readdirSync(sourceDir, { withFileTypes: true });
|
|
23
37
|
for (const entry of entries) {
|
|
38
|
+
if (SKIP_COPY_DIRECTORY_NAMES.has(entry.name))
|
|
39
|
+
continue;
|
|
24
40
|
const from = path_1.default.join(sourceDir, entry.name);
|
|
25
41
|
const to = path_1.default.join(targetDir, entry.name);
|
|
42
|
+
if (entry.isSymbolicLink()) {
|
|
43
|
+
try {
|
|
44
|
+
const targetStat = fs_1.default.statSync(from);
|
|
45
|
+
if (targetStat.isDirectory()) {
|
|
46
|
+
copyDirectoryRecursive(from, to, seen);
|
|
47
|
+
}
|
|
48
|
+
else if (targetStat.isFile()) {
|
|
49
|
+
ensureDir(path_1.default.dirname(to));
|
|
50
|
+
fs_1.default.copyFileSync(from, to);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
// dangling symlink
|
|
55
|
+
}
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
26
58
|
if (entry.isDirectory()) {
|
|
27
|
-
copyDirectoryRecursive(from, to);
|
|
59
|
+
copyDirectoryRecursive(from, to, seen);
|
|
28
60
|
}
|
|
29
61
|
else if (entry.isFile()) {
|
|
30
62
|
fs_1.default.copyFileSync(from, to);
|
|
@@ -55,15 +87,75 @@ function readJsonSafe(absolutePath) {
|
|
|
55
87
|
}
|
|
56
88
|
exports.STATIC_HOST_ROUTE_RULES = [
|
|
57
89
|
{ handle: 'filesystem' },
|
|
58
|
-
{ src: '^/_vista/(.*)$', dest: '/$1' },
|
|
90
|
+
{ src: '^/_vista/static/(.*)$', dest: '/static/$1' },
|
|
59
91
|
{ src: '^/(?:rsc|_rsc)/?$', dest: '/static/pages/index.rsc' },
|
|
60
92
|
{ src: '^/(?:rsc|_rsc)/(.+)$', dest: '/static/pages/$1.rsc' },
|
|
61
93
|
{ src: '^/$', dest: '/static/pages/index.html' },
|
|
62
94
|
{ src: '^/(.+)$', dest: '/static/pages/$1.html' },
|
|
63
95
|
];
|
|
96
|
+
function walkFiles(dir, visitor, prefix = '') {
|
|
97
|
+
if (!fs_1.default.existsSync(dir))
|
|
98
|
+
return;
|
|
99
|
+
const entries = fs_1.default.readdirSync(dir, { withFileTypes: true });
|
|
100
|
+
for (const entry of entries) {
|
|
101
|
+
const relativePath = prefix ? `${prefix}/${entry.name}` : entry.name;
|
|
102
|
+
const absolutePath = path_1.default.join(dir, entry.name);
|
|
103
|
+
if (entry.isDirectory()) {
|
|
104
|
+
walkFiles(absolutePath, visitor, relativePath);
|
|
105
|
+
}
|
|
106
|
+
else if (entry.isFile()) {
|
|
107
|
+
visitor(absolutePath, relativePath);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
/** Lift `.vista/static/pages/*.html` to pretty CDN paths (`docs/foo/index.html`). */
|
|
112
|
+
function flattenPrerenderedPages(pagesDir, targetDir) {
|
|
113
|
+
walkFiles(pagesDir, (absolutePath, relativePath) => {
|
|
114
|
+
const posix = relativePath.replace(/\\/g, '/');
|
|
115
|
+
if (!posix.endsWith('.html') || posix.endsWith('.shell.html'))
|
|
116
|
+
return;
|
|
117
|
+
const destRel = posix === 'index.html' || posix.endsWith('/index.html')
|
|
118
|
+
? posix
|
|
119
|
+
: posix.replace(/\.html$/, '/index.html');
|
|
120
|
+
const dest = path_1.default.join(targetDir, destRel.split('/').join(path_1.default.sep));
|
|
121
|
+
ensureDir(path_1.default.dirname(dest));
|
|
122
|
+
fs_1.default.copyFileSync(absolutePath, dest);
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
/** Serve Flight files at `/rsc/*.rsc` (extension avoids file/directory collisions). */
|
|
126
|
+
function flattenPrerenderedFlight(pagesDir, targetDir) {
|
|
127
|
+
walkFiles(pagesDir, (absolutePath, relativePath) => {
|
|
128
|
+
const posix = relativePath.replace(/\\/g, '/');
|
|
129
|
+
if (!posix.endsWith('.rsc'))
|
|
130
|
+
return;
|
|
131
|
+
const destRel = `rsc/${posix}`;
|
|
132
|
+
const dest = path_1.default.join(targetDir, destRel.split('/').join(path_1.default.sep));
|
|
133
|
+
ensureDir(path_1.default.dirname(dest));
|
|
134
|
+
fs_1.default.copyFileSync(absolutePath, dest);
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
function writeStaticRscRedirects(targetDir) {
|
|
138
|
+
const redirectsPath = path_1.default.join(targetDir, '_redirects');
|
|
139
|
+
const lines = [
|
|
140
|
+
'/rsc /rsc/index.rsc 200',
|
|
141
|
+
'/rsc/ /rsc/index.rsc 200',
|
|
142
|
+
'/rsc/*.rsc /rsc/:splat.rsc 200',
|
|
143
|
+
'/rsc/* /rsc/:splat.rsc 200',
|
|
144
|
+
];
|
|
145
|
+
fs_1.default.writeFileSync(redirectsPath, `${lines.join('\n')}\n`, 'utf8');
|
|
146
|
+
}
|
|
147
|
+
/** Copy webpack assets to `/_vista/static` and flatten HTML + Flight for file-based CDNs. */
|
|
148
|
+
function prepareStaticCdnOutput(targetDir) {
|
|
149
|
+
const staticDir = path_1.default.join(targetDir, 'static');
|
|
150
|
+
copyDirectoryRecursive(staticDir, path_1.default.join(targetDir, '_vista', 'static'));
|
|
151
|
+
flattenPrerenderedPages(path_1.default.join(staticDir, 'pages'), targetDir);
|
|
152
|
+
flattenPrerenderedFlight(path_1.default.join(staticDir, 'pages'), targetDir);
|
|
153
|
+
writeStaticRscRedirects(targetDir);
|
|
154
|
+
}
|
|
64
155
|
function copyStaticHostAssets(cwd, vistaDir, targetDir) {
|
|
65
156
|
copyDirectoryRecursive(path_1.default.join(cwd, 'public'), targetDir);
|
|
66
157
|
copyDirectoryRecursive(path_1.default.join(vistaDir, 'static'), path_1.default.join(targetDir, 'static'));
|
|
158
|
+
copyDirectoryRecursive(path_1.default.join(vistaDir, 'static'), path_1.default.join(targetDir, '_vista', 'static'));
|
|
67
159
|
const clientCssPath = path_1.default.join(vistaDir, 'client.css');
|
|
68
160
|
copyFileIfPresent(clientCssPath, path_1.default.join(targetDir, 'client.css'));
|
|
69
161
|
copyFileIfPresent(clientCssPath, path_1.default.join(targetDir, 'styles.css'));
|
|
@@ -28,6 +28,7 @@ async function fallbackToCore(phase, port) {
|
|
|
28
28
|
process.env.VISTA_ENGINE_VARIANT = 'flashpack';
|
|
29
29
|
process.env.VISTA_FLASHPACK = 'true';
|
|
30
30
|
process.env.VISTA_FLASHPACK_PIPELINE = 'js-fallback';
|
|
31
|
+
console.warn(`[flashpack] Using explicit webpack Flight SSR fallback for ${phase} (same inline-Flight contract; not renderToString).`);
|
|
31
32
|
if (phase === 'build') {
|
|
32
33
|
await (0, build_rsc_1.buildRSC)(false);
|
|
33
34
|
return;
|
|
@@ -13,6 +13,7 @@ const path_1 = __importDefault(require("path"));
|
|
|
13
13
|
const child_process_1 = require("child_process");
|
|
14
14
|
const constants_1 = require("../constants");
|
|
15
15
|
const native_scanner_1 = require("../build/rsc/native-scanner");
|
|
16
|
+
const app_dir_1 = require("../server/app-dir");
|
|
16
17
|
function ensureDir(absolutePath) {
|
|
17
18
|
fs_1.default.mkdirSync(absolutePath, { recursive: true });
|
|
18
19
|
}
|
|
@@ -191,7 +192,7 @@ function prepareFlashpackRuntime(options) {
|
|
|
191
192
|
generatedBy: 'vista-ts-bootstrap',
|
|
192
193
|
timestamp: now,
|
|
193
194
|
});
|
|
194
|
-
const appDir =
|
|
195
|
+
const appDir = (0, app_dir_1.resolveAppDir)(cwd);
|
|
195
196
|
if ((0, native_scanner_1.isNativeAvailable)() && fs_1.default.existsSync(appDir)) {
|
|
196
197
|
const nativeScan = (0, native_scanner_1.scanAppNative)(appDir);
|
|
197
198
|
if (nativeScan) {
|
|
@@ -3,22 +3,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getImgProps = getImgProps;
|
|
4
4
|
const image_config_1 = require("./image-config");
|
|
5
5
|
// Helper: Generate srcSet
|
|
6
|
-
function generateSrcSet(src,
|
|
6
|
+
function generateSrcSet(src, _width, loader, config, unoptimized, quality) {
|
|
7
7
|
if (unoptimized)
|
|
8
8
|
return undefined;
|
|
9
9
|
const { deviceSizes, imageSizes } = config;
|
|
10
10
|
const sizes = [...deviceSizes, ...imageSizes].sort((a, b) => a - b);
|
|
11
|
-
// If width is known, only generate sizes up to that width (plus maybe 2x/3x for density)
|
|
12
|
-
// For simplicity MVP, we'll generate device sizes.
|
|
13
11
|
return sizes
|
|
14
12
|
.map((size) => {
|
|
15
|
-
const url = loader({ src, width: size });
|
|
13
|
+
const url = loader({ src, width: size, quality });
|
|
16
14
|
return `${url} ${size}w`;
|
|
17
15
|
})
|
|
18
16
|
.join(', ');
|
|
19
17
|
}
|
|
20
18
|
function getImgProps(props, config = image_config_1.imageConfigDefault, defaultLoader) {
|
|
21
|
-
const { src, alt, width, height, fill, loader = defaultLoader, quality, priority, unoptimized, style, sizes, className, loading, placeholder, blurDataURL, onLoadingComplete, ...rest } = props;
|
|
19
|
+
const { src, alt, width, height, fill, loader = defaultLoader, quality, priority, unoptimized, style, sizes, className, loading, placeholder: _placeholder, blurDataURL: _blurDataURL, onLoadingComplete: _onLoadingComplete, ...rest } = props;
|
|
22
20
|
const imgStyle = { ...style };
|
|
23
21
|
// Handle Fill Mode
|
|
24
22
|
if (fill) {
|
|
@@ -29,15 +27,27 @@ function getImgProps(props, config = image_config_1.imageConfigDefault, defaultL
|
|
|
29
27
|
imgStyle.objectFit = 'cover'; // Default to cover for bg images
|
|
30
28
|
}
|
|
31
29
|
// Handle Dimensions
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
const widthInt = width ? Number(width) : undefined;
|
|
31
|
+
const heightInt = height ? Number(height) : undefined;
|
|
34
32
|
const vercelStaticBuild = typeof window === 'undefined' &&
|
|
35
33
|
(process.env.VERCEL === '1' || typeof process.env.VERCEL_URL === 'string');
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
34
|
+
const srcPath = String(src || '')
|
|
35
|
+
.split('?')[0]
|
|
36
|
+
.toLowerCase();
|
|
37
|
+
const passthroughSrc = srcPath.startsWith('data:') ||
|
|
38
|
+
srcPath.startsWith('blob:') ||
|
|
39
|
+
srcPath.endsWith('.svg') ||
|
|
40
|
+
srcPath.endsWith('.gif') ||
|
|
41
|
+
srcPath.endsWith('.ico');
|
|
42
|
+
const staticHost = process.env.VISTA_DEPLOY_OUTPUT === 'static' ||
|
|
43
|
+
process.env.VISTA_IMAGES_UNOPTIMIZED === '1' ||
|
|
44
|
+
process.env.CF_PAGES === '1' ||
|
|
45
|
+
process.env.NETLIFY === 'true';
|
|
46
|
+
// Skip /_vista/image when the optimizer is unavailable (static CDN hosts)
|
|
47
|
+
// or the format cannot be resized (SVG/GIF/ICO).
|
|
48
|
+
const disableOptimization = !!unoptimized || !!config.unoptimized || passthroughSrc || staticHost || vercelStaticBuild;
|
|
39
49
|
// Generate SrcSet
|
|
40
|
-
const srcSet = generateSrcSet(src, widthInt, loader, config, disableOptimization);
|
|
50
|
+
const srcSet = generateSrcSet(src, widthInt, loader, config, disableOptimization, quality ? Number(quality) : undefined);
|
|
41
51
|
return {
|
|
42
52
|
...rest,
|
|
43
53
|
src,
|
|
@@ -14,6 +14,8 @@ export declare const imageConfigDefault: {
|
|
|
14
14
|
remotePatterns: any[];
|
|
15
15
|
unoptimized: boolean;
|
|
16
16
|
};
|
|
17
|
+
/** Merge defaults with build-time env (`VISTA_IMAGES_UNOPTIMIZED`, static deploy). */
|
|
18
|
+
export declare function resolveRuntimeImageConfig(overrides?: ImageConfig): ImageConfigComplete;
|
|
17
19
|
export type ImageConfigComplete = typeof imageConfigDefault;
|
|
18
20
|
export type ImageConfig = Partial<ImageConfigComplete>;
|
|
19
21
|
export declare const VALID_LOADERS: readonly ["default", "imgix", "cloudinary", "akamai", "custom"];
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.VALID_LOADERS = exports.imageConfigDefault = void 0;
|
|
4
|
+
exports.resolveRuntimeImageConfig = resolveRuntimeImageConfig;
|
|
4
5
|
const constants_1 = require("../constants");
|
|
5
6
|
exports.imageConfigDefault = {
|
|
6
7
|
deviceSizes: [640, 750, 828, 1080, 1200, 1920, 2048, 3840],
|
|
@@ -18,4 +19,20 @@ exports.imageConfigDefault = {
|
|
|
18
19
|
remotePatterns: [],
|
|
19
20
|
unoptimized: false,
|
|
20
21
|
};
|
|
22
|
+
function envDisablesImageOptimization() {
|
|
23
|
+
return (process.env.VISTA_IMAGES_UNOPTIMIZED === '1' ||
|
|
24
|
+
process.env.VISTA_DEPLOY_OUTPUT === 'static' ||
|
|
25
|
+
process.env.CF_PAGES === '1' ||
|
|
26
|
+
process.env.NETLIFY === 'true');
|
|
27
|
+
}
|
|
28
|
+
/** Merge defaults with build-time env (`VISTA_IMAGES_UNOPTIMIZED`, static deploy). */
|
|
29
|
+
function resolveRuntimeImageConfig(overrides) {
|
|
30
|
+
return {
|
|
31
|
+
...exports.imageConfigDefault,
|
|
32
|
+
...overrides,
|
|
33
|
+
unoptimized: overrides?.unoptimized === true ||
|
|
34
|
+
exports.imageConfigDefault.unoptimized ||
|
|
35
|
+
envDisablesImageOptimization(),
|
|
36
|
+
};
|
|
37
|
+
}
|
|
21
38
|
exports.VALID_LOADERS = ['default', 'imgix', 'cloudinary', 'akamai', 'custom'];
|
package/dist/image/index.d.ts
CHANGED
|
@@ -1,6 +1,21 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ImageProps } from './get-img-props';
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
export type EnhancedImageProps = ImageProps;
|
|
4
|
+
export declare const Image: React.ForwardRefExoticComponent<React.ImgHTMLAttributes<HTMLImageElement> & {
|
|
5
|
+
src: string;
|
|
6
|
+
alt: string;
|
|
7
|
+
width?: number | string;
|
|
8
|
+
height?: number | string;
|
|
9
|
+
fill?: boolean;
|
|
10
|
+
loader?: import("./image-loader").ImageLoader;
|
|
11
|
+
quality?: number | string;
|
|
12
|
+
priority?: boolean;
|
|
13
|
+
unoptimized?: boolean;
|
|
14
|
+
placeholder?: import("./get-img-props").PlaceholderValue;
|
|
15
|
+
blurDataURL?: string;
|
|
16
|
+
onLoadingComplete?: (result: {
|
|
17
|
+
naturalWidth: number;
|
|
18
|
+
naturalHeight: number;
|
|
19
|
+
}) => void;
|
|
20
|
+
} & React.RefAttributes<HTMLImageElement>>;
|
|
6
21
|
export default Image;
|
package/dist/image/index.js
CHANGED
|
@@ -61,7 +61,7 @@ exports.Image = (0, react_1.forwardRef)((props, ref) => {
|
|
|
61
61
|
}
|
|
62
62
|
}, [onError, useDirectSrc]);
|
|
63
63
|
// Get processed img props
|
|
64
|
-
const imgProps = (0, get_img_props_1.getImgProps)({ ...restProps, priority, unoptimized: useDirectSrc || restProps.unoptimized }, image_config_1.
|
|
64
|
+
const imgProps = (0, get_img_props_1.getImgProps)({ ...restProps, priority, unoptimized: useDirectSrc || restProps.unoptimized }, (0, image_config_1.resolveRuntimeImageConfig)(), image_loader_1.defaultLoader);
|
|
65
65
|
const fallbackSrc = String(restProps.src || '');
|
|
66
66
|
const effectiveSrc = useDirectSrc ? fallbackSrc : imgProps.src;
|
|
67
67
|
const effectiveSrcSet = useDirectSrc ? undefined : imgProps.srcSet;
|
|
@@ -12,7 +12,7 @@ const image_loader_1 = require("./image-loader");
|
|
|
12
12
|
* react-server condition uses a plain SSR-friendly <img> wrapper.
|
|
13
13
|
*/
|
|
14
14
|
function Image(props) {
|
|
15
|
-
const imgProps = (0, get_img_props_1.getImgProps)(props, image_config_1.
|
|
15
|
+
const imgProps = (0, get_img_props_1.getImgProps)(props, (0, image_config_1.resolveRuntimeImageConfig)(), image_loader_1.defaultLoader);
|
|
16
16
|
return ((0, jsx_runtime_1.jsx)("img", { ...imgProps, decoding: props.priority ? 'sync' : 'async', fetchPriority: props.priority ? 'high' : undefined }));
|
|
17
17
|
}
|
|
18
18
|
exports.default = Image;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
export * from './router';
|
|
2
|
-
export * from './components';
|
|
3
|
-
export * from './types';
|
|
4
|
-
export * from './dev-error';
|
|
5
|
-
export { useRouter } from './client/router';
|
|
6
|
-
export { usePathname, useSearchParams, useParams, useSelectedLayoutSegment, useSelectedLayoutSegments, } from './client/navigation';
|
|
7
|
-
export { default as dynamic } from './client/dynamic';
|
|
8
|
-
export { default as Script } from './client/script';
|
|
9
|
-
export { default as Head, generateMetadataHead } from './client/head';
|
|
10
|
-
export type { Metadata as HeadMetadata } from './client/head';
|
|
11
|
-
export * from './font/index';
|
|
12
|
-
export * from './metadata';
|
|
13
|
-
export type { Metadata } from './metadata/types';
|
|
14
|
-
export { hydrateClientComponents, initializeHydration } from './client/hydration';
|
|
15
|
-
export { Client } from './components/client';
|
|
16
|
-
export { RSCRouter, RSCRouterContext, useRSCRouter } from './client/rsc-router';
|
|
17
|
-
export type { RSCRouterProps, RSCNavigationState, NavigationOptions } from './client/rsc-router';
|
|
18
|
-
export { callServer } from './client/server-actions';
|
|
19
|
-
export type { ClientManifest, ClientComponentEntry } from './build/rsc/client-manifest';
|
|
20
|
-
export type { ServerManifest, ServerComponentEntry, RouteEntry } from './build/rsc/server-manifest';
|
|
21
|
-
export { NextResponse } from './server/index';
|
|
22
|
-
export type { VistaMiddlewareContext, VistaMiddlewareRequest, MiddlewareResult, MiddlewareConfig, MiddlewareFunction, NextFunction, } from './server/index';
|
|
23
|
-
export * from './ai';
|
|
1
|
+
export * from './router';
|
|
2
|
+
export * from './components';
|
|
3
|
+
export * from './types';
|
|
4
|
+
export * from './dev-error';
|
|
5
|
+
export { useRouter } from './client/router';
|
|
6
|
+
export { usePathname, useSearchParams, useParams, useSelectedLayoutSegment, useSelectedLayoutSegments, } from './client/navigation';
|
|
7
|
+
export { default as dynamic } from './client/dynamic';
|
|
8
|
+
export { default as Script } from './client/script';
|
|
9
|
+
export { default as Head, generateMetadataHead } from './client/head';
|
|
10
|
+
export type { Metadata as HeadMetadata } from './client/head';
|
|
11
|
+
export * from './font/index';
|
|
12
|
+
export * from './metadata';
|
|
13
|
+
export type { Metadata } from './metadata/types';
|
|
14
|
+
export { hydrateClientComponents, initializeHydration } from './client/hydration';
|
|
15
|
+
export { Client } from './components/client';
|
|
16
|
+
export { RSCRouter, RSCRouterContext, useRSCRouter } from './client/rsc-router';
|
|
17
|
+
export type { RSCRouterProps, RSCNavigationState, NavigationOptions } from './client/rsc-router';
|
|
18
|
+
export { callServer } from './client/server-actions';
|
|
19
|
+
export type { ClientManifest, ClientComponentEntry } from './build/rsc/client-manifest';
|
|
20
|
+
export type { ServerManifest, ServerComponentEntry, RouteEntry } from './build/rsc/server-manifest';
|
|
21
|
+
export { NextResponse } from './server/index';
|
|
22
|
+
export type { VistaMiddlewareContext, VistaMiddlewareRequest, MiddlewareResult, MiddlewareConfig, MiddlewareFunction, NextFunction, } from './server/index';
|
|
23
|
+
export * from './ai';
|
package/dist/index.js
CHANGED
|
@@ -1,61 +1,61 @@
|
|
|
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.NextResponse = exports.callServer = exports.useRSCRouter = exports.RSCRouterContext = exports.RSCRouter = exports.Client = exports.initializeHydration = exports.hydrateClientComponents = exports.generateMetadataHead = exports.Head = exports.Script = exports.dynamic = exports.useSelectedLayoutSegments = exports.useSelectedLayoutSegment = exports.useParams = exports.useSearchParams = exports.usePathname = exports.useRouter = void 0;
|
|
21
|
-
__exportStar(require("./router"), exports);
|
|
22
|
-
__exportStar(require("./components"), exports);
|
|
23
|
-
__exportStar(require("./types"), exports);
|
|
24
|
-
__exportStar(require("./dev-error"), exports);
|
|
25
|
-
// Client-side features
|
|
26
|
-
var router_1 = require("./client/router");
|
|
27
|
-
Object.defineProperty(exports, "useRouter", { enumerable: true, get: function () { return router_1.useRouter; } });
|
|
28
|
-
var navigation_1 = require("./client/navigation");
|
|
29
|
-
Object.defineProperty(exports, "usePathname", { enumerable: true, get: function () { return navigation_1.usePathname; } });
|
|
30
|
-
Object.defineProperty(exports, "useSearchParams", { enumerable: true, get: function () { return navigation_1.useSearchParams; } });
|
|
31
|
-
Object.defineProperty(exports, "useParams", { enumerable: true, get: function () { return navigation_1.useParams; } });
|
|
32
|
-
Object.defineProperty(exports, "useSelectedLayoutSegment", { enumerable: true, get: function () { return navigation_1.useSelectedLayoutSegment; } });
|
|
33
|
-
Object.defineProperty(exports, "useSelectedLayoutSegments", { enumerable: true, get: function () { return navigation_1.useSelectedLayoutSegments; } });
|
|
34
|
-
var dynamic_1 = require("./client/dynamic");
|
|
35
|
-
Object.defineProperty(exports, "dynamic", { enumerable: true, get: function () { return __importDefault(dynamic_1).default; } });
|
|
36
|
-
var script_1 = require("./client/script");
|
|
37
|
-
Object.defineProperty(exports, "Script", { enumerable: true, get: function () { return __importDefault(script_1).default; } });
|
|
38
|
-
var head_1 = require("./client/head");
|
|
39
|
-
Object.defineProperty(exports, "Head", { enumerable: true, get: function () { return __importDefault(head_1).default; } });
|
|
40
|
-
Object.defineProperty(exports, "generateMetadataHead", { enumerable: true, get: function () { return head_1.generateMetadataHead; } });
|
|
41
|
-
// Font exports
|
|
42
|
-
__exportStar(require("./font/index"), exports);
|
|
43
|
-
// Metadata exports (Next.js compatible)
|
|
44
|
-
__exportStar(require("./metadata"), exports);
|
|
45
|
-
// RSC (React Server Components) exports
|
|
46
|
-
var hydration_1 = require("./client/hydration");
|
|
47
|
-
Object.defineProperty(exports, "hydrateClientComponents", { enumerable: true, get: function () { return hydration_1.hydrateClientComponents; } });
|
|
48
|
-
Object.defineProperty(exports, "initializeHydration", { enumerable: true, get: function () { return hydration_1.initializeHydration; } });
|
|
49
|
-
var client_1 = require("./components/client");
|
|
50
|
-
Object.defineProperty(exports, "Client", { enumerable: true, get: function () { return client_1.Client; } });
|
|
51
|
-
var rsc_router_1 = require("./client/rsc-router");
|
|
52
|
-
Object.defineProperty(exports, "RSCRouter", { enumerable: true, get: function () { return rsc_router_1.RSCRouter; } });
|
|
53
|
-
Object.defineProperty(exports, "RSCRouterContext", { enumerable: true, get: function () { return rsc_router_1.RSCRouterContext; } });
|
|
54
|
-
Object.defineProperty(exports, "useRSCRouter", { enumerable: true, get: function () { return rsc_router_1.useRSCRouter; } });
|
|
55
|
-
var server_actions_1 = require("./client/server-actions");
|
|
56
|
-
Object.defineProperty(exports, "callServer", { enumerable: true, get: function () { return server_actions_1.callServer; } });
|
|
57
|
-
// Server & Middleware exports
|
|
58
|
-
var index_1 = require("./server/index");
|
|
59
|
-
Object.defineProperty(exports, "NextResponse", { enumerable: true, get: function () { return index_1.NextResponse; } });
|
|
60
|
-
// AI Framework
|
|
61
|
-
__exportStar(require("./ai"), exports);
|
|
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.NextResponse = exports.callServer = exports.useRSCRouter = exports.RSCRouterContext = exports.RSCRouter = exports.Client = exports.initializeHydration = exports.hydrateClientComponents = exports.generateMetadataHead = exports.Head = exports.Script = exports.dynamic = exports.useSelectedLayoutSegments = exports.useSelectedLayoutSegment = exports.useParams = exports.useSearchParams = exports.usePathname = exports.useRouter = void 0;
|
|
21
|
+
__exportStar(require("./router"), exports);
|
|
22
|
+
__exportStar(require("./components"), exports);
|
|
23
|
+
__exportStar(require("./types"), exports);
|
|
24
|
+
__exportStar(require("./dev-error"), exports);
|
|
25
|
+
// Client-side features
|
|
26
|
+
var router_1 = require("./client/router");
|
|
27
|
+
Object.defineProperty(exports, "useRouter", { enumerable: true, get: function () { return router_1.useRouter; } });
|
|
28
|
+
var navigation_1 = require("./client/navigation");
|
|
29
|
+
Object.defineProperty(exports, "usePathname", { enumerable: true, get: function () { return navigation_1.usePathname; } });
|
|
30
|
+
Object.defineProperty(exports, "useSearchParams", { enumerable: true, get: function () { return navigation_1.useSearchParams; } });
|
|
31
|
+
Object.defineProperty(exports, "useParams", { enumerable: true, get: function () { return navigation_1.useParams; } });
|
|
32
|
+
Object.defineProperty(exports, "useSelectedLayoutSegment", { enumerable: true, get: function () { return navigation_1.useSelectedLayoutSegment; } });
|
|
33
|
+
Object.defineProperty(exports, "useSelectedLayoutSegments", { enumerable: true, get: function () { return navigation_1.useSelectedLayoutSegments; } });
|
|
34
|
+
var dynamic_1 = require("./client/dynamic");
|
|
35
|
+
Object.defineProperty(exports, "dynamic", { enumerable: true, get: function () { return __importDefault(dynamic_1).default; } });
|
|
36
|
+
var script_1 = require("./client/script");
|
|
37
|
+
Object.defineProperty(exports, "Script", { enumerable: true, get: function () { return __importDefault(script_1).default; } });
|
|
38
|
+
var head_1 = require("./client/head");
|
|
39
|
+
Object.defineProperty(exports, "Head", { enumerable: true, get: function () { return __importDefault(head_1).default; } });
|
|
40
|
+
Object.defineProperty(exports, "generateMetadataHead", { enumerable: true, get: function () { return head_1.generateMetadataHead; } });
|
|
41
|
+
// Font exports
|
|
42
|
+
__exportStar(require("./font/index"), exports);
|
|
43
|
+
// Metadata exports (Next.js compatible)
|
|
44
|
+
__exportStar(require("./metadata"), exports);
|
|
45
|
+
// RSC (React Server Components) exports
|
|
46
|
+
var hydration_1 = require("./client/hydration");
|
|
47
|
+
Object.defineProperty(exports, "hydrateClientComponents", { enumerable: true, get: function () { return hydration_1.hydrateClientComponents; } });
|
|
48
|
+
Object.defineProperty(exports, "initializeHydration", { enumerable: true, get: function () { return hydration_1.initializeHydration; } });
|
|
49
|
+
var client_1 = require("./components/client");
|
|
50
|
+
Object.defineProperty(exports, "Client", { enumerable: true, get: function () { return client_1.Client; } });
|
|
51
|
+
var rsc_router_1 = require("./client/rsc-router");
|
|
52
|
+
Object.defineProperty(exports, "RSCRouter", { enumerable: true, get: function () { return rsc_router_1.RSCRouter; } });
|
|
53
|
+
Object.defineProperty(exports, "RSCRouterContext", { enumerable: true, get: function () { return rsc_router_1.RSCRouterContext; } });
|
|
54
|
+
Object.defineProperty(exports, "useRSCRouter", { enumerable: true, get: function () { return rsc_router_1.useRSCRouter; } });
|
|
55
|
+
var server_actions_1 = require("./client/server-actions");
|
|
56
|
+
Object.defineProperty(exports, "callServer", { enumerable: true, get: function () { return server_actions_1.callServer; } });
|
|
57
|
+
// Server & Middleware exports
|
|
58
|
+
var index_1 = require("./server/index");
|
|
59
|
+
Object.defineProperty(exports, "NextResponse", { enumerable: true, get: function () { return index_1.NextResponse; } });
|
|
60
|
+
// AI Framework
|
|
61
|
+
__exportStar(require("./ai"), exports);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolve the App Router source directory.
|
|
3
|
+
*
|
|
4
|
+
* Supports both layouts (Next-compatible):
|
|
5
|
+
* - `<cwd>/app`
|
|
6
|
+
* - `<cwd>/src/app`
|
|
7
|
+
*
|
|
8
|
+
* Preference when both exist: root `app/` (matches existing middleware discovery).
|
|
9
|
+
* When neither exists, returns `<cwd>/app` so callers can emit a clear missing-app error.
|
|
10
|
+
*/
|
|
11
|
+
export declare function resolveAppDir(cwd: string): string;
|
|
12
|
+
/** Like resolveAppDir, but returns null when no app directory exists yet. */
|
|
13
|
+
export declare function resolveAppDirOrNull(cwd: string): string | null;
|
|
14
|
+
/**
|
|
15
|
+
* True when the resolved app dir lives under `src/` (i.e. `src/app`).
|
|
16
|
+
*/
|
|
17
|
+
export declare function isSrcAppLayout(cwd: string, appDir?: string): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Shared UI directory paired with the app layout.
|
|
20
|
+
* Prefers `src/components` for `src/app` projects, otherwise root `components/`.
|
|
21
|
+
*/
|
|
22
|
+
export declare function resolveComponentsDir(cwd: string): string;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.resolveAppDir = resolveAppDir;
|
|
7
|
+
exports.resolveAppDirOrNull = resolveAppDirOrNull;
|
|
8
|
+
exports.isSrcAppLayout = isSrcAppLayout;
|
|
9
|
+
exports.resolveComponentsDir = resolveComponentsDir;
|
|
10
|
+
const fs_1 = __importDefault(require("fs"));
|
|
11
|
+
const path_1 = __importDefault(require("path"));
|
|
12
|
+
/**
|
|
13
|
+
* Resolve the App Router source directory.
|
|
14
|
+
*
|
|
15
|
+
* Supports both layouts (Next-compatible):
|
|
16
|
+
* - `<cwd>/app`
|
|
17
|
+
* - `<cwd>/src/app`
|
|
18
|
+
*
|
|
19
|
+
* Preference when both exist: root `app/` (matches existing middleware discovery).
|
|
20
|
+
* When neither exists, returns `<cwd>/app` so callers can emit a clear missing-app error.
|
|
21
|
+
*/
|
|
22
|
+
function resolveAppDir(cwd) {
|
|
23
|
+
const rootApp = path_1.default.join(cwd, 'app');
|
|
24
|
+
const srcApp = path_1.default.join(cwd, 'src', 'app');
|
|
25
|
+
if (isDirectory(rootApp))
|
|
26
|
+
return rootApp;
|
|
27
|
+
if (isDirectory(srcApp))
|
|
28
|
+
return srcApp;
|
|
29
|
+
return rootApp;
|
|
30
|
+
}
|
|
31
|
+
/** Like resolveAppDir, but returns null when no app directory exists yet. */
|
|
32
|
+
function resolveAppDirOrNull(cwd) {
|
|
33
|
+
const rootApp = path_1.default.join(cwd, 'app');
|
|
34
|
+
const srcApp = path_1.default.join(cwd, 'src', 'app');
|
|
35
|
+
if (isDirectory(rootApp))
|
|
36
|
+
return rootApp;
|
|
37
|
+
if (isDirectory(srcApp))
|
|
38
|
+
return srcApp;
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* True when the resolved app dir lives under `src/` (i.e. `src/app`).
|
|
43
|
+
*/
|
|
44
|
+
function isSrcAppLayout(cwd, appDir = resolveAppDir(cwd)) {
|
|
45
|
+
const relative = path_1.default.relative(cwd, appDir).replace(/\\/g, '/');
|
|
46
|
+
return relative === 'src/app' || relative.startsWith('src/app/');
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Shared UI directory paired with the app layout.
|
|
50
|
+
* Prefers `src/components` for `src/app` projects, otherwise root `components/`.
|
|
51
|
+
*/
|
|
52
|
+
function resolveComponentsDir(cwd) {
|
|
53
|
+
const appDir = resolveAppDirOrNull(cwd);
|
|
54
|
+
const preferSrc = appDir ? isSrcAppLayout(cwd, appDir) : false;
|
|
55
|
+
const srcComponents = path_1.default.join(cwd, 'src', 'components');
|
|
56
|
+
const rootComponents = path_1.default.join(cwd, 'components');
|
|
57
|
+
if (preferSrc) {
|
|
58
|
+
if (isDirectory(srcComponents))
|
|
59
|
+
return srcComponents;
|
|
60
|
+
if (isDirectory(rootComponents))
|
|
61
|
+
return rootComponents;
|
|
62
|
+
return srcComponents;
|
|
63
|
+
}
|
|
64
|
+
if (isDirectory(rootComponents))
|
|
65
|
+
return rootComponents;
|
|
66
|
+
if (isDirectory(srcComponents))
|
|
67
|
+
return srcComponents;
|
|
68
|
+
return rootComponents;
|
|
69
|
+
}
|
|
70
|
+
function isDirectory(absolutePath) {
|
|
71
|
+
try {
|
|
72
|
+
return fs_1.default.existsSync(absolutePath) && fs_1.default.statSync(absolutePath).isDirectory();
|
|
73
|
+
}
|
|
74
|
+
catch {
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -21,6 +21,7 @@ export declare function resolveParallelSlotMatches(input: {
|
|
|
21
21
|
layoutPath: string;
|
|
22
22
|
pathname: string;
|
|
23
23
|
}): ParallelSlotMatch[];
|
|
24
|
+
export declare function isPathInside(parent: string, child: string): boolean;
|
|
24
25
|
export declare function resolveDirectoryChain(rootDir: string, entryFilePath: string): string[];
|
|
25
26
|
export declare function resolveNearestSegmentNotFoundPath(appDir: string, startDir: string): string | null;
|
|
26
27
|
export {};
|