vike 0.4.171 → 0.4.172-commit-ea2b76c
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/plugins/buildConfig.js +3 -4
- package/dist/cjs/node/plugin/plugins/devConfig/determineOptimizeDeps.js +18 -15
- package/dist/cjs/node/plugin/plugins/devConfig/index.js +2 -1
- package/dist/cjs/node/plugin/plugins/envVars.js +2 -1
- package/dist/cjs/node/plugin/plugins/extractAssetsPlugin.js +1 -1
- package/dist/cjs/node/plugin/plugins/importUserCode/{generateEagerImport.js → addImportStatement.js} +8 -10
- package/dist/cjs/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.js +0 -1
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +3 -3
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js +17 -6
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.js +2 -2
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +31 -75
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js +4 -43
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigs.js +9 -50
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/isRuntimeEnvMatch.js +6 -0
- package/dist/cjs/node/plugin/shared/addSsrMiddleware.js +17 -2
- package/dist/cjs/node/prerender/runPrerender.js +35 -15
- package/dist/cjs/node/prerender/utils.js +1 -0
- package/dist/cjs/node/runtime/html/injectAssets/getHtmlTags.js +3 -3
- package/dist/cjs/node/runtime/html/injectAssets/getViteDevScripts.js +2 -1
- package/dist/cjs/node/runtime/html/injectAssets/mergeScriptTags.js +2 -8
- package/dist/cjs/node/runtime/html/renderHtml.js +19 -20
- package/dist/cjs/node/runtime/html/stream.js +9 -9
- package/dist/cjs/node/runtime/renderPage/analyzePage.js +9 -7
- package/dist/cjs/node/runtime/renderPage/createHttpResponseObject/getCacheControl.js +1 -1
- package/dist/cjs/node/runtime/renderPage/executeOnBeforeRenderAndDataHooks.js +2 -2
- package/dist/cjs/node/runtime/renderPage/executeOnRenderHtmlHook.js +8 -8
- package/dist/cjs/node/runtime/renderPage/getHttpResponseBody.js +2 -2
- package/dist/cjs/node/runtime/renderPage/loadUserFilesServerSide.js +4 -5
- package/dist/cjs/node/runtime/renderPage/logErrorHint.js +91 -282
- package/dist/cjs/node/runtime/renderPage/preparePageContextForUserConsumptionServerSide.js +2 -2
- package/dist/cjs/node/runtime/renderPage/renderPageAlreadyRouted.js +30 -10
- package/dist/cjs/node/runtime/renderPage.js +24 -17
- package/dist/cjs/node/runtime/utils.js +2 -0
- package/dist/cjs/node/shared/assertV1Design.js +3 -4
- package/dist/cjs/shared/getPageContext.js +5 -0
- package/dist/cjs/shared/{addUrlComputedProps.js → getPageContextUrlComputed.js} +52 -42
- package/dist/cjs/shared/getPageFiles/analyzeClientSide.js +2 -2
- package/dist/cjs/shared/getPageFiles/getExports.js +49 -1
- package/dist/cjs/shared/getPageFiles/parseGlobResults.js +15 -8
- package/dist/cjs/shared/hooks/executeHook.js +22 -3
- package/dist/cjs/shared/hooks/getHook.js +2 -2
- package/dist/cjs/shared/page-configs/getConfigValue.js +14 -17
- package/dist/cjs/shared/page-configs/getConfigValueBuildTime.js +70 -0
- package/dist/cjs/shared/page-configs/loadConfigValues.js +3 -12
- package/dist/cjs/shared/page-configs/serialize/assertPageConfigsSerialized.js +0 -18
- package/dist/cjs/shared/page-configs/serialize/parsePageConfigs.js +110 -16
- package/dist/cjs/shared/page-configs/serialize/serializeConfigValues.js +198 -0
- package/dist/cjs/shared/route/executeGuardHook.js +1 -1
- package/dist/cjs/shared/route/executeOnBeforeRouteHook.js +1 -1
- package/dist/cjs/shared/route/index.js +2 -2
- package/dist/cjs/shared/route/loadPageRoutes.js +2 -2
- package/dist/cjs/shared/route/resolveRouteFunction.js +2 -2
- package/dist/cjs/shared/sortPageContext.js +4 -8
- package/dist/cjs/shared/utils.js +2 -0
- package/dist/cjs/utils/assert.js +1 -1
- package/dist/cjs/utils/assertNodeVersion.js +1 -1
- package/dist/cjs/utils/changeEnumerable.js +9 -0
- package/dist/cjs/utils/escapeHtml.js +14 -0
- package/dist/cjs/utils/getPropAccessNotation.js +1 -4
- package/dist/cjs/utils/hasProp.js +5 -7
- package/dist/cjs/utils/normalizeHeaders.js +13 -0
- package/dist/cjs/utils/objectAssign.js +1 -1
- package/dist/cjs/utils/objectDefineProperty.js +8 -0
- package/dist/cjs/utils/objectKeys.js +8 -4
- package/dist/cjs/utils/projectInfo.js +1 -1
- package/dist/esm/client/client-routing-runtime/createPageContext.d.ts +6 -4
- package/dist/esm/client/client-routing-runtime/createPageContext.js +4 -3
- package/dist/esm/client/client-routing-runtime/getPageContextFromHooks.js +16 -12
- package/dist/esm/client/client-routing-runtime/installClientRouter.js +18 -10
- package/dist/esm/client/client-routing-runtime/renderPageClientSide.js +3 -3
- package/dist/esm/client/server-routing-runtime/getPageContext.d.ts +4 -4
- package/dist/esm/client/server-routing-runtime/utils.d.ts +1 -0
- package/dist/esm/client/server-routing-runtime/utils.js +1 -0
- package/dist/esm/client/shared/executeOnRenderClientHook.js +1 -1
- package/dist/esm/client/shared/getPageContextProxyForUser.d.ts +3 -2
- package/dist/esm/client/shared/getPageContextProxyForUser.js +35 -48
- package/dist/esm/client/shared/loadUserFilesClientSide.js +4 -4
- package/dist/esm/node/plugin/plugins/buildConfig.js +3 -4
- package/dist/esm/node/plugin/plugins/devConfig/determineOptimizeDeps.js +18 -15
- package/dist/esm/node/plugin/plugins/devConfig/index.js +2 -1
- package/dist/esm/node/plugin/plugins/envVars.js +2 -1
- package/dist/esm/node/plugin/plugins/extractAssetsPlugin.js +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/addImportStatement.d.ts +14 -0
- package/dist/esm/node/plugin/plugins/importUserCode/{generateEagerImport.js → addImportStatement.js} +7 -9
- package/dist/esm/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.js +0 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.d.ts +2 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +3 -3
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js +18 -7
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.js +2 -2
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +31 -75
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js +4 -43
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigs.js +9 -50
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/isRuntimeEnvMatch.d.ts +1 -0
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/isRuntimeEnvMatch.js +6 -0
- package/dist/esm/node/plugin/shared/addSsrMiddleware.js +14 -2
- package/dist/esm/node/prerender/runPrerender.js +37 -17
- package/dist/esm/node/prerender/utils.d.ts +1 -0
- package/dist/esm/node/prerender/utils.js +1 -0
- package/dist/esm/node/runtime/html/injectAssets/getHtmlTags.js +3 -3
- package/dist/esm/node/runtime/html/injectAssets/getViteDevScripts.js +3 -2
- package/dist/esm/node/runtime/html/injectAssets/mergeScriptTags.d.ts +1 -1
- package/dist/esm/node/runtime/html/injectAssets/mergeScriptTags.js +2 -8
- package/dist/esm/node/runtime/html/renderHtml.js +19 -20
- package/dist/esm/node/runtime/html/stream.d.ts +1 -1
- package/dist/esm/node/runtime/html/stream.js +9 -9
- package/dist/esm/node/runtime/renderPage/analyzePage.js +9 -7
- package/dist/esm/node/runtime/renderPage/createHttpResponseObject/getCacheControl.js +2 -2
- package/dist/esm/node/runtime/renderPage/executeOnBeforeRenderAndDataHooks.js +2 -2
- package/dist/esm/node/runtime/renderPage/executeOnRenderHtmlHook.js +8 -8
- package/dist/esm/node/runtime/renderPage/getHttpResponseBody.js +2 -2
- package/dist/esm/node/runtime/renderPage/loadUserFilesServerSide.d.ts +1 -6
- package/dist/esm/node/runtime/renderPage/loadUserFilesServerSide.js +4 -5
- package/dist/esm/node/runtime/renderPage/logErrorHint.d.ts +2 -6
- package/dist/esm/node/runtime/renderPage/logErrorHint.js +92 -283
- package/dist/esm/node/runtime/renderPage/preparePageContextForUserConsumptionServerSide.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/preparePageContextForUserConsumptionServerSide.js +2 -2
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.d.ts +65 -39
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.js +31 -11
- package/dist/esm/node/runtime/renderPage.js +24 -17
- package/dist/esm/node/runtime/utils.d.ts +2 -0
- package/dist/esm/node/runtime/utils.js +2 -0
- package/dist/esm/node/shared/assertV1Design.d.ts +2 -2
- package/dist/esm/node/shared/assertV1Design.js +3 -4
- package/dist/esm/shared/VikeNamespace.d.ts +9 -0
- package/dist/esm/shared/getPageContext.d.ts +1 -0
- package/dist/esm/shared/getPageContext.js +1 -0
- package/dist/esm/shared/{addUrlComputedProps.d.ts → getPageContextUrlComputed.d.ts} +23 -21
- package/dist/esm/shared/{addUrlComputedProps.js → getPageContextUrlComputed.js} +52 -42
- package/dist/esm/shared/getPageFiles/analyzeClientSide.js +3 -3
- package/dist/esm/shared/getPageFiles/getExports.d.ts +36 -0
- package/dist/esm/shared/getPageFiles/getExports.js +50 -2
- package/dist/esm/shared/getPageFiles/parseGlobResults.js +14 -7
- package/dist/esm/shared/hooks/executeHook.d.ts +10 -1
- package/dist/esm/shared/hooks/executeHook.js +21 -2
- package/dist/esm/shared/hooks/getHook.d.ts +2 -2
- package/dist/esm/shared/hooks/getHook.js +3 -3
- package/dist/esm/shared/page-configs/Config/PageContextConfig.d.ts +2 -2
- package/dist/esm/shared/page-configs/PageConfig.d.ts +14 -8
- package/dist/esm/shared/page-configs/getConfigValue.d.ts +12 -12
- package/dist/esm/shared/page-configs/getConfigValue.js +13 -16
- package/dist/esm/shared/page-configs/getConfigValueBuildTime.d.ts +9 -0
- package/dist/esm/shared/page-configs/getConfigValueBuildTime.js +67 -0
- package/dist/esm/shared/page-configs/loadConfigValues.js +3 -12
- package/dist/esm/shared/page-configs/serialize/PageConfigSerialized.d.ts +17 -21
- package/dist/esm/shared/page-configs/serialize/assertPageConfigsSerialized.d.ts +1 -5
- package/dist/esm/shared/page-configs/serialize/assertPageConfigsSerialized.js +1 -16
- package/dist/esm/shared/page-configs/serialize/parsePageConfigs.d.ts +4 -1
- package/dist/esm/shared/page-configs/serialize/parsePageConfigs.js +109 -15
- package/dist/esm/shared/page-configs/serialize/serializeConfigValues.d.ts +5 -0
- package/dist/esm/shared/page-configs/serialize/serializeConfigValues.js +192 -0
- package/dist/esm/shared/route/executeGuardHook.js +1 -1
- package/dist/esm/shared/route/executeOnBeforeRouteHook.js +1 -1
- package/dist/esm/shared/route/index.d.ts +3 -3
- package/dist/esm/shared/route/index.js +2 -2
- package/dist/esm/shared/route/loadPageRoutes.js +3 -3
- package/dist/esm/shared/route/resolveRouteFunction.d.ts +2 -2
- package/dist/esm/shared/route/resolveRouteFunction.js +2 -2
- package/dist/esm/shared/sortPageContext.js +4 -8
- package/dist/esm/shared/types.d.ts +32 -6
- package/dist/esm/shared/utils.d.ts +2 -0
- package/dist/esm/shared/utils.js +2 -0
- package/dist/esm/types/index.d.ts +1 -1
- package/dist/esm/utils/assert.js +1 -1
- package/dist/esm/utils/assertNodeVersion.js +1 -1
- package/dist/esm/utils/changeEnumerable.d.ts +2 -0
- package/dist/esm/utils/changeEnumerable.js +5 -0
- package/dist/esm/utils/escapeHtml.d.ts +1 -0
- package/dist/esm/utils/escapeHtml.js +10 -0
- package/dist/esm/utils/getPropAccessNotation.d.ts +1 -2
- package/dist/esm/utils/getPropAccessNotation.js +2 -6
- package/dist/esm/utils/hasProp.d.ts +4 -13
- package/dist/esm/utils/hasProp.js +5 -7
- package/dist/esm/utils/normalizeHeaders.d.ts +1 -0
- package/dist/esm/utils/normalizeHeaders.js +9 -0
- package/dist/esm/utils/objectAssign.js +1 -1
- package/dist/esm/utils/objectDefineProperty.d.ts +4 -0
- package/dist/esm/utils/objectDefineProperty.js +4 -0
- package/dist/esm/utils/objectKeys.d.ts +1 -3
- package/dist/esm/utils/objectKeys.js +8 -4
- package/dist/esm/utils/projectInfo.d.ts +2 -2
- package/dist/esm/utils/projectInfo.js +1 -1
- package/package.json +21 -12
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getConfigValuesSerialized.js +0 -76
- package/dist/cjs/node/plugin/shared/getConfigValueSourcesNotOverriden.js +0 -14
- package/dist/cjs/node/shared/getClientEntry.js +0 -12
- package/dist/cjs/shared/page-configs/serialize/parseConfigValuesImported.js +0 -85
- package/dist/cjs/shared/page-configs/serialize/parseConfigValuesSerialized.js +0 -24
- package/dist/cjs/shared/page-configs/serialize/serializeConfigValue.js +0 -50
- package/dist/esm/node/plugin/plugins/importUserCode/generateEagerImport.d.ts +0 -16
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getConfigValuesSerialized.d.ts +0 -5
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getConfigValuesSerialized.js +0 -70
- package/dist/esm/node/plugin/shared/getConfigValueSourcesNotOverriden.d.ts +0 -5
- package/dist/esm/node/plugin/shared/getConfigValueSourcesNotOverriden.js +0 -11
- package/dist/esm/node/shared/getClientEntry.d.ts +0 -3
- package/dist/esm/node/shared/getClientEntry.js +0 -9
- package/dist/esm/shared/page-configs/serialize/parseConfigValuesImported.d.ts +0 -4
- package/dist/esm/shared/page-configs/serialize/parseConfigValuesImported.js +0 -82
- package/dist/esm/shared/page-configs/serialize/parseConfigValuesSerialized.d.ts +0 -4
- package/dist/esm/shared/page-configs/serialize/parseConfigValuesSerialized.js +0 -21
- package/dist/esm/shared/page-configs/serialize/serializeConfigValue.d.ts +0 -8
- package/dist/esm/shared/page-configs/serialize/serializeConfigValue.js +0 -47
|
@@ -5,7 +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, isPlainObject, handleNodeEnv_prerender, pLimit, assertPathFilesystemAbsolute, isArray } from './utils.js';
|
|
8
|
+
import { assert, assertUsage, assertWarning, hasProp, projectInfo, objectAssign, isObjectWithKeys, isCallable, getOutDirs, isPropertyGetter, assertPosixPath, urlToFile, isPlainObject, handleNodeEnv_prerender, pLimit, assertPathFilesystemAbsolute, isArray, changeEnumerable } from './utils.js';
|
|
9
9
|
import { prerenderPage, prerender404Page, getRenderContext, getPageContextInitEnhanced } from '../runtime/renderPage/renderPageAlreadyRouted.js';
|
|
10
10
|
import pc from '@brillout/picocolors';
|
|
11
11
|
import { cpus } from 'os';
|
|
@@ -16,10 +16,10 @@ import { getPageFilesServerSide } from '../../shared/getPageFiles.js';
|
|
|
16
16
|
import { getPageContextRequestUrl } from '../../shared/getPageContextRequestUrl.js';
|
|
17
17
|
import { getUrlFromRouteString } from '../../shared/route/resolveRouteString.js';
|
|
18
18
|
import { getConfigValueFilePathToShowToUser } from '../../shared/page-configs/helpers.js';
|
|
19
|
-
import {
|
|
19
|
+
import { getConfigValueRuntime } from '../../shared/page-configs/getConfigValue.js';
|
|
20
20
|
import { loadConfigValues } from '../../shared/page-configs/loadConfigValues.js';
|
|
21
21
|
import { isErrorPage } from '../../shared/error-page.js';
|
|
22
|
-
import {
|
|
22
|
+
import { getPageContextUrlComputed } from '../../shared/getPageContextUrlComputed.js';
|
|
23
23
|
import { isAbortError } from '../../shared/route/abort.js';
|
|
24
24
|
import { loadUserFilesServerSide } from '../runtime/renderPage/loadUserFilesServerSide.js';
|
|
25
25
|
import { getHookFromPageConfig, getHookFromPageConfigGlobal, getHookTimeoutDefault, setIsPrerenderering } from '../../shared/hooks/getHook.js';
|
|
@@ -27,6 +27,7 @@ import { noRouteMatch } from '../../shared/route/noRouteMatch.js';
|
|
|
27
27
|
import { getVikeConfig } from '../plugin/plugins/importUserCode/v1-design/getVikeConfig.js';
|
|
28
28
|
import { logErrorHint } from '../runtime/renderPage/logErrorHint.js';
|
|
29
29
|
import { executeHook, isUserHookError } from '../../shared/hooks/executeHook.js';
|
|
30
|
+
import { getConfigValueBuildTime } from '../../shared/page-configs/getConfigValueBuildTime.js';
|
|
30
31
|
async function runPrerenderFromAPI(options = {}) {
|
|
31
32
|
await runPrerender(options, 'prerender()');
|
|
32
33
|
// - 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.
|
|
@@ -114,7 +115,7 @@ async function collectDoNoPrerenderList(renderContext, pageConfigs, doNotPrerend
|
|
|
114
115
|
// V1 design
|
|
115
116
|
pageConfigs.forEach((pageConfig) => {
|
|
116
117
|
const configName = 'prerender';
|
|
117
|
-
const configValue =
|
|
118
|
+
const configValue = getConfigValueBuildTime(pageConfig, configName, 'boolean');
|
|
118
119
|
if (configValue?.value === false) {
|
|
119
120
|
const configValueFilePathToShowToUser = getConfigValueFilePathToShowToUser(configValue.definedAtData);
|
|
120
121
|
assert(configValueFilePathToShowToUser);
|
|
@@ -217,7 +218,7 @@ async function callOnBeforePrerenderStartHooks(prerenderContext, renderContext,
|
|
|
217
218
|
if (doNotPrerenderList.find((p) => p.pageId === pageId)) {
|
|
218
219
|
return;
|
|
219
220
|
}
|
|
220
|
-
const prerenderResult = await executeHook(() => hookFn(), { hookName, hookFilePath, hookTimeout });
|
|
221
|
+
const prerenderResult = await executeHook(() => hookFn(), { hookName, hookFilePath, hookTimeout }, null);
|
|
221
222
|
const result = normalizeOnPrerenderHookResult(prerenderResult, hookFilePath, hookName);
|
|
222
223
|
result.forEach(({ url, pageContext }) => {
|
|
223
224
|
{
|
|
@@ -240,9 +241,9 @@ async function callOnBeforePrerenderStartHooks(prerenderContext, renderContext,
|
|
|
240
241
|
prerenderContext.pageContexts.push(pageContextNew);
|
|
241
242
|
if (pageContext) {
|
|
242
243
|
objectAssign(pageContextNew, {
|
|
243
|
-
_pageContextAlreadyProvidedByOnPrerenderHook: true
|
|
244
|
-
...pageContext
|
|
244
|
+
_pageContextAlreadyProvidedByOnPrerenderHook: true
|
|
245
245
|
});
|
|
246
|
+
objectAssign(pageContextNew, pageContext);
|
|
246
247
|
}
|
|
247
248
|
});
|
|
248
249
|
})));
|
|
@@ -300,14 +301,11 @@ function createPageContext(urlOriginal, renderContext, prerenderContext) {
|
|
|
300
301
|
_prerenderContext: prerenderContext
|
|
301
302
|
};
|
|
302
303
|
const pageContextInit = {
|
|
303
|
-
urlOriginal
|
|
304
|
-
...prerenderContext.pageContextInit
|
|
304
|
+
urlOriginal
|
|
305
305
|
};
|
|
306
|
+
objectAssign(pageContextInit, prerenderContext.pageContextInit);
|
|
306
307
|
{
|
|
307
|
-
const pageContextInitEnhanced = getPageContextInitEnhanced(pageContextInit, renderContext
|
|
308
|
-
// We set `enumerable` to `false` to avoid computed URL properties from being iterated & copied in a onPrerenderStart() hook, e.g. /examples/i18n/
|
|
309
|
-
urlComputedPropsNonEnumerable: true
|
|
310
|
-
});
|
|
308
|
+
const pageContextInitEnhanced = getPageContextInitEnhanced(pageContextInit, renderContext);
|
|
311
309
|
objectAssign(pageContext, pageContextInitEnhanced);
|
|
312
310
|
}
|
|
313
311
|
return pageContext;
|
|
@@ -382,6 +380,8 @@ async function callOnPrerenderStartHook(prerenderContext, renderContext) {
|
|
|
382
380
|
pageContext._urlOriginalBeforeHook = pageContext.urlOriginal;
|
|
383
381
|
});
|
|
384
382
|
const docLink = 'https://vike.dev/i18n#pre-rendering';
|
|
383
|
+
// Set `enumerable` to `false` to avoid computed URL properties from being iterated & copied in onPrerenderStart() hook, e.g. /examples/i18n/
|
|
384
|
+
const { restoreEnumerable, addPageContextComputedUrl } = makePageContextComputedUrlNonEnumerable(prerenderContext.pageContexts);
|
|
385
385
|
let result = await executeHook(() => hookFn({
|
|
386
386
|
pageContexts: prerenderContext.pageContexts,
|
|
387
387
|
// TODO/v1-release: remove warning
|
|
@@ -392,7 +392,8 @@ async function callOnPrerenderStartHook(prerenderContext, renderContext) {
|
|
|
392
392
|
});
|
|
393
393
|
return prerenderContext.pageContexts;
|
|
394
394
|
}
|
|
395
|
-
}), onPrerenderStartHook);
|
|
395
|
+
}), onPrerenderStartHook, null);
|
|
396
|
+
restoreEnumerable();
|
|
396
397
|
if (result === null || result === undefined) {
|
|
397
398
|
return;
|
|
398
399
|
}
|
|
@@ -430,9 +431,8 @@ async function callOnPrerenderStartHook(prerenderContext, renderContext) {
|
|
|
430
431
|
hookName
|
|
431
432
|
};
|
|
432
433
|
}
|
|
433
|
-
// Restore as URL computed props are lost when user makes a pageContext copy
|
|
434
|
-
addUrlComputedProps(pageContext);
|
|
435
434
|
});
|
|
435
|
+
addPageContextComputedUrl(prerenderContext.pageContexts);
|
|
436
436
|
}
|
|
437
437
|
async function routeAndPrerender(prerenderContext, concurrencyLimit, onComplete) {
|
|
438
438
|
const globalContext = getGlobalContext();
|
|
@@ -474,7 +474,7 @@ async function routeAndPrerender(prerenderContext, concurrencyLimit, onComplete)
|
|
|
474
474
|
if (pageContext._pageConfigs.length > 0) {
|
|
475
475
|
const pageConfig = pageContext._pageConfigs.find((p) => p.pageId === pageId);
|
|
476
476
|
assert(pageConfig);
|
|
477
|
-
usesClientRouter =
|
|
477
|
+
usesClientRouter = getConfigValueRuntime(pageConfig, 'clientRouting', 'boolean')?.value ?? false;
|
|
478
478
|
}
|
|
479
479
|
else {
|
|
480
480
|
usesClientRouter = globalContext.pluginManifest.usesClientRouter;
|
|
@@ -714,3 +714,23 @@ function assertIsNotAbort(err, urlOr404) {
|
|
|
714
714
|
assert(abortCall);
|
|
715
715
|
assertUsage(false, `${pc.cyan(abortCall)} thrown${thrownBy} while pre-rendering ${urlOr404} but ${pc.cyan(abortCaller)} isn't supported for pre-rendered pages`);
|
|
716
716
|
}
|
|
717
|
+
function makePageContextComputedUrlNonEnumerable(pageContexts) {
|
|
718
|
+
change(false);
|
|
719
|
+
return { restoreEnumerable, addPageContextComputedUrl };
|
|
720
|
+
function restoreEnumerable() {
|
|
721
|
+
change(true);
|
|
722
|
+
}
|
|
723
|
+
function addPageContextComputedUrl(pageContexts) {
|
|
724
|
+
// Add URL computed props to the user-generated pageContext copies
|
|
725
|
+
pageContexts.forEach((pageContext) => {
|
|
726
|
+
const pageContextUrlComputed = getPageContextUrlComputed(pageContext);
|
|
727
|
+
objectAssign(pageContext, pageContextUrlComputed);
|
|
728
|
+
});
|
|
729
|
+
}
|
|
730
|
+
function change(enumerable) {
|
|
731
|
+
pageContexts.forEach((pageContext) => {
|
|
732
|
+
changeEnumerable(pageContext, 'urlPathname', enumerable);
|
|
733
|
+
changeEnumerable(pageContext, 'urlParsed', enumerable);
|
|
734
|
+
});
|
|
735
|
+
}
|
|
736
|
+
}
|
|
@@ -107,7 +107,7 @@ async function getHtmlTags(pageContext, injectToStream, injectFilter) {
|
|
|
107
107
|
});
|
|
108
108
|
}
|
|
109
109
|
// The JavaScript entry <script> tag
|
|
110
|
-
const scriptEntry = await mergeScriptEntries(pageAssets
|
|
110
|
+
const scriptEntry = await mergeScriptEntries(pageAssets);
|
|
111
111
|
if (scriptEntry) {
|
|
112
112
|
htmlTags.push({
|
|
113
113
|
htmlTag: scriptEntry,
|
|
@@ -128,11 +128,11 @@ async function getHtmlTags(pageContext, injectToStream, injectFilter) {
|
|
|
128
128
|
});
|
|
129
129
|
return htmlTags;
|
|
130
130
|
}
|
|
131
|
-
async function mergeScriptEntries(pageAssets
|
|
131
|
+
async function mergeScriptEntries(pageAssets) {
|
|
132
132
|
const scriptEntries = pageAssets.filter((pageAsset) => pageAsset.isEntry && pageAsset.assetType === 'script');
|
|
133
133
|
const viteScripts = await getViteDevScripts();
|
|
134
134
|
const scriptTagsHtml = `${viteScripts}${scriptEntries.map((asset) => inferAssetTag(asset)).join('')}`;
|
|
135
|
-
const scriptTag = mergeScriptTags(scriptTagsHtml
|
|
135
|
+
const scriptTag = mergeScriptTags(scriptTagsHtml);
|
|
136
136
|
return scriptTag;
|
|
137
137
|
}
|
|
138
138
|
function getPageContextJsonScriptTag(pageContext) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { getViteDevScripts };
|
|
2
2
|
import { getGlobalContext } from '../../globalContext.js';
|
|
3
|
-
import { assert, assertUsage } from '../../utils.js';
|
|
3
|
+
import { assert, assertUsage, assertWarning } from '../../utils.js';
|
|
4
4
|
import pc from '@brillout/picocolors';
|
|
5
5
|
async function getViteDevScripts() {
|
|
6
6
|
const globalContext = getGlobalContext();
|
|
@@ -16,7 +16,8 @@ async function getViteDevScripts() {
|
|
|
16
16
|
assertUsage(!fakeHtml.startsWith(fakeHtmlBegin.replace(' ', '')), 'Vite plugins that minify the HTML are not supported by vike, see https://github.com/vikejs/vike/issues/224');
|
|
17
17
|
assertUsage(fakeHtml.startsWith(fakeHtmlBegin) && fakeHtml.endsWith(fakeHtmlEnd), 'You are using a Vite Plugin that transforms the HTML in a way that conflicts with vike. Create a new GitHub ticket to discuss a solution.');
|
|
18
18
|
const viteInjection = fakeHtml.slice(fakeHtmlBegin.length, -1 * fakeHtmlEnd.length);
|
|
19
|
-
assert(viteInjection.includes('script')
|
|
19
|
+
assert(viteInjection.includes('script'));
|
|
20
|
+
assertWarning(!viteInjection.includes('import('), 'Unexpected Vite HMR code. Reach out to a Vike maintainer on GitHub.', { onlyOnce: true });
|
|
20
21
|
const scriptTags = viteInjection;
|
|
21
22
|
return scriptTags;
|
|
22
23
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { mergeScriptTags };
|
|
2
|
-
declare function mergeScriptTags(scriptTagsHtml: string
|
|
2
|
+
declare function mergeScriptTags(scriptTagsHtml: string): string;
|
|
@@ -4,7 +4,7 @@ import { scriptAttrs } from './inferHtmlTags.js';
|
|
|
4
4
|
const scriptRE = /(<script\b(?:\s[^>]*>|>))(.*?)<\/script>/gims;
|
|
5
5
|
const srcRE = /\bsrc\s*=\s*(?:"([^"]+)"|'([^']+)'|([^\s'">]+))/im;
|
|
6
6
|
const typeRE = /\btype\s*=\s*(?:"([^"]+)"|'([^']+)'|([^\s'">]+))/im;
|
|
7
|
-
function mergeScriptTags(scriptTagsHtml
|
|
7
|
+
function mergeScriptTags(scriptTagsHtml) {
|
|
8
8
|
let scriptTag = '';
|
|
9
9
|
const scripts = parseScripts(scriptTagsHtml);
|
|
10
10
|
// We need to merge module scripts to ensure execution order
|
|
@@ -19,13 +19,7 @@ function mergeScriptTags(scriptTagsHtml, isProduction) {
|
|
|
19
19
|
const hasInnerHtml = !!innerHtml.trim();
|
|
20
20
|
if (src) {
|
|
21
21
|
assert(!hasInnerHtml);
|
|
22
|
-
|
|
23
|
-
contents.push(`import ${JSON.stringify(src)};`);
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
// Ensure HMR preamble code is executed before client entries
|
|
27
|
-
contents.push(`import(${JSON.stringify(src)});`);
|
|
28
|
-
}
|
|
22
|
+
contents.push(`import ${JSON.stringify(src)};`);
|
|
29
23
|
}
|
|
30
24
|
else if (hasInnerHtml) {
|
|
31
25
|
innerHtml = innerHtml.split('\n').filter(Boolean).join('\n');
|
|
@@ -3,7 +3,7 @@ export { dangerouslySkipEscape };
|
|
|
3
3
|
export { renderDocumentHtml };
|
|
4
4
|
export { isDocumentHtml };
|
|
5
5
|
export { getHtmlString };
|
|
6
|
-
import { assert, assertUsage, assertWarning, checkType, hasProp, isHtml, isPromise, objectAssign } from '../utils.js';
|
|
6
|
+
import { assert, assertUsage, assertWarning, checkType, escapeHtml, hasProp, isHtml, isPromise, objectAssign } from '../utils.js';
|
|
7
7
|
import { injectHtmlTagsToString, injectHtmlTagsToStream } from './injectAssets.js';
|
|
8
8
|
import { processStream, isStream, streamToString } from './stream.js';
|
|
9
9
|
import { isStreamReactStreaming } from './stream/react-streaming.js';
|
|
@@ -165,31 +165,40 @@ async function renderTemplate(templateContent, pageContext) {
|
|
|
165
165
|
setStream(templateVar);
|
|
166
166
|
continue;
|
|
167
167
|
}
|
|
168
|
-
const getErrMsg = (
|
|
168
|
+
const getErrMsg = (msg) => {
|
|
169
169
|
const { hookName, hookFilePath } = pageContext._renderHook;
|
|
170
170
|
const nth = (i === 0 && '1st') || (i === 1 && '2nd') || (i === 2 && '3rd') || `${i}-th`;
|
|
171
|
-
return [
|
|
171
|
+
return [
|
|
172
|
+
`The ${nth} HTML variable is ${msg}`,
|
|
173
|
+
`The HTML was provided by the ${hookName}() hook at ${hookFilePath}.`
|
|
174
|
+
]
|
|
172
175
|
.filter(Boolean)
|
|
173
176
|
.join(' ');
|
|
174
177
|
};
|
|
175
|
-
assertUsage(!isPromise(templateVar), getErrMsg(
|
|
178
|
+
assertUsage(!isPromise(templateVar), getErrMsg(`a promise, did you forget to ${pc.cyan('await')} the promise?`));
|
|
176
179
|
if (templateVar === undefined || templateVar === null) {
|
|
177
|
-
|
|
180
|
+
const msgVal = pc.cyan(String(templateVar));
|
|
181
|
+
const msgEmptyString = pc.cyan("''");
|
|
182
|
+
const msg = `${msgVal} which will be converted to an empty string. Pass the empty string ${msgEmptyString} instead of ${msgVal} to remove this warning.`;
|
|
183
|
+
assertWarning(false, getErrMsg(msg), { onlyOnce: false });
|
|
178
184
|
templateVar = '';
|
|
179
185
|
}
|
|
180
186
|
{
|
|
181
187
|
const varType = typeof templateVar;
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
188
|
+
if (varType !== 'string') {
|
|
189
|
+
const msgType = pc.cyan(`typeof htmlVariable === "${varType}"`);
|
|
190
|
+
const msg = `${msgType} but a string or stream (https://vike.dev/streaming) is expected instead.`;
|
|
191
|
+
assertUsage(false, getErrMsg(msg));
|
|
192
|
+
}
|
|
186
193
|
}
|
|
187
194
|
{
|
|
188
195
|
const { isProduction } = getGlobalContext();
|
|
189
196
|
if (isHtml(templateVar) &&
|
|
190
197
|
// We don't show this warning in production because it's expected that some users may (un)willingly do some XSS injection: we avoid flooding the production logs.
|
|
191
198
|
!isProduction) {
|
|
192
|
-
|
|
199
|
+
const msgVal = pc.cyan(String(templateVar));
|
|
200
|
+
const msg = `${msgVal} which seems to be HTML code. Did you forget to wrap the value with dangerouslySkipEscape()?`;
|
|
201
|
+
assertWarning(false, getErrMsg(msg), { onlyOnce: false });
|
|
193
202
|
}
|
|
194
203
|
}
|
|
195
204
|
// Escape untrusted template variable
|
|
@@ -209,16 +218,6 @@ async function renderTemplate(templateContent, pageContext) {
|
|
|
209
218
|
htmlPartsEnd
|
|
210
219
|
};
|
|
211
220
|
}
|
|
212
|
-
function escapeHtml(unsafeString) {
|
|
213
|
-
// Source: https://stackoverflow.com/questions/6234773/can-i-escape-html-special-chars-in-javascript/6234804#6234804
|
|
214
|
-
const safe = unsafeString
|
|
215
|
-
.replace(/&/g, '&')
|
|
216
|
-
.replace(/</g, '<')
|
|
217
|
-
.replace(/>/g, '>')
|
|
218
|
-
.replace(/"/g, '"')
|
|
219
|
-
.replace(/'/g, ''');
|
|
220
|
-
return safe;
|
|
221
|
-
}
|
|
222
221
|
async function getHtmlString(htmlRender) {
|
|
223
222
|
if (typeof htmlRender === 'string') {
|
|
224
223
|
return htmlRender;
|
|
@@ -80,5 +80,5 @@ type StreamPipeWrapped = {
|
|
|
80
80
|
};
|
|
81
81
|
declare function pipeStream(pipe: StreamPipe): StreamPipeWrapped;
|
|
82
82
|
declare function streamToString(stream: StreamProviderAny): Promise<string>;
|
|
83
|
-
declare function getStreamName(
|
|
83
|
+
declare function getStreamName(kind: 'pipe' | 'readable' | 'writable', type: 'web' | 'node'): `a ${string} Stream` | `a ${string} Stream Pipe`;
|
|
84
84
|
declare function inferStreamName(stream: StreamProviderNormalized): `a ${string} Stream` | `a ${string} Stream Pipe`;
|
|
@@ -758,17 +758,17 @@ async function loadStreamNodeModule() {
|
|
|
758
758
|
const { Readable, Writable } = streamModule;
|
|
759
759
|
return { Readable, Writable };
|
|
760
760
|
}
|
|
761
|
-
function getStreamName(
|
|
762
|
-
let
|
|
763
|
-
if (
|
|
764
|
-
|
|
761
|
+
function getStreamName(kind, type) {
|
|
762
|
+
let typeName = capitalizeFirstLetter(type);
|
|
763
|
+
if (typeName === 'Node') {
|
|
764
|
+
typeName = 'Node.js';
|
|
765
765
|
}
|
|
766
|
-
const
|
|
767
|
-
if (
|
|
768
|
-
return `a ${
|
|
766
|
+
const kindName = capitalizeFirstLetter(kind);
|
|
767
|
+
if (kind !== 'pipe') {
|
|
768
|
+
return `a ${kindName} ${typeName} Stream`;
|
|
769
769
|
}
|
|
770
|
-
if (
|
|
771
|
-
return `a ${
|
|
770
|
+
if (kind === 'pipe') {
|
|
771
|
+
return `a ${typeName} Stream Pipe`;
|
|
772
772
|
}
|
|
773
773
|
assert(false);
|
|
774
774
|
}
|
|
@@ -4,12 +4,16 @@ import { analyzePageClientSide } from '../../../shared/getPageFiles/analyzePageC
|
|
|
4
4
|
import { getVirtualFileIdPageConfigValuesAll } from '../../shared/virtual-files/virtualFilePageConfigValuesAll.js';
|
|
5
5
|
import { analyzeClientSide } from '../../../shared/getPageFiles/analyzeClientSide.js';
|
|
6
6
|
import { getGlobalContext } from '../globalContext.js';
|
|
7
|
-
import {
|
|
7
|
+
import { getConfigValueRuntime } from '../../../shared/page-configs/getConfigValue.js';
|
|
8
8
|
function analyzePage(pageFilesAll, pageConfig, pageId) {
|
|
9
9
|
if (pageConfig) {
|
|
10
10
|
const { isClientSideRenderable, isClientRouting } = analyzeClientSide(pageConfig, pageFilesAll, pageId);
|
|
11
|
-
const
|
|
12
|
-
const
|
|
11
|
+
const clientEntries = [];
|
|
12
|
+
const clientFilePath = getConfigValueRuntime(pageConfig, 'client', 'string')?.value ?? null;
|
|
13
|
+
if (clientFilePath)
|
|
14
|
+
clientEntries.push(clientFilePath);
|
|
15
|
+
if (isClientSideRenderable)
|
|
16
|
+
clientEntries.push(getVikeClientEntry(isClientRouting));
|
|
13
17
|
const clientDependencies = [];
|
|
14
18
|
clientDependencies.push({
|
|
15
19
|
id: getVirtualFileIdPageConfigValuesAll(pageConfig.pageId, true),
|
|
@@ -41,15 +45,13 @@ function analyzePage(pageFilesAll, pageConfig, pageId) {
|
|
|
41
45
|
}
|
|
42
46
|
})
|
|
43
47
|
*/
|
|
44
|
-
|
|
45
|
-
if (clientEntry) {
|
|
48
|
+
clientEntries.forEach((clientEntry) => {
|
|
46
49
|
clientDependencies.push({
|
|
47
50
|
id: clientEntry,
|
|
48
51
|
onlyAssets: false,
|
|
49
52
|
eagerlyImported: false
|
|
50
53
|
});
|
|
51
|
-
|
|
52
|
-
}
|
|
54
|
+
});
|
|
53
55
|
return {
|
|
54
56
|
isHtmlOnly: !isClientSideRenderable,
|
|
55
57
|
isClientRouting,
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
export { getCacheControl };
|
|
2
2
|
import { getPageConfig } from '../../../../shared/page-configs/helpers.js';
|
|
3
|
-
import {
|
|
3
|
+
import { getConfigValueRuntime } from '../../../../shared/page-configs/getConfigValue.js';
|
|
4
4
|
const defaultValue = 'no-store, max-age=0';
|
|
5
5
|
function getCacheControl(pageId, pageConfigs) {
|
|
6
6
|
// TODO/v1-release: remove
|
|
7
7
|
if (pageConfigs.length === 0)
|
|
8
8
|
return defaultValue;
|
|
9
9
|
const pageConfig = getPageConfig(pageId, pageConfigs);
|
|
10
|
-
const configValue =
|
|
10
|
+
const configValue = getConfigValueRuntime(pageConfig, 'cacheControl', 'string');
|
|
11
11
|
const value = configValue?.value;
|
|
12
12
|
if (value)
|
|
13
13
|
return value;
|
|
@@ -14,7 +14,7 @@ async function executeOnBeforeRenderAndDataHooks(pageContext) {
|
|
|
14
14
|
}
|
|
15
15
|
preparePageContextForUserConsumptionServerSide(pageContext);
|
|
16
16
|
if (dataHook) {
|
|
17
|
-
const hookResult = await executeHook(() => dataHook.hookFn(pageContext), dataHook);
|
|
17
|
+
const hookResult = await executeHook(() => dataHook.hookFn(pageContext), dataHook, pageContext);
|
|
18
18
|
// Note: hookResult can be anything (e.g. an object) and is to be assigned to pageContext.data
|
|
19
19
|
const pageContextFromHook = {
|
|
20
20
|
data: hookResult
|
|
@@ -22,7 +22,7 @@ async function executeOnBeforeRenderAndDataHooks(pageContext) {
|
|
|
22
22
|
Object.assign(pageContext, pageContextFromHook);
|
|
23
23
|
}
|
|
24
24
|
if (onBeforeRenderHook) {
|
|
25
|
-
const hookResult = await executeHook(() => onBeforeRenderHook.hookFn(pageContext), onBeforeRenderHook);
|
|
25
|
+
const hookResult = await executeHook(() => onBeforeRenderHook.hookFn(pageContext), onBeforeRenderHook, pageContext);
|
|
26
26
|
assertOnBeforeRenderHookReturn(hookResult, onBeforeRenderHook.hookFilePath);
|
|
27
27
|
const pageContextFromHook = hookResult?.pageContext;
|
|
28
28
|
Object.assign(pageContext, pageContextFromHook);
|
|
@@ -13,7 +13,7 @@ async function executeOnRenderHtmlHook(pageContext) {
|
|
|
13
13
|
const { renderHook, hookFn } = getRenderHook(pageContext);
|
|
14
14
|
objectAssign(pageContext, { _renderHook: renderHook });
|
|
15
15
|
preparePageContextForUserConsumptionServerSide(pageContext);
|
|
16
|
-
const hookReturnValue = await executeHook(() => hookFn(pageContext), renderHook);
|
|
16
|
+
const hookReturnValue = await executeHook(() => hookFn(pageContext), renderHook, pageContext);
|
|
17
17
|
const { documentHtml, pageContextProvidedByRenderHook, pageContextPromise, injectFilter } = processHookReturnValue(hookReturnValue, renderHook);
|
|
18
18
|
Object.assign(pageContext, pageContextProvidedByRenderHook);
|
|
19
19
|
objectAssign(pageContext, { _pageContextPromise: pageContextPromise });
|
|
@@ -63,13 +63,13 @@ function getRenderHook(pageContext) {
|
|
|
63
63
|
assertUsage(false, [
|
|
64
64
|
`No ${hookName}() hook found, see https://vike.dev/${hookName}`
|
|
65
65
|
/*
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
66
|
+
'See https://vike.dev/render-modes for more information.',
|
|
67
|
+
[
|
|
68
|
+
// 'Loaded config files (none of them define the onRenderHtml() hook):',
|
|
69
|
+
'Loaded server-side page files (none of them `export { render }`):',
|
|
70
|
+
...pageContext._pageFilePathsLoaded.map((f, i) => ` (${i + 1}): ${f}`)
|
|
71
|
+
].join('\n')
|
|
72
|
+
*/
|
|
73
73
|
].join(' '));
|
|
74
74
|
}
|
|
75
75
|
return hookFound;
|
|
@@ -95,8 +95,8 @@ function getHttpResponseBodyStreamHandlers(htmlRender, renderHook) {
|
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
97
|
};
|
|
98
|
-
function getFixMsg(
|
|
99
|
-
const streamName = getStreamName(
|
|
98
|
+
function getFixMsg(kind, type) {
|
|
99
|
+
const streamName = getStreamName(kind, type);
|
|
100
100
|
assert(['a ', 'an ', 'the '].some((s) => streamName.startsWith(s)));
|
|
101
101
|
assert(renderHook);
|
|
102
102
|
const { hookFilePath, hookName } = renderHook;
|
|
@@ -14,16 +14,11 @@ type PageContext_loadUserFilesServerSide = PageContextGetPageAssets & PageContex
|
|
|
14
14
|
type PageFiles = PromiseType<ReturnType<typeof loadUserFilesServerSide>>;
|
|
15
15
|
declare function loadUserFilesServerSide(pageContext: {
|
|
16
16
|
_pageId: string;
|
|
17
|
-
} & PageContext_loadUserFilesServerSide): Promise<{
|
|
17
|
+
} & PageContext_loadUserFilesServerSide): Promise<import("../../../shared/getPageFiles.js").PageContextExports & {
|
|
18
18
|
Page: unknown;
|
|
19
19
|
_isHtmlOnly: boolean;
|
|
20
20
|
_passToClient: string[];
|
|
21
21
|
_pageFilePathsLoaded: string[];
|
|
22
|
-
config: Record<string, unknown>;
|
|
23
|
-
configEntries: import("../../../shared/getPageFiles/getExports.js").ConfigEntries;
|
|
24
|
-
exports: Record<string, unknown>;
|
|
25
|
-
exportsAll: import("../../../shared/getPageFiles/getExports.js").ExportsAll;
|
|
26
|
-
pageExports: Record<string, unknown>;
|
|
27
22
|
} & {
|
|
28
23
|
__getPageAssets: () => Promise<PageAsset[]>;
|
|
29
24
|
}>;
|
|
@@ -10,7 +10,7 @@ import { getGlobalContext } from '../globalContext.js';
|
|
|
10
10
|
import { loadConfigValues } from '../../../shared/page-configs/loadConfigValues.js';
|
|
11
11
|
async function loadUserFilesServerSide(pageContext) {
|
|
12
12
|
const pageConfig = findPageConfig(pageContext._pageConfigs, pageContext._pageId); // Make pageConfig globally available as pageContext._pageConfig?
|
|
13
|
-
const [{ pageFilesLoaded,
|
|
13
|
+
const [{ pageFilesLoaded, pageContextExports }] = await Promise.all([
|
|
14
14
|
loadPageUserFiles(pageContext._pageFilesAll, pageConfig, pageContext._pageId, !getGlobalContext().isProduction),
|
|
15
15
|
analyzePageClientSideInit(pageContext._pageFilesAll, pageContext._pageId, { sharedPageFilesAlreadyLoaded: true })
|
|
16
16
|
]);
|
|
@@ -35,8 +35,8 @@ async function loadUserFilesServerSide(pageContext) {
|
|
|
35
35
|
});
|
|
36
36
|
}
|
|
37
37
|
const pageContextAddendum = {};
|
|
38
|
+
objectAssign(pageContextAddendum, pageContextExports);
|
|
38
39
|
objectAssign(pageContextAddendum, {
|
|
39
|
-
...pageContextExports,
|
|
40
40
|
Page: pageContextExports.exports.Page,
|
|
41
41
|
_isHtmlOnly: isHtmlOnly,
|
|
42
42
|
_passToClient: passToClient,
|
|
@@ -101,8 +101,7 @@ async function loadPageUserFiles(pageFilesAll, pageConfig, pageId, isDev) {
|
|
|
101
101
|
await Promise.all(pageFilesServerSide.map((p) => p.loadFile?.()));
|
|
102
102
|
const pageContextExports = getPageContextExports(pageFilesServerSide, pageConfigLoaded);
|
|
103
103
|
return {
|
|
104
|
-
|
|
105
|
-
pageFilesLoaded: pageFilesServerSide
|
|
106
|
-
pageConfigLoaded
|
|
104
|
+
pageContextExports,
|
|
105
|
+
pageFilesLoaded: pageFilesServerSide
|
|
107
106
|
};
|
|
108
107
|
}
|
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
export { logErrorHint };
|
|
2
|
-
export {
|
|
3
|
-
export { isKnownError };
|
|
4
|
-
export { getHint };
|
|
2
|
+
export { getErrorHint };
|
|
5
3
|
declare function logErrorHint(error: unknown): void;
|
|
6
|
-
declare function
|
|
7
|
-
declare function isKnownError(error: unknown): false | string;
|
|
8
|
-
declare function isCjsEsmError(error: unknown): boolean | string[];
|
|
4
|
+
declare function getErrorHint(error: unknown): null | string;
|