vike 0.4.193 → 0.4.195-commit-486b49a
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/LICENSE.md +9 -0
- package/RenderErrorPage.js +1 -0
- package/__internal/setup.js +1 -0
- package/__internal.js +1 -0
- package/abort.js +1 -0
- package/cli.js +1 -0
- package/client/router.js +1 -0
- package/client.js +1 -0
- package/dist/cjs/node/plugin/plugins/importBuild/index.js +2 -2
- package/dist/cjs/node/plugin/plugins/importUserCode/index.js +1 -5
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +5 -1
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +2 -2
- package/dist/cjs/node/plugin/shared/addSsrMiddleware.js +4 -9
- package/dist/cjs/node/plugin/shared/loggerNotProd/log.js +1 -13
- package/dist/cjs/node/plugin/shared/loggerNotProd.js +2 -24
- package/dist/cjs/node/plugin/shared/loggerVite.js +0 -3
- package/dist/cjs/node/runtime/globalContext/loadImportBuild.js +2 -2
- package/dist/cjs/node/runtime/html/injectAssets/getHtmlTags.js +17 -12
- package/dist/cjs/node/runtime/html/injectAssets/injectHtmlTags.js +1 -1
- package/dist/cjs/node/runtime/html/injectAssets.js +2 -2
- package/dist/cjs/node/runtime/renderPage/analyzePage.js +4 -4
- package/dist/cjs/node/runtime/renderPage/assertArguments.js +3 -3
- package/dist/cjs/node/runtime/renderPage/{createHttpResponseObject.js → createHttpResponse.js} +34 -15
- package/dist/cjs/node/runtime/renderPage/executeOnRenderHtmlHook.js +3 -5
- package/dist/cjs/node/runtime/renderPage/handleErrorWithoutErrorPage.js +4 -3
- package/dist/cjs/node/runtime/renderPage/inferMediaType.js +3 -0
- package/dist/cjs/node/runtime/renderPage/isConfigInvalid.js +4 -2
- package/dist/cjs/node/runtime/renderPage/renderPageAlreadyRouted.js +6 -12
- package/dist/cjs/node/runtime/renderPage.js +62 -66
- package/dist/cjs/shared/getPageFiles/analyzeClientSide.js +3 -3
- package/dist/cjs/shared/page-configs/assertPlusFileExport.js +1 -2
- package/dist/cjs/shared/route/executeOnBeforeRouteHook.js +1 -1
- package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
- package/dist/cjs/utils/isArray.js +1 -1
- package/dist/cjs/utils/parseUrl-extras.js +6 -1
- package/dist/esm/client/client-routing-runtime/isClientSideRoutable.js +2 -2
- package/dist/esm/client/client-routing-runtime/renderPageClientSide.js +30 -15
- package/dist/esm/node/plugin/plugins/importBuild/index.js +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/index.js +2 -6
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +5 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +2 -2
- package/dist/esm/node/plugin/shared/addSsrMiddleware.js +4 -9
- package/dist/esm/node/plugin/shared/loggerNotProd/log.d.ts +0 -7
- package/dist/esm/node/plugin/shared/loggerNotProd/log.js +0 -12
- package/dist/esm/node/plugin/shared/loggerNotProd.d.ts +1 -7
- package/dist/esm/node/plugin/shared/loggerNotProd.js +2 -24
- package/dist/esm/node/plugin/shared/loggerVite.js +1 -4
- package/dist/esm/node/runtime/globalContext/loadImportBuild.js +1 -1
- package/dist/esm/node/runtime/html/injectAssets/getHtmlTags.d.ts +1 -1
- package/dist/esm/node/runtime/html/injectAssets/getHtmlTags.js +17 -12
- package/dist/esm/node/runtime/html/injectAssets/injectHtmlTags.js +1 -1
- package/dist/esm/node/runtime/html/injectAssets.js +2 -2
- package/dist/esm/node/runtime/renderPage/analyzePage.js +4 -4
- package/dist/esm/node/runtime/renderPage/assertArguments.js +3 -3
- package/dist/esm/node/runtime/renderPage/{createHttpResponseObject.d.ts → createHttpResponse.d.ts} +13 -5
- package/dist/esm/node/runtime/renderPage/{createHttpResponseObject.js → createHttpResponse.js} +34 -15
- package/dist/esm/node/runtime/renderPage/executeOnRenderHtmlHook.d.ts +1 -1
- package/dist/esm/node/runtime/renderPage/executeOnRenderHtmlHook.js +3 -5
- package/dist/esm/node/runtime/renderPage/handleErrorWithoutErrorPage.d.ts +2 -0
- package/dist/esm/node/runtime/renderPage/handleErrorWithoutErrorPage.js +4 -3
- package/dist/esm/node/runtime/renderPage/inferMediaType.d.ts +1 -1
- package/dist/esm/node/runtime/renderPage/inferMediaType.js +3 -0
- package/dist/esm/node/runtime/renderPage/isConfigInvalid.d.ts +6 -2
- package/dist/esm/node/runtime/renderPage/isConfigInvalid.js +6 -2
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.js +5 -11
- package/dist/esm/node/runtime/renderPage.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage.js +62 -66
- package/dist/esm/shared/getPageFiles/analyzeClientSide.d.ts +1 -1
- package/dist/esm/shared/getPageFiles/analyzeClientSide.js +3 -3
- package/dist/esm/shared/page-configs/Config.d.ts +2 -2
- package/dist/esm/shared/page-configs/assertPlusFileExport.js +1 -2
- package/dist/esm/shared/route/abort.d.ts +3 -3
- package/dist/esm/shared/route/executeOnBeforeRouteHook.js +1 -1
- package/dist/esm/types/index.d.ts +1 -1
- package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
- package/dist/esm/utils/PROJECT_VERSION.js +1 -1
- package/dist/esm/utils/isArray.js +1 -1
- package/dist/esm/utils/parseUrl-extras.d.ts +2 -0
- package/dist/esm/utils/parseUrl-extras.js +5 -0
- package/dist/esm/utils/projectInfo.d.ts +1 -1
- package/package.json +69 -68
- package/plugin.js +1 -0
- package/prerender.js +1 -0
- package/routing.js +1 -0
- package/server.js +1 -0
- /package/dist/cjs/node/runtime/renderPage/{createHttpResponseObject → createHttpResponse}/assertNoInfiniteHttpRedirect.js +0 -0
- /package/dist/cjs/node/runtime/renderPage/{createHttpResponseObject → createHttpResponse}/getCacheControl.js +0 -0
- /package/dist/esm/node/runtime/renderPage/{createHttpResponseObject → createHttpResponse}/assertNoInfiniteHttpRedirect.d.ts +0 -0
- /package/dist/esm/node/runtime/renderPage/{createHttpResponseObject → createHttpResponse}/assertNoInfiniteHttpRedirect.js +0 -0
- /package/dist/esm/node/runtime/renderPage/{createHttpResponseObject → createHttpResponse}/getCacheControl.d.ts +0 -0
- /package/dist/esm/node/runtime/renderPage/{createHttpResponseObject → createHttpResponse}/getCacheControl.js +0 -0
|
@@ -1,17 +1,12 @@
|
|
|
1
1
|
export { logWithViteTag };
|
|
2
2
|
export { logWithVikeTag };
|
|
3
3
|
export { logDirectly };
|
|
4
|
-
export { isFirstLog };
|
|
5
|
-
export { clearScreen };
|
|
6
|
-
export { screenHasErrors };
|
|
7
4
|
export { applyViteSourceMapToStackTrace };
|
|
8
5
|
import { assert, projectInfo, stripAnsi, hasProp, assertIsNotProductionRuntime } from '../../utils.js';
|
|
9
6
|
import pc from '@brillout/picocolors';
|
|
10
7
|
import { isErrorDebug } from '../../../shared/isErrorDebug.js';
|
|
11
8
|
import { getViteDevServer } from '../../../runtime/globalContext.js';
|
|
12
9
|
assertIsNotProductionRuntime();
|
|
13
|
-
let isFirstLog = true;
|
|
14
|
-
let screenHasErrors = false;
|
|
15
10
|
function logWithVikeTag(msg, logType, category, showVikeVersion = false) {
|
|
16
11
|
const projectTag = getProjectTag(showVikeVersion);
|
|
17
12
|
msg = prependTags(msg, projectTag, category, logType);
|
|
@@ -36,7 +31,6 @@ function logWithViteTag(msg, logType, category) {
|
|
|
36
31
|
// - Production => logs aren't managed by loggerNotProd.ts => logDirectly() is never called (not even loaded as asserted by assertIsVitePluginCode())
|
|
37
32
|
function logDirectly(thing, logType) {
|
|
38
33
|
applyViteSourceMapToStackTrace(thing);
|
|
39
|
-
isFirstLog = false;
|
|
40
34
|
if (logType === 'info') {
|
|
41
35
|
console.log(thing);
|
|
42
36
|
return;
|
|
@@ -46,7 +40,6 @@ function logDirectly(thing, logType) {
|
|
|
46
40
|
return;
|
|
47
41
|
}
|
|
48
42
|
if (logType === 'error') {
|
|
49
|
-
screenHasErrors = true;
|
|
50
43
|
console.error(thing);
|
|
51
44
|
return;
|
|
52
45
|
}
|
|
@@ -57,11 +50,6 @@ function logDirectly(thing, logType) {
|
|
|
57
50
|
}
|
|
58
51
|
assert(false);
|
|
59
52
|
}
|
|
60
|
-
function clearScreen(viteConfig) {
|
|
61
|
-
// We use Vite's logger in order to respect the user's `clearScreen: false` setting
|
|
62
|
-
viteConfig.logger.clearScreen('error');
|
|
63
|
-
screenHasErrors = false;
|
|
64
|
-
}
|
|
65
53
|
function applyViteSourceMapToStackTrace(thing) {
|
|
66
54
|
if (isErrorDebug())
|
|
67
55
|
return;
|
|
@@ -4,7 +4,6 @@ export { logConfigInfo };
|
|
|
4
4
|
export { logConfigError };
|
|
5
5
|
export { logConfigErrorRecover };
|
|
6
6
|
export { logErrorDebugNote };
|
|
7
|
-
export { clearLogs };
|
|
8
7
|
export type { LogInfo };
|
|
9
8
|
export type { LogInfoArgs };
|
|
10
9
|
export type { LogError };
|
|
@@ -17,18 +16,13 @@ type LogInfo = (...args: LogInfoArgs) => void;
|
|
|
17
16
|
type LogInfoArgs = Parameters<typeof logRuntimeInfo>;
|
|
18
17
|
type LogError = (...args: LogErrorArgs) => void;
|
|
19
18
|
type LogErrorArgs = Parameters<typeof logRuntimeError>;
|
|
20
|
-
declare function logRuntimeInfo(msg: string, httpRequestId: number, logType: LogType
|
|
19
|
+
declare function logRuntimeInfo(msg: string, httpRequestId: number, logType: LogType): void;
|
|
21
20
|
declare function logViteAny(msg: string, logType: LogType, httpRequestId: number | null, prependViteTag: boolean): void;
|
|
22
21
|
declare function logConfigInfo(msg: string, logType: LogType): void;
|
|
23
22
|
declare function logConfigErrorRecover(): void;
|
|
24
23
|
declare function logRuntimeError(err: unknown, httpRequestId: number | null): void;
|
|
25
24
|
declare function logViteError(err: unknown, httpRequestId: number | undefined): void;
|
|
26
25
|
declare function logConfigError(err: unknown): void;
|
|
27
|
-
declare function clearLogs(conditions?: {
|
|
28
|
-
clearErrors?: boolean;
|
|
29
|
-
clearIfFirstLog?: boolean;
|
|
30
|
-
clearAlsoIfConfigIsInvalid?: boolean;
|
|
31
|
-
}): void;
|
|
32
26
|
/** Note shown to user when vike does something risky:
|
|
33
27
|
* - When vike dedupes (i.e. swallows) an error with getHttpRequestAsyncStore().shouldErrorBeSwallowed(err)
|
|
34
28
|
* - When vike modifies the error with getPrettyErrorWithCodeSnippet(err)
|
|
@@ -10,7 +10,6 @@ export { logConfigInfo };
|
|
|
10
10
|
export { logConfigError };
|
|
11
11
|
export { logConfigErrorRecover };
|
|
12
12
|
export { logErrorDebugNote };
|
|
13
|
-
export { clearLogs };
|
|
14
13
|
import { isAbortError } from '../../../shared/route/abort.js';
|
|
15
14
|
import { getViteConfig } from '../../runtime/globalContext.js';
|
|
16
15
|
import { overwriteRuntimeProductionLogger } from '../../runtime/renderPage/loggerRuntime.js';
|
|
@@ -19,18 +18,15 @@ import { getHttpRequestAsyncStore } from './getHttpRequestAsyncStore.js';
|
|
|
19
18
|
import { isErrorDebug } from '../../shared/isErrorDebug.js';
|
|
20
19
|
import { isErrorWithCodeSnippet, getPrettyErrorWithCodeSnippet } from './loggerNotProd/errorWithCodeSnippet.js';
|
|
21
20
|
import { getConfigExecutionErrorIntroMsg, getConfigBuildErrorFormatted } from '../plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js';
|
|
22
|
-
import { logWithVikeTag, logWithViteTag, logDirectly,
|
|
21
|
+
import { logWithVikeTag, logWithViteTag, logDirectly, applyViteSourceMapToStackTrace } from './loggerNotProd/log.js';
|
|
23
22
|
import pc from '@brillout/picocolors';
|
|
24
23
|
import { setAlreadyLogged } from '../../runtime/renderPage/isNewError.js';
|
|
25
|
-
import { isConfigInvalid } from '../../runtime/renderPage/isConfigInvalid.js';
|
|
26
24
|
import { onRuntimeError } from '../../runtime/renderPage/loggerProd.js';
|
|
27
25
|
import { isUserHookError } from '../../../shared/hooks/executeHook.js';
|
|
28
26
|
assertIsNotProductionRuntime();
|
|
29
27
|
overwriteRuntimeProductionLogger(logRuntimeError, logRuntimeInfo);
|
|
30
28
|
overwriteAssertProductionLogger(assertLogger);
|
|
31
|
-
function logRuntimeInfo(msg, httpRequestId, logType
|
|
32
|
-
if (clearErrors)
|
|
33
|
-
clearLogs({ clearErrors: true });
|
|
29
|
+
function logRuntimeInfo(msg, httpRequestId, logType) {
|
|
34
30
|
const category = getCategory(httpRequestId);
|
|
35
31
|
assert(category);
|
|
36
32
|
logWithVikeTag(msg, logType, category);
|
|
@@ -50,7 +46,6 @@ function logConfigInfo(msg, logType) {
|
|
|
50
46
|
}
|
|
51
47
|
function logConfigErrorRecover() {
|
|
52
48
|
const msg = pc.bold(pc.green('Configuration successfully loaded'));
|
|
53
|
-
clearLogs({ clearAlsoIfConfigIsInvalid: true });
|
|
54
49
|
const category = getConfigCategory();
|
|
55
50
|
logWithVikeTag(msg, 'error-recover', category);
|
|
56
51
|
}
|
|
@@ -110,7 +105,6 @@ function logErr(err, httpRequestId = null, errorComesFromVite) {
|
|
|
110
105
|
onRuntimeError(err);
|
|
111
106
|
}
|
|
112
107
|
function logConfigError(err) {
|
|
113
|
-
clearLogs({ clearAlsoIfConfigIsInvalid: true });
|
|
114
108
|
warnIfErrorIsNotObject(err);
|
|
115
109
|
const category = getConfigCategory();
|
|
116
110
|
{
|
|
@@ -173,22 +167,6 @@ function assertLogger(thing, logType) {
|
|
|
173
167
|
const { assertMsg, showVikeVersion } = res;
|
|
174
168
|
logWithVikeTag(assertMsg, logType, category, showVikeVersion);
|
|
175
169
|
}
|
|
176
|
-
function clearLogs(conditions = {}) {
|
|
177
|
-
if (!conditions.clearAlsoIfConfigIsInvalid && isConfigInvalid) {
|
|
178
|
-
// Avoid hiding the config error: the config error is printed only once
|
|
179
|
-
return;
|
|
180
|
-
}
|
|
181
|
-
if (conditions.clearErrors && !screenHasErrors) {
|
|
182
|
-
return;
|
|
183
|
-
}
|
|
184
|
-
if (conditions.clearIfFirstLog && !isFirstLog) {
|
|
185
|
-
return;
|
|
186
|
-
}
|
|
187
|
-
const viteConfig = getViteConfig();
|
|
188
|
-
if (viteConfig) {
|
|
189
|
-
clearScreen(viteConfig);
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
170
|
/** Note shown to user when vike does something risky:
|
|
193
171
|
* - When vike dedupes (i.e. swallows) an error with getHttpRequestAsyncStore().shouldErrorBeSwallowed(err)
|
|
194
172
|
* - When vike modifies the error with getPrettyErrorWithCodeSnippet(err)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { improveViteLogs };
|
|
2
2
|
import { assert, removeEmptyLines, trimWithAnsi, trimWithAnsiTrailOnly } from '../utils.js';
|
|
3
|
-
import { logViteError, logViteAny
|
|
3
|
+
import { logViteError, logViteAny } from './loggerNotProd.js';
|
|
4
4
|
import { getHttpRequestAsyncStore } from './getHttpRequestAsyncStore.js';
|
|
5
5
|
import { removeSuperfluousViteLog } from './loggerVite/removeSuperfluousViteLog.js';
|
|
6
6
|
import { isErrorDebug } from '../../shared/isErrorDebug.js';
|
|
@@ -36,9 +36,6 @@ function intercept(logType, config) {
|
|
|
36
36
|
assert(!isErrorDebug());
|
|
37
37
|
return;
|
|
38
38
|
}
|
|
39
|
-
// Only allow Vite to clear for its first log. All other clearing is controlled by vike.
|
|
40
|
-
if (options.clear)
|
|
41
|
-
clearLogs({ clearIfFirstLog: true });
|
|
42
39
|
// Vite's default logger preprends the "[vite]" tag if and only if options.timestamp is true
|
|
43
40
|
const prependViteTag = options.timestamp || !!store?.httpRequestId;
|
|
44
41
|
logViteAny(msg, logType, store?.httpRequestId ?? null, prependViteTag);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { loadImportBuild };
|
|
2
2
|
export { setImportBuildGetters };
|
|
3
|
-
import { importServerEntry } from '@brillout/vite-plugin-server-entry/
|
|
3
|
+
import { importServerEntry } from '@brillout/vite-plugin-server-entry/runtime';
|
|
4
4
|
import { assert } from '../utils.js';
|
|
5
5
|
const buildGetters = (globalThis.__vike_buildGetters = globalThis.__vike_buildGetters || {
|
|
6
6
|
getters: null
|
|
@@ -22,7 +22,7 @@ type InjectFilterEntry = {
|
|
|
22
22
|
isEntry: boolean;
|
|
23
23
|
inject: PreloadFilterInject;
|
|
24
24
|
};
|
|
25
|
-
type Position = 'HTML_BEGIN' | 'HTML_END' | '
|
|
25
|
+
type Position = 'HTML_BEGIN' | 'HTML_END' | 'HTML_STREAM';
|
|
26
26
|
type HtmlTag = {
|
|
27
27
|
htmlTag: string | (() => string);
|
|
28
28
|
position: Position;
|
|
@@ -20,7 +20,7 @@ function getHtmlTags(pageContext, streamFromReactStreamingPackage, injectFilter,
|
|
|
20
20
|
if (asset.isEntry && asset.assetType === 'script') {
|
|
21
21
|
// We could allow the user to change the position of <script> but we currently don't:
|
|
22
22
|
// - Because of mergeScriptEntries()
|
|
23
|
-
// - We would need to add
|
|
23
|
+
// - We would need to add HTML_STREAM to to PreloadFilterInject
|
|
24
24
|
// To suppor this, we should add the JavaScript entry to injectFilterEntries (with an `src` value of `null`)
|
|
25
25
|
return false;
|
|
26
26
|
}
|
|
@@ -77,31 +77,36 @@ function getHtmlTags(pageContext, streamFromReactStreamingPackage, injectFilter,
|
|
|
77
77
|
// ==========
|
|
78
78
|
// JavaScript
|
|
79
79
|
// ==========
|
|
80
|
-
// -
|
|
80
|
+
// - By default, we place the entry <script> towards the end of the HTML for better performance.
|
|
81
|
+
// - Performance-wise, it's more interesting to start showing the page (parse HTML and load CSS) before starting loading scripts.
|
|
82
|
+
// - But with HTML streaming, in order to support [Progressive Rendering](https://vike.dev/streaming#progressive-rendering), the entry <script> should be injected earlier instead.
|
|
83
|
+
// - The entry <script> shouldn't be `<script defer>` upon HTML streaming, otherwise progressive hydration while SSR streaming won't work.
|
|
84
|
+
// - `<script id="vike_pageContext" type="application/json">` (the `pageContext` JSON) should be fully sent before Vike's client runtime starts executing.
|
|
81
85
|
// - Otherwise, race condition "SyntaxError: Unterminated string in JSON": https://github.com/vikejs/vike/issues/567
|
|
82
|
-
// -
|
|
83
|
-
// -
|
|
84
|
-
|
|
85
|
-
// - The entry <script> should be towards the end of the HTML as performance-wise it's more interesting to parse <div id="page-view"> before running the entry <script> which initiates the hydration.
|
|
86
|
-
// - But with HTML streaming, in order to support [Progressive Rendering](https://vike.dev/streaming#progressive-rendering), the entry <script> should be injected early instead.
|
|
86
|
+
// - `<script id="vike_pageContext" type="application/json">` must appear before the entry <script> (which loads Vike's client runtime).
|
|
87
|
+
// - `<script id="vike_pageContext" type="application/json">` can't be async nor defer.
|
|
88
|
+
const positionJavaScriptDefault = 'HTML_END';
|
|
87
89
|
const positionJavaScriptEntry = (() => {
|
|
88
90
|
if (injectScriptsAt !== null) {
|
|
89
91
|
if (pageContext._pageContextPromise) {
|
|
90
92
|
assertWarning(injectScriptsAt === 'HTML_END' || !isStream, `You're setting injectScriptsAt to ${pc.code(JSON.stringify(injectScriptsAt))} while using HTML streaming with a pageContext promise (https://vike.dev/streaming#initial-data-after-stream-end) which is contradictory: the pageContext promise is skipped.`, { onlyOnce: true });
|
|
91
93
|
}
|
|
94
|
+
if (injectScriptsAt === 'HTML_STREAM' && !isStream) {
|
|
95
|
+
return positionJavaScriptDefault;
|
|
96
|
+
}
|
|
92
97
|
return injectScriptsAt;
|
|
93
98
|
}
|
|
94
99
|
if (pageContext._pageContextPromise) {
|
|
95
100
|
// - If there is a pageContext._pageContextPromise then <script id="vike_pageContext" type="application/json"> needs to await for it.
|
|
96
101
|
// - pageContext._pageContextPromise is typically resolved only after the page's components are rendered and the stream ended.
|
|
97
102
|
// - https://vike.dev/streaming#initial-data-after-stream-end
|
|
98
|
-
return
|
|
103
|
+
return positionJavaScriptDefault;
|
|
99
104
|
}
|
|
100
105
|
if (streamFromReactStreamingPackage && !streamFromReactStreamingPackage.hasStreamEnded()) {
|
|
101
106
|
// If there is a stream then, in order to support progressive hydration, inject the JavaScript during the stream after React(/Vue/Solid/...) resolved the first suspense boundary.
|
|
102
|
-
return '
|
|
107
|
+
return 'HTML_STREAM';
|
|
103
108
|
}
|
|
104
|
-
return
|
|
109
|
+
return positionJavaScriptDefault;
|
|
105
110
|
})();
|
|
106
111
|
if (pageContext._pageContextPromise && streamFromReactStreamingPackage) {
|
|
107
112
|
// - Should we show this warning for Solid as well? Solid seems to also support progressive rendering.
|
|
@@ -135,7 +140,7 @@ function getHtmlTags(pageContext, streamFromReactStreamingPackage, injectFilter,
|
|
|
135
140
|
const htmlTag = inferPreloadTag(asset);
|
|
136
141
|
if (!asset.inject)
|
|
137
142
|
return;
|
|
138
|
-
// Ideally, instead of this conditional ternary operator, we should add
|
|
143
|
+
// Ideally, instead of this conditional ternary operator, we should add HTML_STREAM to PreloadFilterInject
|
|
139
144
|
const position = asset.inject === 'HTML_END' ? positionJavaScriptEntry : asset.inject;
|
|
140
145
|
htmlTags.push({ htmlTag, position });
|
|
141
146
|
});
|
|
@@ -217,6 +222,6 @@ function getInjectScriptsAt(pageId, pageConfigs) {
|
|
|
217
222
|
assertUsage(injectScriptsAt === null ||
|
|
218
223
|
injectScriptsAt === 'HTML_BEGIN' ||
|
|
219
224
|
injectScriptsAt === 'HTML_END' ||
|
|
220
|
-
injectScriptsAt === '
|
|
225
|
+
injectScriptsAt === 'HTML_STREAM', `${configDefinedAt} has an invalid value`);
|
|
221
226
|
return injectScriptsAt;
|
|
222
227
|
}
|
|
@@ -16,7 +16,7 @@ function injectHtmlTags(htmlString, htmlTags, position) {
|
|
|
16
16
|
}
|
|
17
17
|
// Is it worth it? Should we remove this? https://github.com/vikejs/vike/pull/1740#issuecomment-2230540892
|
|
18
18
|
function injectHtmlTagsUsingStream(htmlTags, streamFromReactStreamingPackage) {
|
|
19
|
-
const htmlFragment = joinHtmlTags(htmlTags.filter((h) => h.position === '
|
|
19
|
+
const htmlFragment = joinHtmlTags(htmlTags.filter((h) => h.position === 'HTML_STREAM'));
|
|
20
20
|
if (htmlFragment) {
|
|
21
21
|
assert(!streamFromReactStreamingPackage.hasStreamEnded());
|
|
22
22
|
streamFromReactStreamingPackage.injectToStream(htmlFragment, { flush: true });
|
|
@@ -12,7 +12,7 @@ async function injectHtmlTagsToString(htmlParts, pageContext, injectFilter) {
|
|
|
12
12
|
let htmlString = htmlPartsToString(htmlParts, pageAssets);
|
|
13
13
|
htmlString = injectToHtmlBegin(htmlString, htmlTags);
|
|
14
14
|
htmlString = injectToHtmlEnd(htmlString, htmlTags);
|
|
15
|
-
assert(htmlTags.filter((snippet) => snippet.position === '
|
|
15
|
+
assert(htmlTags.filter((snippet) => snippet.position === 'HTML_STREAM').length === 0);
|
|
16
16
|
return htmlString;
|
|
17
17
|
}
|
|
18
18
|
function injectHtmlTagsToStream(pageContext, streamFromReactStreamingPackage, injectFilter) {
|
|
@@ -39,7 +39,7 @@ function injectHtmlTagsToStream(pageContext, streamFromReactStreamingPackage, in
|
|
|
39
39
|
if (streamFromReactStreamingPackage)
|
|
40
40
|
return null;
|
|
41
41
|
assert(htmlTags);
|
|
42
|
-
const tags = htmlTags.filter((h) => h.position === '
|
|
42
|
+
const tags = htmlTags.filter((h) => h.position === 'HTML_STREAM');
|
|
43
43
|
if (tags.length === 0)
|
|
44
44
|
return null;
|
|
45
45
|
const htmlFragment = joinHtmlTags(tags);
|
|
@@ -7,17 +7,17 @@ import { getGlobalContext } from '../globalContext.js';
|
|
|
7
7
|
import { getConfigValueRuntime } from '../../../shared/page-configs/getConfigValue.js';
|
|
8
8
|
function analyzePage(pageFilesAll, pageConfig, pageId) {
|
|
9
9
|
if (pageConfig) {
|
|
10
|
-
const {
|
|
10
|
+
const { isClientRuntimeLoaded, isClientRouting } = analyzeClientSide(pageConfig, pageFilesAll, pageId);
|
|
11
11
|
const clientEntries = [];
|
|
12
12
|
const clientFilePath = getConfigValueRuntime(pageConfig, 'client', 'string')?.value ?? null;
|
|
13
13
|
if (clientFilePath)
|
|
14
14
|
clientEntries.push(clientFilePath);
|
|
15
|
-
if (
|
|
15
|
+
if (isClientRuntimeLoaded)
|
|
16
16
|
clientEntries.push(getVikeClientEntry(isClientRouting));
|
|
17
17
|
const clientDependencies = [];
|
|
18
18
|
clientDependencies.push({
|
|
19
19
|
id: getVirtualFileIdPageConfigValuesAll(pageConfig.pageId, true),
|
|
20
|
-
onlyAssets:
|
|
20
|
+
onlyAssets: isClientRuntimeLoaded ? false : true,
|
|
21
21
|
eagerlyImported: false
|
|
22
22
|
});
|
|
23
23
|
// In production we inject the import of the server virtual module with ?extractAssets inside the client virtual module
|
|
@@ -53,7 +53,7 @@ function analyzePage(pageFilesAll, pageConfig, pageId) {
|
|
|
53
53
|
});
|
|
54
54
|
});
|
|
55
55
|
return {
|
|
56
|
-
isHtmlOnly: !
|
|
56
|
+
isHtmlOnly: !isClientRuntimeLoaded,
|
|
57
57
|
isClientRouting,
|
|
58
58
|
clientEntries,
|
|
59
59
|
clientDependencies,
|
|
@@ -2,14 +2,14 @@ export { assertArguments };
|
|
|
2
2
|
import { assert, assertUsage, assertWarning, hasProp, isObject } from '../utils.js';
|
|
3
3
|
import pc from '@brillout/picocolors';
|
|
4
4
|
function assertArguments(...args) {
|
|
5
|
-
const prefix =
|
|
5
|
+
const prefix = `${pc.code('renderPage(pageContextInit)')} (https://vike.dev/renderPage)`;
|
|
6
6
|
const pageContextInit = args[0];
|
|
7
7
|
assertUsage(pageContextInit !== undefined && pageContextInit !== null, prefix + ` argument ${pc.cyan('pageContextInit')} is missing`, { showStackTrace: true });
|
|
8
8
|
const len = args.length;
|
|
9
|
-
assertUsage(len === 1, `${prefix}
|
|
9
|
+
assertUsage(len === 1, `${prefix} called with ${len} arguments but renderPage() accepts only one argument.'`, {
|
|
10
10
|
showStackTrace: true
|
|
11
11
|
});
|
|
12
|
-
assertUsage(isObject(pageContextInit), `${prefix}
|
|
12
|
+
assertUsage(isObject(pageContextInit), `${prefix} called with ${pc.code(`typeof pageContextInit === ${JSON.stringify(typeof pageContextInit)}`)} but ${pc.code('pageContextInit')} should be an object.`, { showStackTrace: true });
|
|
13
13
|
// TODO/v1-release: remove
|
|
14
14
|
if ('url' in pageContextInit) {
|
|
15
15
|
assertWarning(false, '`pageContextInit.url` has been renamed to `pageContextInit.urlOriginal`: replace `renderPage({ url })` with `renderPage({ urlOriginal })`. (See https://vike.dev/migration/0.4.23 for more information.)', { showStackTrace: true, onlyOnce: true });
|
package/dist/esm/node/runtime/renderPage/{createHttpResponseObject.d.ts → createHttpResponse.d.ts}
RENAMED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { createHttpResponsePage };
|
|
2
2
|
export { createHttpResponsePageContextJson };
|
|
3
|
-
export {
|
|
3
|
+
export { createHttpResponseError };
|
|
4
|
+
export { createHttpResponseRedirect };
|
|
5
|
+
export { createHttpResponseFavicon404 };
|
|
4
6
|
export type { HttpResponse };
|
|
5
7
|
import type { GetPageAssets } from './getPageAssets.js';
|
|
6
8
|
import type { HtmlRender } from '../html/renderHtml.js';
|
|
@@ -9,6 +11,7 @@ import type { RenderHook } from './executeOnRenderHtmlHook.js';
|
|
|
9
11
|
import type { RedirectStatusCode, AbortStatusCode, UrlRedirect } from '../../../shared/route/abort.js';
|
|
10
12
|
import { HttpResponseBody } from './getHttpResponseBody.js';
|
|
11
13
|
import { type EarlyHint } from './getEarlyHints.js';
|
|
14
|
+
import type { PageFile } from '../../../shared/getPageFiles.js';
|
|
12
15
|
type HttpResponse = {
|
|
13
16
|
statusCode: 200 | 404 | 500 | RedirectStatusCode | AbortStatusCode;
|
|
14
17
|
headers: [string, string][];
|
|
@@ -16,13 +19,18 @@ type HttpResponse = {
|
|
|
16
19
|
/** **Deprecated**: use `headers` instead, see https://vike.dev/migration/0.4.134 */
|
|
17
20
|
contentType: 'application/json' | 'text/html;charset=utf-8';
|
|
18
21
|
} & HttpResponseBody;
|
|
19
|
-
declare function
|
|
22
|
+
declare function createHttpResponsePage(htmlRender: HtmlRender, renderHook: null | RenderHook, pageContext: {
|
|
20
23
|
_pageId: null | string;
|
|
21
24
|
is404: null | boolean;
|
|
22
25
|
errorWhileRendering: null | Error;
|
|
23
26
|
__getPageAssets: GetPageAssets;
|
|
24
27
|
_pageConfigs: PageConfigRuntime[];
|
|
25
28
|
abortStatusCode?: AbortStatusCode;
|
|
26
|
-
}): Promise<HttpResponse
|
|
29
|
+
}): Promise<HttpResponse>;
|
|
30
|
+
declare function createHttpResponseFavicon404(): HttpResponse;
|
|
31
|
+
declare function createHttpResponseError(pageContext: null | {
|
|
32
|
+
_pageFilesAll: PageFile[];
|
|
33
|
+
_pageConfigs: PageConfigRuntime[];
|
|
34
|
+
}): HttpResponse;
|
|
27
35
|
declare function createHttpResponsePageContextJson(pageContextSerialized: string): Promise<HttpResponse>;
|
|
28
|
-
declare function
|
|
36
|
+
declare function createHttpResponseRedirect({ url, statusCode }: UrlRedirect, urlLogical: string): HttpResponse;
|
package/dist/esm/node/runtime/renderPage/{createHttpResponseObject.js → createHttpResponse.js}
RENAMED
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { createHttpResponsePage };
|
|
2
2
|
export { createHttpResponsePageContextJson };
|
|
3
|
-
export {
|
|
3
|
+
export { createHttpResponseError };
|
|
4
|
+
export { createHttpResponseRedirect };
|
|
5
|
+
export { createHttpResponseFavicon404 };
|
|
4
6
|
import { assert, assertWarning } from '../utils.js';
|
|
5
|
-
import { isErrorPage } from '../../../shared/error-page.js';
|
|
7
|
+
import { getErrorPageId, isErrorPage } from '../../../shared/error-page.js';
|
|
6
8
|
import { getHttpResponseBody, getHttpResponseBodyStreamHandlers } from './getHttpResponseBody.js';
|
|
7
9
|
import { getEarlyHints } from './getEarlyHints.js';
|
|
8
|
-
import { getCacheControl } from './
|
|
9
|
-
import { assertNoInfiniteHttpRedirect } from './
|
|
10
|
-
async function
|
|
11
|
-
if (htmlRender === null) {
|
|
12
|
-
return null;
|
|
13
|
-
}
|
|
10
|
+
import { getCacheControl } from './createHttpResponse/getCacheControl.js';
|
|
11
|
+
import { assertNoInfiniteHttpRedirect } from './createHttpResponse/assertNoInfiniteHttpRedirect.js';
|
|
12
|
+
async function createHttpResponsePage(htmlRender, renderHook, pageContext) {
|
|
14
13
|
let statusCode = pageContext.abortStatusCode;
|
|
15
14
|
if (!statusCode) {
|
|
16
15
|
const isError = !pageContext._pageId || isErrorPage(pageContext._pageId, pageContext._pageConfigs);
|
|
@@ -33,13 +32,33 @@ async function createHttpResponseObject(htmlRender, renderHook, pageContext) {
|
|
|
33
32
|
if (cacheControl) {
|
|
34
33
|
headers.push(['Cache-Control', cacheControl]);
|
|
35
34
|
}
|
|
36
|
-
return
|
|
35
|
+
return createHttpResponse(statusCode, 'text/html;charset=utf-8', headers, htmlRender, earlyHints, renderHook);
|
|
36
|
+
}
|
|
37
|
+
function createHttpResponseFavicon404() {
|
|
38
|
+
const httpResponse = createHttpResponse(404, 'text/html;charset=utf-8', [], "<p>No favicon.ico found.</p><script>console.log('This HTTP response was generated by Vike.')</script>");
|
|
39
|
+
return httpResponse;
|
|
40
|
+
}
|
|
41
|
+
function createHttpResponseError(pageContext) {
|
|
42
|
+
const reason = (() => {
|
|
43
|
+
if (!pageContext) {
|
|
44
|
+
return 'no error page (https://vike.dev/error-page) could be rendered';
|
|
45
|
+
}
|
|
46
|
+
const errorPageId = getErrorPageId(pageContext._pageFilesAll, pageContext._pageConfigs);
|
|
47
|
+
if (errorPageId) {
|
|
48
|
+
return "the error page (https://vike.dev/error-page) couldn't be rendered (for example if an error occurred while rendering the error page)";
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
return 'no error page (https://vike.dev/error-page) is defined, make sure to create one';
|
|
52
|
+
}
|
|
53
|
+
})();
|
|
54
|
+
const httpResponse = createHttpResponse(500, 'text/html;charset=utf-8', [], `<p>An error occurred.</p><script>console.log(${JSON.stringify(`This HTTP response was generated by Vike. Vike returned this response because ${reason}.`)})</script>`);
|
|
55
|
+
return httpResponse;
|
|
37
56
|
}
|
|
38
57
|
async function createHttpResponsePageContextJson(pageContextSerialized) {
|
|
39
|
-
const httpResponse =
|
|
58
|
+
const httpResponse = createHttpResponse(200, 'application/json', [], pageContextSerialized, [], null);
|
|
40
59
|
return httpResponse;
|
|
41
60
|
}
|
|
42
|
-
function
|
|
61
|
+
function createHttpResponseRedirect({ url, statusCode },
|
|
43
62
|
// The URL we assume the redirect to be logically based on
|
|
44
63
|
urlLogical) {
|
|
45
64
|
assertNoInfiniteHttpRedirect(url, urlLogical);
|
|
@@ -47,12 +66,12 @@ urlLogical) {
|
|
|
47
66
|
assert(statusCode);
|
|
48
67
|
assert(300 <= statusCode && statusCode <= 399);
|
|
49
68
|
const headers = [['Location', url]];
|
|
50
|
-
return
|
|
69
|
+
return createHttpResponse(statusCode, 'text/html;charset=utf-8', headers,
|
|
51
70
|
// For bots / programmatic crawlig: show what's going on.
|
|
52
71
|
// For users: showing a blank page is probably better than a flickering text.
|
|
53
|
-
`<p style="display: none">Redirecting to ${url}</p>`);
|
|
72
|
+
`<p style="display: none">Redirecting to ${url}</p><script>console.log('This HTTP response was generated by Vike.')</script>`);
|
|
54
73
|
}
|
|
55
|
-
function
|
|
74
|
+
function createHttpResponse(statusCode, contentType, headers, htmlRender, earlyHints = [], renderHook = null) {
|
|
56
75
|
headers.push(['Content-Type', contentType]);
|
|
57
76
|
assert(renderHook || typeof htmlRender === 'string');
|
|
58
77
|
return {
|
|
@@ -17,9 +17,6 @@ async function executeOnRenderHtmlHook(pageContext) {
|
|
|
17
17
|
const { documentHtml, pageContextProvidedByRenderHook, pageContextPromise, injectFilter } = processHookReturnValue(hookReturnValue, renderHook);
|
|
18
18
|
Object.assign(pageContext, pageContextProvidedByRenderHook);
|
|
19
19
|
objectAssign(pageContext, { _pageContextPromise: pageContextPromise });
|
|
20
|
-
if (documentHtml === null || documentHtml === undefined) {
|
|
21
|
-
return { htmlRender: null, renderHook };
|
|
22
|
-
}
|
|
23
20
|
const onErrorWhileStreaming = (err) => {
|
|
24
21
|
// Should the stream inject the following?
|
|
25
22
|
// ```
|
|
@@ -75,7 +72,7 @@ function getRenderHook(pageContext) {
|
|
|
75
72
|
return hookFound;
|
|
76
73
|
}
|
|
77
74
|
function processHookReturnValue(hookReturnValue, renderHook) {
|
|
78
|
-
let documentHtml
|
|
75
|
+
let documentHtml;
|
|
79
76
|
let pageContextPromise = null;
|
|
80
77
|
let pageContextProvidedByRenderHook = null;
|
|
81
78
|
let injectFilter = null;
|
|
@@ -102,7 +99,8 @@ function processHookReturnValue(hookReturnValue, renderHook) {
|
|
|
102
99
|
assertUsage(isCallable(hookReturnValue.injectFilter), 'injectFilter should be a function');
|
|
103
100
|
injectFilter = hookReturnValue.injectFilter;
|
|
104
101
|
}
|
|
105
|
-
|
|
102
|
+
assertUsage(hookReturnValue.documentHtml, `${errPrefix} returned an object that is missing the ${pc.code('documentHtml')} property.`);
|
|
103
|
+
{
|
|
106
104
|
let val = hookReturnValue.documentHtml;
|
|
107
105
|
const errBegin = `${errPrefix} returned ${pc.cyan('{ documentHtml }')}, but ${pc.cyan('documentHtml')}`;
|
|
108
106
|
if (typeof val === 'string') {
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
export { handleErrorWithoutErrorPage };
|
|
2
2
|
import type { PageContextAfterRender } from './renderPageAlreadyRouted.js';
|
|
3
3
|
import type { PageConfigRuntime } from '../../../shared/page-configs/PageConfig.js';
|
|
4
|
+
import type { PageFile } from '../../../shared/getPageFiles.js';
|
|
4
5
|
declare function handleErrorWithoutErrorPage<PageContext extends {
|
|
5
6
|
isClientSideNavigation: boolean;
|
|
6
7
|
errorWhileRendering: null | Error;
|
|
7
8
|
is404: null | boolean;
|
|
8
9
|
_pageId: null;
|
|
10
|
+
_pageFilesAll: PageFile[];
|
|
9
11
|
_pageConfigs: PageConfigRuntime[];
|
|
10
12
|
urlOriginal: string;
|
|
11
13
|
}>(pageContext: PageContext): Promise<PageContext & PageContextAfterRender>;
|
|
@@ -2,7 +2,7 @@ export { handleErrorWithoutErrorPage };
|
|
|
2
2
|
import { stringify } from '@brillout/json-serializer/stringify';
|
|
3
3
|
import { getGlobalContext } from '../globalContext.js';
|
|
4
4
|
import { assert, assertWarning, objectAssign } from '../utils.js';
|
|
5
|
-
import {
|
|
5
|
+
import { createHttpResponsePage, createHttpResponseError } from './createHttpResponse.js';
|
|
6
6
|
import pc from '@brillout/picocolors';
|
|
7
7
|
// When the user hasn't defined _error.page.js
|
|
8
8
|
async function handleErrorWithoutErrorPage(pageContext) {
|
|
@@ -13,13 +13,14 @@ async function handleErrorWithoutErrorPage(pageContext) {
|
|
|
13
13
|
warnMissingErrorPage(isV1);
|
|
14
14
|
}
|
|
15
15
|
if (!pageContext.isClientSideNavigation) {
|
|
16
|
-
|
|
16
|
+
const httpResponse = createHttpResponseError(pageContext);
|
|
17
|
+
objectAssign(pageContext, { httpResponse });
|
|
17
18
|
return pageContext;
|
|
18
19
|
}
|
|
19
20
|
else {
|
|
20
21
|
const __getPageAssets = async () => [];
|
|
21
22
|
objectAssign(pageContext, { __getPageAssets });
|
|
22
|
-
const httpResponse = await
|
|
23
|
+
const httpResponse = await createHttpResponsePage(stringify({ serverSideError: true }), null, pageContext);
|
|
23
24
|
objectAssign(pageContext, { httpResponse });
|
|
24
25
|
return pageContext;
|
|
25
26
|
}
|
|
@@ -2,6 +2,6 @@ export { inferMediaType };
|
|
|
2
2
|
export type { MediaType };
|
|
3
3
|
type MediaType = null | {
|
|
4
4
|
assetType: 'image' | 'script' | 'font' | 'style' | 'audio' | 'video' | 'document' | 'fetch' | 'track' | 'worker' | 'embed' | 'object';
|
|
5
|
-
mediaType: 'text/javascript' | 'text/css' | 'image/jpeg' | 'image/png' | 'image/webp' | 'image/gif' | 'image/svg+xml' | 'font/ttf' | 'font/woff' | 'font/woff2' | 'video/mp4' | 'video/webm' | 'video/ogg' | 'video/mpeg' | 'video/x-msvideo' | 'video/quicktime' | 'audio/mpeg' | 'audio/wav' | 'audio/ogg' | 'audio/aac' | 'audio/midi' | 'audio/flac';
|
|
5
|
+
mediaType: 'text/javascript' | 'text/css' | 'image/avif' | 'image/jpeg' | 'image/png' | 'image/webp' | 'image/gif' | 'image/svg+xml' | 'font/ttf' | 'font/woff' | 'font/woff2' | 'video/mp4' | 'video/webm' | 'video/ogg' | 'video/mpeg' | 'video/x-msvideo' | 'video/quicktime' | 'audio/mpeg' | 'audio/wav' | 'audio/ogg' | 'audio/aac' | 'audio/midi' | 'audio/flac';
|
|
6
6
|
};
|
|
7
7
|
declare function inferMediaType(href: string): MediaType;
|
|
@@ -24,6 +24,9 @@ function inferMediaType(href) {
|
|
|
24
24
|
if (href.endsWith('.svg')) {
|
|
25
25
|
return { assetType: 'image', mediaType: 'image/svg+xml' };
|
|
26
26
|
}
|
|
27
|
+
if (href.endsWith('.avif')) {
|
|
28
|
+
return { assetType: 'image', mediaType: 'image/avif' };
|
|
29
|
+
}
|
|
27
30
|
// Fonts
|
|
28
31
|
if (href.endsWith('.ttf')) {
|
|
29
32
|
return { assetType: 'font', mediaType: 'font/ttf' };
|
|
@@ -1,2 +1,6 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
1
|
+
export { isConfigInvalid };
|
|
2
|
+
export { isConfigInvalid_set };
|
|
3
|
+
declare let isConfigInvalid: false | {
|
|
4
|
+
err: unknown;
|
|
5
|
+
};
|
|
6
|
+
declare const isConfigInvalid_set: (val: typeof isConfigInvalid) => void;
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
1
|
+
export { isConfigInvalid };
|
|
2
|
+
export { isConfigInvalid_set };
|
|
3
|
+
import { assert } from '../utils.js';
|
|
4
|
+
let isConfigInvalid;
|
|
5
|
+
const isConfigInvalid_set = (val) => {
|
|
6
|
+
assert(val === false || val.err);
|
|
3
7
|
isConfigInvalid = val;
|
|
4
8
|
};
|
|
@@ -8,13 +8,13 @@ export type { PageContextAfterRender };
|
|
|
8
8
|
export type { PageContextInitEnhanced };
|
|
9
9
|
import { type PageFile } from '../../../shared/getPageFiles.js';
|
|
10
10
|
import { type PageContextUrlInternal } from '../../../shared/getPageContextUrlComputed.js';
|
|
11
|
-
import { HttpResponse } from './
|
|
11
|
+
import { HttpResponse } from './createHttpResponse.js';
|
|
12
12
|
import { PageContext_loadUserFilesServerSide, type PageFiles } from './loadUserFilesServerSide.js';
|
|
13
13
|
import type { PageConfigRuntime, PageConfigGlobalRuntime } from '../../../shared/page-configs/PageConfig.js';
|
|
14
14
|
import { type PageRoutes } from '../../../shared/route/loadPageRoutes.js';
|
|
15
15
|
import type { Hook } from '../../../shared/hooks/getHook.js';
|
|
16
16
|
type PageContextAfterRender = {
|
|
17
|
-
httpResponse:
|
|
17
|
+
httpResponse: HttpResponse;
|
|
18
18
|
errorWhileRendering: null | Error;
|
|
19
19
|
};
|
|
20
20
|
declare function renderPageAlreadyRouted<PageContext extends {
|
|
@@ -10,7 +10,7 @@ import { assert, assertUsage, assertWarning, hasProp, normalizeHeaders, objectAs
|
|
|
10
10
|
import { serializePageContextClientSide } from '../html/serializePageContextClientSide.js';
|
|
11
11
|
import { getPageContextUrlComputed } from '../../../shared/getPageContextUrlComputed.js';
|
|
12
12
|
import { getGlobalContext } from '../globalContext.js';
|
|
13
|
-
import {
|
|
13
|
+
import { createHttpResponsePage, createHttpResponsePageContextJson } from './createHttpResponse.js';
|
|
14
14
|
import { loadUserFilesServerSide } from './loadUserFilesServerSide.js';
|
|
15
15
|
import { executeOnRenderHtmlHook } from './executeOnRenderHtmlHook.js';
|
|
16
16
|
import { executeOnBeforeRenderAndDataHooks } from './executeOnBeforeRenderAndDataHooks.js';
|
|
@@ -56,16 +56,10 @@ async function renderPageAlreadyRouted(pageContext) {
|
|
|
56
56
|
return pageContext;
|
|
57
57
|
}
|
|
58
58
|
const renderHookResult = await executeOnRenderHtmlHook(pageContext);
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
else {
|
|
64
|
-
const { htmlRender, renderHook } = renderHookResult;
|
|
65
|
-
const httpResponse = await createHttpResponseObject(htmlRender, renderHook, pageContext);
|
|
66
|
-
objectAssign(pageContext, { httpResponse });
|
|
67
|
-
return pageContext;
|
|
68
|
-
}
|
|
59
|
+
const { htmlRender, renderHook } = renderHookResult;
|
|
60
|
+
const httpResponse = await createHttpResponsePage(htmlRender, renderHook, pageContext);
|
|
61
|
+
objectAssign(pageContext, { httpResponse });
|
|
62
|
+
return pageContext;
|
|
69
63
|
}
|
|
70
64
|
async function prerenderPage(pageContext) {
|
|
71
65
|
objectAssign(pageContext, {
|