vike 0.4.165 → 0.4.166-commit-6a8acaa
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/dist/cjs/node/plugin/index.js +1 -1
- package/dist/cjs/node/plugin/plugins/baseUrls.js +1 -1
- package/dist/cjs/node/plugin/plugins/buildConfig/fixServerAssets.js +6 -2
- package/dist/cjs/node/plugin/plugins/buildConfig.js +78 -63
- package/dist/cjs/node/plugin/plugins/commonConfig/assertResolveAlias.js +14 -1
- package/dist/cjs/node/plugin/plugins/config/index.js +1 -1
- package/dist/cjs/node/plugin/plugins/devConfig/determineOptimizeDeps.js +18 -23
- package/dist/cjs/node/plugin/plugins/envVars.js +3 -2
- package/dist/cjs/node/plugin/plugins/fileEnv.js +6 -3
- package/dist/cjs/node/plugin/plugins/importUserCode/index.js +6 -2
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +0 -1
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js +53 -24
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/filesystemRouting.js +6 -6
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.js +10 -25
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveImportPath.js +32 -35
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js +18 -26
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +26 -21
- package/dist/cjs/node/plugin/shared/getFilePath.js +142 -0
- package/dist/cjs/node/plugin/shared/loggerNotProd/errorWithCodeSnippet.js +3 -8
- package/dist/cjs/node/plugin/shared/loggerNotProd.js +2 -1
- package/dist/cjs/node/plugin/utils.js +1 -1
- package/dist/cjs/node/prerender/runPrerender.js +6 -7
- package/dist/cjs/node/prerender/utils.js +2 -1
- package/dist/cjs/node/runtime/html/injectAssets/getHtmlTags.js +1 -0
- package/dist/cjs/node/runtime/html/injectAssets/injectHtmlTags.js +1 -1
- package/dist/cjs/node/runtime/renderPage/executeOnBeforeRenderAndDataHooks.js +3 -3
- package/dist/cjs/node/runtime/renderPage/executeOnRenderHtmlHook.js +2 -1
- package/dist/cjs/node/runtime/renderPage/getPageAssets/getManifestEntry.js +31 -33
- package/dist/cjs/node/runtime/renderPage/getPageAssets/retrieveAssetsProd.js +9 -8
- package/dist/cjs/node/runtime/renderPage/getPageAssets.js +6 -12
- package/dist/cjs/node/runtime/renderPage/logErrorHint.js +5 -0
- package/dist/cjs/node/runtime/renderPage.js +34 -21
- package/dist/cjs/node/runtime/utils.js +0 -1
- package/dist/cjs/shared/page-configs/FilePath.js +2 -0
- package/dist/cjs/shared/route/abort.js +2 -1
- package/dist/cjs/shared/route/executeGuardHook.js +2 -1
- package/dist/cjs/shared/route/executeOnBeforeRouteHook.js +2 -1
- package/dist/cjs/shared/route/utils.js +0 -1
- package/dist/cjs/utils/assert.js +2 -0
- package/dist/cjs/utils/assertPathIsFilesystemAbsolute.js +1 -0
- package/dist/cjs/utils/assertSingleInstance.js +6 -5
- package/dist/cjs/utils/assertVersion.js +4 -1
- package/dist/cjs/utils/getGlobalObject.js +21 -6
- package/dist/cjs/utils/isNpmPackage.js +11 -5
- package/dist/cjs/utils/parseUrl.js +8 -1
- package/dist/cjs/utils/projectInfo.js +1 -4
- package/dist/esm/client/client-routing-runtime/history.d.ts +1 -1
- package/dist/esm/client/client-routing-runtime/history.js +5 -5
- package/dist/esm/client/client-routing-runtime/onBrowserHistoryNavigation.js +1 -1
- package/dist/esm/node/plugin/index.js +1 -1
- package/dist/esm/node/plugin/plugins/baseUrls.js +1 -1
- package/dist/esm/node/plugin/plugins/buildConfig/fixServerAssets.js +6 -2
- package/dist/esm/node/plugin/plugins/buildConfig.d.ts +1 -1
- package/dist/esm/node/plugin/plugins/buildConfig.js +79 -64
- package/dist/esm/node/plugin/plugins/commonConfig/assertResolveAlias.js +14 -1
- package/dist/esm/node/plugin/plugins/config/index.js +1 -1
- package/dist/esm/node/plugin/plugins/devConfig/determineOptimizeDeps.js +19 -24
- package/dist/esm/node/plugin/plugins/envVars.js +4 -3
- package/dist/esm/node/plugin/plugins/fileEnv.js +7 -4
- package/dist/esm/node/plugin/plugins/importUserCode/index.js +7 -3
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.d.ts +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +0 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.d.ts +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js +54 -25
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/filesystemRouting.d.ts +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/filesystemRouting.js +6 -6
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.d.ts +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.js +11 -26
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveImportPath.d.ts +2 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveImportPath.js +32 -35
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.d.ts +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js +18 -26
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.d.ts +3 -2
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +26 -21
- package/dist/esm/node/plugin/shared/getFilePath.d.ts +21 -0
- package/dist/esm/node/plugin/shared/getFilePath.js +136 -0
- package/dist/esm/node/plugin/shared/loggerNotProd/errorWithCodeSnippet.js +4 -9
- package/dist/esm/node/plugin/shared/loggerNotProd.js +2 -1
- package/dist/esm/node/plugin/utils.d.ts +1 -1
- package/dist/esm/node/plugin/utils.js +1 -1
- package/dist/esm/node/prerender/runPrerender.js +2 -3
- package/dist/esm/node/prerender/utils.d.ts +2 -1
- package/dist/esm/node/prerender/utils.js +2 -1
- package/dist/esm/node/runtime/html/injectAssets/getHtmlTags.js +1 -0
- package/dist/esm/node/runtime/html/injectAssets/injectHtmlTags.js +1 -1
- package/dist/esm/node/runtime/renderPage/executeOnBeforeRenderAndDataHooks.js +1 -1
- package/dist/esm/node/runtime/renderPage/executeOnRenderHtmlHook.js +2 -1
- package/dist/esm/node/runtime/renderPage/getPageAssets/getManifestEntry.js +32 -34
- package/dist/esm/node/runtime/renderPage/getPageAssets/retrieveAssetsProd.js +9 -8
- package/dist/esm/node/runtime/renderPage/getPageAssets.js +7 -13
- package/dist/esm/node/runtime/renderPage/logErrorHint.js +2 -0
- package/dist/esm/node/runtime/renderPage.js +34 -21
- package/dist/esm/node/runtime/utils.d.ts +0 -1
- package/dist/esm/node/runtime/utils.js +0 -1
- package/dist/esm/shared/page-configs/Config/PageContextConfig.d.ts +1 -1
- package/dist/esm/shared/page-configs/FilePath.d.ts +64 -0
- package/dist/esm/shared/page-configs/FilePath.js +1 -0
- package/dist/esm/shared/page-configs/PageConfig.d.ts +1 -42
- package/dist/esm/shared/route/abort.js +2 -1
- package/dist/esm/shared/route/executeGuardHook.js +2 -1
- package/dist/esm/shared/route/executeOnBeforeRouteHook.js +2 -1
- package/dist/esm/shared/route/utils.d.ts +0 -1
- package/dist/esm/shared/route/utils.js +0 -1
- package/dist/esm/utils/assert.js +2 -0
- package/dist/esm/utils/assertPathIsFilesystemAbsolute.js +1 -0
- package/dist/esm/utils/assertSingleInstance.d.ts +2 -2
- package/dist/esm/utils/assertSingleInstance.js +5 -4
- package/dist/esm/utils/assertVersion.js +4 -1
- package/dist/esm/utils/debug.d.ts +1 -1
- package/dist/esm/utils/getGlobalObject.d.ts +6 -1
- package/dist/esm/utils/getGlobalObject.js +22 -6
- package/dist/esm/utils/isNpmPackage.d.ts +5 -7
- package/dist/esm/utils/isNpmPackage.js +15 -4
- package/dist/esm/utils/parseUrl.js +8 -1
- package/dist/esm/utils/projectInfo.d.ts +2 -2
- package/dist/esm/utils/projectInfo.js +1 -4
- package/package.json +26 -14
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveFilePath.js +0 -33
- package/dist/cjs/node/runtime/renderPage/getPageAssets/assertClientEntryId.js +0 -19
- package/dist/cjs/utils/getFilePathAbsolute.js +0 -70
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveFilePath.d.ts +0 -5
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveFilePath.js +0 -27
- package/dist/esm/node/runtime/renderPage/getPageAssets/assertClientEntryId.d.ts +0 -2
- package/dist/esm/node/runtime/renderPage/getPageAssets/assertClientEntryId.js +0 -16
- package/dist/esm/utils/getFilePathAbsolute.d.ts +0 -5
- package/dist/esm/utils/getFilePathAbsolute.js +0 -64
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
export { getFilePathResolved };
|
|
2
|
+
export { getFilePathUnresolved };
|
|
3
|
+
export { getModuleFilePath };
|
|
4
|
+
export { getFilePathToShowToUserFromUnkown };
|
|
5
|
+
export { cleanFilePathUnkown };
|
|
6
|
+
import path from 'path';
|
|
7
|
+
import { assert, assertPathIsFilesystemAbsolute, assertPosixPath, toPosixPath } from '../utils.js';
|
|
8
|
+
function getFilePathUnresolved({ importPathAbsolute }) {
|
|
9
|
+
return getFilePath({ importPathAbsolute, filePathAbsoluteUserRootDir: null });
|
|
10
|
+
}
|
|
11
|
+
function getFilePathResolved(args) {
|
|
12
|
+
const { userRootDir } = args;
|
|
13
|
+
const importPathAbsolute = args.importPathAbsolute ?? null;
|
|
14
|
+
let filePathAbsoluteFilesystem;
|
|
15
|
+
let filePathAbsoluteUserRootDir;
|
|
16
|
+
if ('filePathAbsoluteFilesystem' in args) {
|
|
17
|
+
filePathAbsoluteFilesystem = args.filePathAbsoluteFilesystem;
|
|
18
|
+
filePathAbsoluteUserRootDir = getFilePathAbsoluteUserRootDir({ filePathAbsoluteFilesystem, userRootDir });
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
filePathAbsoluteUserRootDir = args.filePathAbsoluteUserRootDir;
|
|
22
|
+
filePathAbsoluteFilesystem = getFilePathAbsoluteUserFilesystem({ filePathAbsoluteUserRootDir, userRootDir });
|
|
23
|
+
}
|
|
24
|
+
let filePath;
|
|
25
|
+
const common = {
|
|
26
|
+
filePathAbsoluteUserRootDir,
|
|
27
|
+
importPathAbsolute,
|
|
28
|
+
userRootDir
|
|
29
|
+
};
|
|
30
|
+
if (importPathAbsolute) {
|
|
31
|
+
filePath = getFilePath({
|
|
32
|
+
...common,
|
|
33
|
+
importPathAbsolute
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
assert(filePathAbsoluteUserRootDir);
|
|
38
|
+
filePath = getFilePath({
|
|
39
|
+
...common,
|
|
40
|
+
filePathAbsoluteUserRootDir
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
assert(filePathAbsoluteFilesystem);
|
|
44
|
+
assertPathIsFilesystemAbsolute(filePathAbsoluteFilesystem);
|
|
45
|
+
const filePathToShowToUserResolved = filePathAbsoluteUserRootDir || filePathAbsoluteFilesystem;
|
|
46
|
+
assert(filePathToShowToUserResolved);
|
|
47
|
+
const filePathResolved = {
|
|
48
|
+
...filePath,
|
|
49
|
+
filePathAbsoluteFilesystem,
|
|
50
|
+
filePathToShowToUserResolved
|
|
51
|
+
};
|
|
52
|
+
return filePathResolved;
|
|
53
|
+
}
|
|
54
|
+
function getFilePath(args) {
|
|
55
|
+
let filePathAbsoluteVite;
|
|
56
|
+
if (args.filePathAbsoluteUserRootDir !== null) {
|
|
57
|
+
filePathAbsoluteVite = args.filePathAbsoluteUserRootDir;
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
assert(args.importPathAbsolute !== null); // Help TS
|
|
61
|
+
filePathAbsoluteVite = args.importPathAbsolute;
|
|
62
|
+
}
|
|
63
|
+
const filePathToShowToUser = filePathAbsoluteVite;
|
|
64
|
+
assert(filePathToShowToUser);
|
|
65
|
+
return {
|
|
66
|
+
...args,
|
|
67
|
+
filePathAbsoluteFilesystem: null,
|
|
68
|
+
filePathAbsoluteVite,
|
|
69
|
+
filePathToShowToUser
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
function getFilePathAbsoluteUserFilesystem({ filePathAbsoluteUserRootDir, userRootDir }) {
|
|
73
|
+
assertPosixPath(filePathAbsoluteUserRootDir);
|
|
74
|
+
assertPosixPath(userRootDir);
|
|
75
|
+
assertPathIsFilesystemAbsolute(userRootDir);
|
|
76
|
+
const filePathAbsoluteFilesystem = path.posix.join(userRootDir, filePathAbsoluteUserRootDir);
|
|
77
|
+
assertPathIsFilesystemAbsolute(userRootDir);
|
|
78
|
+
return filePathAbsoluteFilesystem;
|
|
79
|
+
}
|
|
80
|
+
function getFilePathAbsoluteUserRootDir({ filePathAbsoluteFilesystem, userRootDir }) {
|
|
81
|
+
assertPosixPath(filePathAbsoluteFilesystem);
|
|
82
|
+
assertPosixPath(userRootDir);
|
|
83
|
+
assertPathIsFilesystemAbsolute(filePathAbsoluteFilesystem);
|
|
84
|
+
assertPathIsFilesystemAbsolute(userRootDir);
|
|
85
|
+
const filePathRelative = path.posix.relative(userRootDir, filePathAbsoluteFilesystem);
|
|
86
|
+
if (!filePathAbsoluteFilesystem.startsWith(userRootDir)) {
|
|
87
|
+
assert(filePathRelative.startsWith('../'));
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
assert(!filePathRelative.startsWith('.') && !filePathRelative.startsWith('/'));
|
|
91
|
+
const filePathAbsoluteUserRootDir = `/${filePathRelative}`;
|
|
92
|
+
assert(filePathAbsoluteUserRootDir === getFilePathAbsoluteUserRootDir2(filePathAbsoluteFilesystem, userRootDir));
|
|
93
|
+
return filePathAbsoluteUserRootDir;
|
|
94
|
+
}
|
|
95
|
+
function getModuleFilePath(moduleId, config) {
|
|
96
|
+
const userRootDir = config.root;
|
|
97
|
+
assertPosixPath(moduleId);
|
|
98
|
+
assertPosixPath(userRootDir);
|
|
99
|
+
const filePathAbsoluteFilesystem = cleanModuleId(moduleId);
|
|
100
|
+
assertPathIsFilesystemAbsolute(filePathAbsoluteFilesystem);
|
|
101
|
+
const filePath = getFilePathResolved({ filePathAbsoluteFilesystem, userRootDir });
|
|
102
|
+
return filePath.filePathToShowToUserResolved;
|
|
103
|
+
}
|
|
104
|
+
function getFilePathToShowToUserFromUnkown(
|
|
105
|
+
// We don't have any guarentee about filePath, e.g. about whether is filePathAbsoluteFilesystem or filePathAbsoluteUserRootDir
|
|
106
|
+
filePathUnkown, userRootDir) {
|
|
107
|
+
assertPosixPath(userRootDir);
|
|
108
|
+
assertPathIsFilesystemAbsolute(userRootDir);
|
|
109
|
+
filePathUnkown = cleanFilePathUnkown(filePathUnkown);
|
|
110
|
+
if (!filePathUnkown.startsWith(userRootDir)) {
|
|
111
|
+
return filePathUnkown;
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
return getFilePathAbsoluteUserRootDir2(filePathUnkown, userRootDir);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
function getFilePathAbsoluteUserRootDir2(filePathAbsoluteFilesystem, userRootDir) {
|
|
118
|
+
assert(filePathAbsoluteFilesystem.startsWith(userRootDir));
|
|
119
|
+
let filePathAbsoluteUserRootDir = filePathAbsoluteFilesystem.slice(userRootDir.length);
|
|
120
|
+
if (!filePathAbsoluteUserRootDir.startsWith('/'))
|
|
121
|
+
filePathAbsoluteUserRootDir = '/' + filePathAbsoluteUserRootDir;
|
|
122
|
+
return filePathAbsoluteUserRootDir;
|
|
123
|
+
}
|
|
124
|
+
function cleanFilePathUnkown(filePathUnknown) {
|
|
125
|
+
filePathUnknown = toPosixPath(filePathUnknown);
|
|
126
|
+
filePathUnknown = cleanModuleId(filePathUnknown);
|
|
127
|
+
return filePathUnknown;
|
|
128
|
+
}
|
|
129
|
+
function cleanModuleId(moduleId) {
|
|
130
|
+
// remove query
|
|
131
|
+
const parts = moduleId.split('?');
|
|
132
|
+
if (parts.length > 1)
|
|
133
|
+
parts.pop();
|
|
134
|
+
assert(parts.length >= 1);
|
|
135
|
+
return parts.join('?');
|
|
136
|
+
}
|
|
@@ -7,7 +7,8 @@ export { isEquivalentErrorWithCodeSnippet };
|
|
|
7
7
|
export { getPrettyErrMessage };
|
|
8
8
|
// Copied & adapted from https://github.com/vitejs/vite/blob/9c114c5c72a6af87e3330d5573362554b4511265/packages/vite/src/node/server/middlewares/error.ts
|
|
9
9
|
import pc from '@brillout/picocolors';
|
|
10
|
-
import { assert, escapeRegex,
|
|
10
|
+
import { assert, escapeRegex, isObject, removeEmptyLines, stripAnsi } from '../../utils.js';
|
|
11
|
+
import { cleanFilePathUnkown, getFilePathToShowToUserFromUnkown } from '../getFilePath.js';
|
|
11
12
|
function isErrorWithCodeSnippet(err) {
|
|
12
13
|
if (!isObject(err)) {
|
|
13
14
|
return false;
|
|
@@ -46,7 +47,7 @@ function getPrettyErrorWithCodeSnippet(err, userRootDir) {
|
|
|
46
47
|
let { id, frame } = err;
|
|
47
48
|
const msgFirstLine = [
|
|
48
49
|
pc.red('Failed to transpile'),
|
|
49
|
-
pc.bold(pc.red(
|
|
50
|
+
pc.bold(pc.red(getFilePathToShowToUserFromUnkown(id, userRootDir))),
|
|
50
51
|
pc.red('because:')
|
|
51
52
|
].join(' ');
|
|
52
53
|
const errMsg = getPrettyErrMessage(err);
|
|
@@ -85,7 +86,7 @@ function getPrettyErrMessage(err) {
|
|
|
85
86
|
// Remove "/home/rom/code/vike/examples/react-full/components/Counter.tsx:1:8:" (redundant since we already print the filename)
|
|
86
87
|
const pos = /(?:\:\d+|)/;
|
|
87
88
|
errMsg = errMsg.split(reg([id, pos, pos, trail], 'gi')).join('');
|
|
88
|
-
errMsg = errMsg.split(reg([
|
|
89
|
+
errMsg = errMsg.split(reg([cleanFilePathUnkown(id), pos, pos, trail], 'gi')).join('');
|
|
89
90
|
// Remove "ERROR:" (useless)
|
|
90
91
|
errMsg = errMsg.split(reg(['ERROR:', trail])).join('');
|
|
91
92
|
// Remove "Internal server error:" (useless)
|
|
@@ -155,9 +156,3 @@ function isEquivalentErrorWithCodeSnippet(err1, err2) {
|
|
|
155
156
|
function isDefinedAndSame(val1, val2) {
|
|
156
157
|
return val1 && val1 === val2;
|
|
157
158
|
}
|
|
158
|
-
function normalizeId(id) {
|
|
159
|
-
id = toPosixPath(id);
|
|
160
|
-
// remove query
|
|
161
|
-
id = id.split('?')[0];
|
|
162
|
-
return id;
|
|
163
|
-
}
|
|
@@ -14,7 +14,7 @@ export { clearLogs };
|
|
|
14
14
|
import { isAbortError } from '../../../shared/route/abort.js';
|
|
15
15
|
import { getViteConfig } from '../../runtime/globalContext.js';
|
|
16
16
|
import { overwriteRuntimeProductionLogger } from '../../runtime/renderPage/loggerRuntime.js';
|
|
17
|
-
import { assert, assertIsNotProductionRuntime, formatHintLog, getAssertErrMsg,
|
|
17
|
+
import { assert, assertIsNotProductionRuntime, formatHintLog, getAssertErrMsg, overwriteAssertProductionLogger, stripAnsi, warnIfErrorIsNotObject } from '../utils.js';
|
|
18
18
|
import { getHttpRequestAsyncStore } from './getHttpRequestAsyncStore.js';
|
|
19
19
|
import { isErrorDebug } from './isErrorDebug.js';
|
|
20
20
|
import { isErrorWithCodeSnippet, getPrettyErrorWithCodeSnippet } from './loggerNotProd/errorWithCodeSnippet.js';
|
|
@@ -24,6 +24,7 @@ import pc from '@brillout/picocolors';
|
|
|
24
24
|
import { setAlreadyLogged } from '../../runtime/renderPage/isNewError.js';
|
|
25
25
|
import { isConfigInvalid } from '../../runtime/renderPage/isConfigInvalid.js';
|
|
26
26
|
import { onRuntimeError } from '../../runtime/renderPage/loggerProd.js';
|
|
27
|
+
import { isUserHookError } from '../../../shared/hooks/executeHook.js';
|
|
27
28
|
assertIsNotProductionRuntime();
|
|
28
29
|
overwriteRuntimeProductionLogger(logRuntimeError, logRuntimeInfo);
|
|
29
30
|
overwriteAssertProductionLogger(assertLogger);
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export * from '../runtime/utils.js';
|
|
2
2
|
export * from '../../utils/viteIsSSR.js';
|
|
3
|
-
export * from '../../utils/getFilePathAbsolute.js';
|
|
4
3
|
export * from '../../utils/requireResolve.js';
|
|
5
4
|
export * from '../../utils/arrayIncludes.js';
|
|
6
5
|
export * from '../../utils/isDev.js';
|
|
@@ -20,3 +19,4 @@ export * from '../../utils/injectRollupInputs.js';
|
|
|
20
19
|
export * from '../../utils/humanizeTime.js';
|
|
21
20
|
export * from '../../utils/pLimit.js';
|
|
22
21
|
export * from '../../utils/assertVersion.js';
|
|
22
|
+
export * from '../../utils/assertPathIsFilesystemAbsolute.js';
|
|
@@ -6,7 +6,6 @@ onLoad();
|
|
|
6
6
|
export * from '../runtime/utils.js';
|
|
7
7
|
// Utils only needed by `plugin/*`
|
|
8
8
|
export * from '../../utils/viteIsSSR.js';
|
|
9
|
-
export * from '../../utils/getFilePathAbsolute.js';
|
|
10
9
|
export * from '../../utils/requireResolve.js';
|
|
11
10
|
export * from '../../utils/arrayIncludes.js';
|
|
12
11
|
export * from '../../utils/isDev.js';
|
|
@@ -26,3 +25,4 @@ export * from '../../utils/injectRollupInputs.js';
|
|
|
26
25
|
export * from '../../utils/humanizeTime.js';
|
|
27
26
|
export * from '../../utils/pLimit.js';
|
|
28
27
|
export * from '../../utils/assertVersion.js';
|
|
28
|
+
export * from '../../utils/assertPathIsFilesystemAbsolute.js';
|
|
@@ -5,8 +5,7 @@ export { runPrerender_forceExit };
|
|
|
5
5
|
import '../runtime/page-files/setup.js';
|
|
6
6
|
import path from 'path';
|
|
7
7
|
import { route } from '../../shared/route/index.js';
|
|
8
|
-
import { assert, assertUsage, assertWarning, hasProp, projectInfo, objectAssign, isObjectWithKeys, isCallable, getOutDirs, isPropertyGetter, assertPosixPath, urlToFile,
|
|
9
|
-
import { pLimit } from '../../utils/pLimit.js';
|
|
8
|
+
import { assert, assertUsage, assertWarning, hasProp, projectInfo, objectAssign, isObjectWithKeys, isCallable, getOutDirs, isPropertyGetter, assertPosixPath, urlToFile, isPlainObject, handleNodeEnv_prerender, pLimit, assertPathIsFilesystemAbsolute } from './utils.js';
|
|
10
9
|
import { prerenderPage, prerender404Page, getRenderContext, getPageContextInitEnhanced } from '../runtime/renderPage/renderPageAlreadyRouted.js';
|
|
11
10
|
import pc from '@brillout/picocolors';
|
|
12
11
|
import { cpus } from 'os';
|
|
@@ -20,13 +19,13 @@ import { getConfigValue, getConfigValueFilePathToShowToUser } from '../../shared
|
|
|
20
19
|
import { loadConfigValues } from '../../shared/page-configs/loadConfigValues.js';
|
|
21
20
|
import { isErrorPage } from '../../shared/error-page.js';
|
|
22
21
|
import { addUrlComputedProps } from '../../shared/addUrlComputedProps.js';
|
|
23
|
-
import { assertPathIsFilesystemAbsolute } from '../../utils/assertPathIsFilesystemAbsolute.js';
|
|
24
22
|
import { isAbortError } from '../../shared/route/abort.js';
|
|
25
23
|
import { loadUserFilesServerSide } from '../runtime/renderPage/loadUserFilesServerSide.js';
|
|
26
24
|
import { getHookFromPageConfig, getHookFromPageConfigGlobal, getHookTimeoutDefault, setIsPrerenderering } from '../../shared/hooks/getHook.js';
|
|
27
25
|
import { noRouteMatch } from '../../shared/route/noRouteMatch.js';
|
|
28
26
|
import { getVikeConfig } from '../plugin/plugins/importUserCode/v1-design/getVikeConfig.js';
|
|
29
27
|
import { logErrorHint } from '../runtime/renderPage/logErrorHint.js';
|
|
28
|
+
import { executeHook, isUserHookError } from '../../shared/hooks/executeHook.js';
|
|
30
29
|
async function runPrerenderFromAPI(options = {}) {
|
|
31
30
|
await runPrerender(options, 'prerender()');
|
|
32
31
|
// - We purposely propagate the error to the user land, so that the error interrupts the user land. It's also, I guess, a nice-to-have that the user has control over the error.
|
|
@@ -8,6 +8,7 @@ export * from '../../utils/getOutDirs.js';
|
|
|
8
8
|
export * from '../../utils/isPropertyGetter.js';
|
|
9
9
|
export * from '../../utils/filesystemPathHandling.js';
|
|
10
10
|
export * from '../../utils/urlToFile.js';
|
|
11
|
-
export * from '../../shared/hooks/executeHook.js';
|
|
12
11
|
export * from '../../utils/isPlainObject.js';
|
|
13
12
|
export * from '../../utils/assertNodeEnv.js';
|
|
13
|
+
export * from '../../utils/pLimit.js';
|
|
14
|
+
export * from '../../utils/assertPathIsFilesystemAbsolute.js';
|
|
@@ -10,6 +10,7 @@ export * from '../../utils/getOutDirs.js';
|
|
|
10
10
|
export * from '../../utils/isPropertyGetter.js';
|
|
11
11
|
export * from '../../utils/filesystemPathHandling.js';
|
|
12
12
|
export * from '../../utils/urlToFile.js';
|
|
13
|
-
export * from '../../shared/hooks/executeHook.js';
|
|
14
13
|
export * from '../../utils/isPlainObject.js';
|
|
15
14
|
export * from '../../utils/assertNodeEnv.js';
|
|
15
|
+
export * from '../../utils/pLimit.js';
|
|
16
|
+
export * from '../../utils/assertPathIsFilesystemAbsolute.js';
|
|
@@ -138,6 +138,7 @@ async function mergeScriptEntries(pageAssets, isProduction) {
|
|
|
138
138
|
function getPageContextJsonScriptTag(pageContext) {
|
|
139
139
|
const pageContextSerialized = sanitizeJson(serializePageContextClientSide(pageContext));
|
|
140
140
|
const htmlTag = `<script id="vike_pageContext" type="application/json">${pageContextSerialized}</script>`;
|
|
141
|
+
// Used by contra.com https://github.com/gajus
|
|
141
142
|
// @ts-expect-error
|
|
142
143
|
pageContext._pageContextHtmlTag = htmlTag;
|
|
143
144
|
return htmlTag;
|
|
@@ -94,7 +94,7 @@ function injectBreakLines(htmlFragment, before, after) {
|
|
|
94
94
|
const whitespaceExtra = paddingParent ? ' ' : '';
|
|
95
95
|
const whitespace = `${paddingParent}${whitespaceExtra}`;
|
|
96
96
|
const padding = `\n${whitespace}`;
|
|
97
|
-
htmlFragment = htmlFragment.
|
|
97
|
+
htmlFragment = htmlFragment.replace(/<[^\/]/g, (match) => `${padding}${match}`);
|
|
98
98
|
if (isBlankLine) {
|
|
99
99
|
assert(htmlFragment.startsWith(padding), { htmlFragment });
|
|
100
100
|
htmlFragment = whitespaceExtra + htmlFragment.slice(padding.length);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export { executeOnBeforeRenderAndDataHooks };
|
|
2
2
|
import { getHook } from '../../../shared/hooks/getHook.js';
|
|
3
3
|
import { preparePageContextForUserConsumptionServerSide } from './preparePageContextForUserConsumptionServerSide.js';
|
|
4
|
-
import { executeHook } from '../utils.js';
|
|
5
4
|
import { assertOnBeforeRenderHookReturn } from '../../../shared/assertOnBeforeRenderHookReturn.js';
|
|
5
|
+
import { executeHook } from '../../../shared/hooks/executeHook.js';
|
|
6
6
|
async function executeOnBeforeRenderAndDataHooks(pageContext) {
|
|
7
7
|
if (pageContext._pageContextAlreadyProvidedByOnPrerenderHook) {
|
|
8
8
|
return;
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
export { executeOnRenderHtmlHook };
|
|
2
2
|
import { isDocumentHtml, renderDocumentHtml, dangerouslySkipEscape } from '../html/renderHtml.js';
|
|
3
3
|
import { getHook } from '../../../shared/hooks/getHook.js';
|
|
4
|
-
import { assert, assertUsage, assertWarning, isObject, objectAssign, isPromise,
|
|
4
|
+
import { assert, assertUsage, assertWarning, isObject, objectAssign, isPromise, isCallable } from '../utils.js';
|
|
5
5
|
import { isStream } from '../html/stream.js';
|
|
6
6
|
import { assertPageContextProvidedByUser } from '../../../shared/assertPageContextProvidedByUser.js';
|
|
7
7
|
import { preparePageContextForUserConsumptionServerSide } from './preparePageContextForUserConsumptionServerSide.js';
|
|
8
8
|
import { assertHookReturnedObject } from '../../../shared/assertHookReturnedObject.js';
|
|
9
9
|
import { logRuntimeError } from './loggerRuntime.js';
|
|
10
10
|
import pc from '@brillout/picocolors';
|
|
11
|
+
import { executeHook } from '../../../shared/hooks/executeHook.js';
|
|
11
12
|
async function executeOnRenderHtmlHook(pageContext) {
|
|
12
13
|
const { renderHook, hookFn } = getRenderHook(pageContext);
|
|
13
14
|
objectAssign(pageContext, { _renderHook: renderHook });
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
export { getManifestEntry };
|
|
2
|
-
import { assert, slice,
|
|
3
|
-
import { assertClientEntryId } from './assertClientEntryId.js';
|
|
2
|
+
import { assert, slice, assertIsNpmPackageImport } from '../../utils.js';
|
|
4
3
|
import { isVirtualFileIdPageConfigValuesAll } from '../../../shared/virtual-files/virtualFilePageConfigValuesAll.js';
|
|
5
4
|
import { prependEntriesDir } from '../../../shared/prependEntriesDir.js';
|
|
6
5
|
function getManifestEntry(id, assetsManifest) {
|
|
7
|
-
assertClientEntryId(id);
|
|
8
6
|
const debugInfo = getDebugInfo(id, assetsManifest);
|
|
9
7
|
// Vike client entry
|
|
10
8
|
if (id.startsWith('@@vike/')) {
|
|
@@ -42,42 +40,42 @@ function getManifestEntry(id, assetsManifest) {
|
|
|
42
40
|
return { manifestEntry, manifestKey };
|
|
43
41
|
}
|
|
44
42
|
// npm package import
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
43
|
+
assertIsNpmPackageImport(id);
|
|
44
|
+
const found = Object.entries(assetsManifest).find(([, e]) => e.name === prependEntriesDir(id));
|
|
45
|
+
assert(found);
|
|
46
|
+
const [manifestKey, manifestEntry] = found;
|
|
47
|
+
return { manifestEntry, manifestKey };
|
|
48
|
+
/* Can we remove this?
|
|
51
49
|
// extensions[number].pageConfigsSrcDir
|
|
52
50
|
if (id.startsWith('/node_modules/') || id.startsWith('/../')) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
51
|
+
let manifestKeyEnd = id.split('/node_modules/').slice(-1)[0]
|
|
52
|
+
assert(manifestKeyEnd, debugInfo)
|
|
53
|
+
assert(!manifestKeyEnd.startsWith('/'), debugInfo)
|
|
54
|
+
manifestKeyEnd = '/' + manifestKeyEnd
|
|
55
|
+
{
|
|
56
|
+
const { manifestEntry, manifestKey } = findEntryWithKeyEnd(manifestKeyEnd, assetsManifest, id)
|
|
57
|
+
if (manifestEntry) {
|
|
58
|
+
assert(manifestKey, debugInfo)
|
|
59
|
+
return { manifestEntry, manifestKey }
|
|
63
60
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
61
|
+
}
|
|
62
|
+
{
|
|
63
|
+
assert(manifestKeyEnd.startsWith('/'), debugInfo)
|
|
64
|
+
const dirS = manifestKeyEnd.split('/')
|
|
65
|
+
assert(dirS[0] === '', debugInfo)
|
|
66
|
+
manifestKeyEnd = '/' + dirS.slice(2).join('/')
|
|
67
|
+
assert(manifestKeyEnd.startsWith('/'), debugInfo)
|
|
68
|
+
}
|
|
69
|
+
{
|
|
70
|
+
const { manifestEntry, manifestKey } = findEntryWithKeyEnd(manifestKeyEnd, assetsManifest, id)
|
|
71
|
+
if (manifestEntry) {
|
|
72
|
+
assert(manifestKey, debugInfo)
|
|
73
|
+
return { manifestEntry, manifestKey }
|
|
77
74
|
}
|
|
78
|
-
|
|
75
|
+
}
|
|
76
|
+
assert(false, debugInfo)
|
|
79
77
|
}
|
|
80
|
-
|
|
78
|
+
*/
|
|
81
79
|
}
|
|
82
80
|
function findEntryWithKeyEnd(manifestKeyEnd, assetsManifest, id) {
|
|
83
81
|
const debugInfo = getDebugInfo(id, assetsManifest, manifestKeyEnd);
|
|
@@ -9,15 +9,16 @@ function retrieveAssetsProd(clientDependencies, assetsManifest, includeAssetsImp
|
|
|
9
9
|
clientDependencies.forEach(({ id, onlyAssets, eagerlyImported }) => {
|
|
10
10
|
if (eagerlyImported)
|
|
11
11
|
return; // Eagerly imported assets aren't imported with import() and therefore don't create a new Rollup entry and aren't listed in the manifest file
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
// TODO/v1-release: remove
|
|
13
|
+
if (includeAssetsImportedByServer &&
|
|
14
|
+
onlyAssets &&
|
|
15
|
+
id.includes('.page.server.') &&
|
|
15
16
|
// We assume that all npm packages have already built their files: bundlers (Rollup, esbuild, tsup, ...) extract the CSS out of JavaScript => we can assume JavaScript to not import any CSS/assets.
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
!isNpmPackageImport(id, {
|
|
18
|
+
// I presume Vite already resolves path aliases when Vite sets the module's id
|
|
19
|
+
cannotBePathAlias: true
|
|
20
|
+
})) {
|
|
21
|
+
id = extractAssetsAddQuery(id);
|
|
21
22
|
}
|
|
22
23
|
const { manifestKey } = getManifestEntry(id, assetsManifest);
|
|
23
24
|
collectAssets(manifestKey, assetUrls, visistedAssets, assetsManifest, onlyAssets);
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
export { getPageAssets };
|
|
2
|
-
import { assert, prependBase, assertPosixPath, toPosixPath,
|
|
2
|
+
import { assert, prependBase, assertPosixPath, toPosixPath, unique, pathJoin, assertIsNpmPackageImport } from '../utils.js';
|
|
3
3
|
import { retrieveAssetsDev } from './getPageAssets/retrieveAssetsDev.js';
|
|
4
4
|
import { retrieveAssetsProd } from './getPageAssets/retrieveAssetsProd.js';
|
|
5
5
|
import { inferMediaType } from './inferMediaType.js';
|
|
6
6
|
import { getManifestEntry } from './getPageAssets/getManifestEntry.js';
|
|
7
7
|
import { sortPageAssetsForEarlyHintsHeader } from './getPageAssets/sortPageAssetsForEarlyHintsHeader.js';
|
|
8
8
|
import { getGlobalContext } from '../globalContext.js';
|
|
9
|
-
import { assertClientEntryId } from './getPageAssets/assertClientEntryId.js';
|
|
10
9
|
import { import_ } from '@brillout/import';
|
|
11
10
|
async function getPageAssets(pageContext, clientDependencies, clientEntries) {
|
|
12
11
|
const globalContext = getGlobalContext();
|
|
@@ -56,7 +55,6 @@ async function getPageAssets(pageContext, clientDependencies, clientEntries) {
|
|
|
56
55
|
return pageAssets;
|
|
57
56
|
}
|
|
58
57
|
async function resolveClientEntriesDev(clientEntry, viteDevServer) {
|
|
59
|
-
assertClientEntryId(clientEntry);
|
|
60
58
|
let root = viteDevServer.config.root;
|
|
61
59
|
assert(root);
|
|
62
60
|
root = toPosixPath(root);
|
|
@@ -73,11 +71,9 @@ async function resolveClientEntriesDev(clientEntry, viteDevServer) {
|
|
|
73
71
|
assertPosixPath(clientEntry);
|
|
74
72
|
let filePath;
|
|
75
73
|
if (clientEntry.startsWith('/')) {
|
|
76
|
-
// User files
|
|
77
74
|
filePath = pathJoin(root, clientEntry);
|
|
78
75
|
}
|
|
79
|
-
else
|
|
80
|
-
// Vike client entry
|
|
76
|
+
else {
|
|
81
77
|
const { createRequire } = (await import_('module')).default;
|
|
82
78
|
const { dirname } = (await import_('path')).default;
|
|
83
79
|
const { fileURLToPath } = (await import_('url')).default;
|
|
@@ -88,10 +84,7 @@ async function resolveClientEntriesDev(clientEntry, viteDevServer) {
|
|
|
88
84
|
// @ts-expect-error
|
|
89
85
|
// Bun workaround https://github.com/vikejs/vike/pull/1048
|
|
90
86
|
const res = typeof Bun !== 'undefined' ? (toPath) => Bun.resolveSync(toPath, __dirname_) : require_.resolve;
|
|
91
|
-
if (
|
|
92
|
-
filePath = res(clientEntry);
|
|
93
|
-
}
|
|
94
|
-
else {
|
|
87
|
+
if (clientEntry.startsWith('@@vike/')) {
|
|
95
88
|
assert(clientEntry.endsWith('.js'));
|
|
96
89
|
try {
|
|
97
90
|
// For Vitest (which doesn't resolve vike to its dist but to its source files)
|
|
@@ -104,9 +97,10 @@ async function resolveClientEntriesDev(clientEntry, viteDevServer) {
|
|
|
104
97
|
filePath = toPosixPath(res(clientEntry.replace('@@vike/dist/esm/client/', '../../../../../dist/esm/client/')));
|
|
105
98
|
}
|
|
106
99
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
100
|
+
else {
|
|
101
|
+
assertIsNpmPackageImport(clientEntry);
|
|
102
|
+
filePath = res(clientEntry);
|
|
103
|
+
}
|
|
110
104
|
}
|
|
111
105
|
if (!filePath.startsWith('/')) {
|
|
112
106
|
assert(process.platform === 'win32');
|
|
@@ -4,6 +4,7 @@ export { isCjsEsmError };
|
|
|
4
4
|
export { isKnownError };
|
|
5
5
|
export { getHint };
|
|
6
6
|
import { assert, formatHintLog, isNotNullish, isObject, unique } from '../utils.js';
|
|
7
|
+
import pc from '@brillout/picocolors';
|
|
7
8
|
const knownErrors = [
|
|
8
9
|
{
|
|
9
10
|
errMsg: 'jsxDEV is not a function',
|
|
@@ -44,6 +45,7 @@ function getHint(error) {
|
|
|
44
45
|
}
|
|
45
46
|
function logHint(hint) {
|
|
46
47
|
hint = formatHintLog(hint);
|
|
48
|
+
hint = pc.bold(hint);
|
|
47
49
|
console.error(hint);
|
|
48
50
|
}
|
|
49
51
|
function isKnownError(error) {
|
|
@@ -51,7 +51,7 @@ async function renderPage(pageContextInit) {
|
|
|
51
51
|
async function renderPageAndPrepare(pageContextInit, httpRequestId) {
|
|
52
52
|
// Invalid config
|
|
53
53
|
const handleInvalidConfig = () => {
|
|
54
|
-
logRuntimeInfo?.(pc.bold(pc.red(
|
|
54
|
+
logRuntimeInfo?.(pc.bold(pc.red('Error while loading a Vike config file, see error above.')), httpRequestId, 'error');
|
|
55
55
|
const pageContextHttpResponseNull = getPageContextHttpResponseNull(pageContextInit);
|
|
56
56
|
return pageContextHttpResponseNull;
|
|
57
57
|
};
|
|
@@ -203,29 +203,42 @@ function getRequestInfoMessage(urlOriginal) {
|
|
|
203
203
|
}
|
|
204
204
|
function logHttpResponse(urlOriginal, httpRequestId, pageContextReturn) {
|
|
205
205
|
const statusCode = pageContextReturn.httpResponse?.statusCode ?? null;
|
|
206
|
+
let msg;
|
|
207
|
+
let isNominal;
|
|
206
208
|
{
|
|
207
|
-
// If URL doesn't include Base URL
|
|
208
209
|
const { errorWhileRendering } = pageContextReturn;
|
|
209
|
-
const isSkipped = statusCode === null &&
|
|
210
|
-
if (isSkipped)
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
210
|
+
const isSkipped = statusCode === null && !errorWhileRendering;
|
|
211
|
+
if (isSkipped) {
|
|
212
|
+
// - URL doesn't include Base URL
|
|
213
|
+
// - Can we abort earlier so that `logHttpResponse()` and `logHttpRequest()` aren't even called?
|
|
214
|
+
// - Error loading a Vike config file
|
|
215
|
+
// - We should show `HTTP response ${urlOriginal} ERR` instead.
|
|
216
|
+
// - Maybe we can/should make the error available at pageContext.errorWhileRendering
|
|
217
|
+
assert(errorWhileRendering === null || errorWhileRendering === undefined);
|
|
218
|
+
msg = `HTTP response ${pc.bold(urlOriginal)} ${pc.dim('null')}`;
|
|
219
|
+
// Erroneous value (it shoud sometimes be `false`) but it's fine as it doesn't seem to have much of an impact.
|
|
220
|
+
isNominal = true;
|
|
221
|
+
}
|
|
222
|
+
else {
|
|
223
|
+
const isSuccess = statusCode !== null && statusCode >= 200 && statusCode <= 399;
|
|
224
|
+
isNominal = isSuccess || statusCode === 404;
|
|
225
|
+
const color = (s) => pc.bold(isSuccess ? pc.green(String(s)) : pc.red(String(s)));
|
|
226
|
+
const isRedirect = statusCode && 300 <= statusCode && statusCode <= 399;
|
|
227
|
+
const type = isRedirect ? 'redirect' : 'response';
|
|
228
|
+
if (isRedirect) {
|
|
229
|
+
assert(pageContextReturn.httpResponse);
|
|
230
|
+
const headerRedirect = pageContextReturn.httpResponse.headers
|
|
231
|
+
.slice()
|
|
232
|
+
.reverse()
|
|
233
|
+
.find((header) => header[0] === 'Location');
|
|
234
|
+
assert(headerRedirect);
|
|
235
|
+
const urlRedirect = headerRedirect[1];
|
|
236
|
+
urlOriginal = urlRedirect;
|
|
237
|
+
}
|
|
238
|
+
msg = `HTTP ${type} ${pc.bold(urlOriginal)} ${color(statusCode ?? 'ERR')}`;
|
|
239
|
+
}
|
|
227
240
|
}
|
|
228
|
-
logRuntimeInfo?.(
|
|
241
|
+
logRuntimeInfo?.(msg, httpRequestId, isNominal ? 'info' : 'error');
|
|
229
242
|
}
|
|
230
243
|
function getPageContextHttpResponseNullWithError(err, pageContextInit) {
|
|
231
244
|
const pageContextHttpResponseNull = {};
|
|
@@ -29,7 +29,6 @@ export * from '../../utils/isPropertyGetter.js';
|
|
|
29
29
|
export * from '../../utils/debug.js';
|
|
30
30
|
export * from '../../utils/urlToFile.js';
|
|
31
31
|
export * from '../../utils/getGlobalObject.js';
|
|
32
|
-
export * from '../../shared/hooks/executeHook.js';
|
|
33
32
|
export * from '../../utils/freezePartial.js';
|
|
34
33
|
export * from '../../utils/isNpmPackage.js';
|
|
35
34
|
export * from '../../utils/isNotNullish.js';
|
|
@@ -32,7 +32,6 @@ export * from '../../utils/isPropertyGetter.js';
|
|
|
32
32
|
export * from '../../utils/debug.js';
|
|
33
33
|
export * from '../../utils/urlToFile.js';
|
|
34
34
|
export * from '../../utils/getGlobalObject.js';
|
|
35
|
-
export * from '../../shared/hooks/executeHook.js';
|
|
36
35
|
export * from '../../utils/freezePartial.js';
|
|
37
36
|
export * from '../../utils/isNpmPackage.js';
|
|
38
37
|
export * from '../../utils/isNotNullish.js';
|
|
@@ -2,7 +2,7 @@ export type { PageContextConfig };
|
|
|
2
2
|
import type { VikePackages } from '../../VikeNamespace.js';
|
|
3
3
|
import type { ConfigBuiltIn } from '../Config.js';
|
|
4
4
|
import type { Combine, IsNotEmpty, XOR5 } from './helpers.ts';
|
|
5
|
-
type PageContextConfig = ConfigBuiltIn & (ConfigVikePackagesNotEmptyXor extends true ? ConfigVikePackagesIntersection : ConfigVikePackagesCombined);
|
|
5
|
+
type PageContextConfig = ConfigBuiltIn & Vike.Config & (ConfigVikePackagesNotEmptyXor extends true ? ConfigVikePackagesIntersection : ConfigVikePackagesCombined);
|
|
6
6
|
type ConfigVikePackagesIntersection = VikePackages.ConfigVikeReact & VikePackages.ConfigVikeVue & VikePackages.ConfigVikeSolid & VikePackages.ConfigVikeSvelte & VikePackages.ConfigVikeAngular;
|
|
7
7
|
type ConfigVikePackagesCombined = Combine<VikePackages.ConfigVikeReact, Combine<VikePackages.ConfigVikeVue, Combine<VikePackages.ConfigVikeSolid, Combine<VikePackages.ConfigVikeSvelte, VikePackages.ConfigVikeAngular>>>>;
|
|
8
8
|
type ConfigVikePackagesNotEmptyXor = XOR5<IsNotEmpty<VikePackages.ConfigVikeReact>, IsNotEmpty<VikePackages.ConfigVikeVue>, IsNotEmpty<VikePackages.ConfigVikeSolid>, IsNotEmpty<VikePackages.ConfigVikeSvelte>, IsNotEmpty<VikePackages.ConfigVikeAngular>>;
|