vike 0.4.218 → 0.4.220
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/__internal/index.js +11 -11
- package/dist/cjs/node/api/build.js +20 -11
- package/dist/cjs/node/api/context.js +5 -1
- package/dist/cjs/node/api/index.js +17 -7
- package/dist/cjs/node/api/prepareViteApiCall.js +39 -11
- package/dist/cjs/node/cli/entry.js +19 -7
- package/dist/cjs/node/plugin/index.js +5 -5
- package/dist/cjs/node/plugin/plugins/autoFullBuild.js +3 -4
- package/dist/cjs/node/plugin/plugins/baseUrls.js +3 -10
- package/dist/cjs/node/plugin/plugins/buildConfig.js +2 -2
- package/dist/cjs/node/plugin/plugins/{importBuild → buildEntry}/index.js +16 -17
- package/dist/cjs/node/plugin/plugins/commonConfig.js +39 -4
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +26 -23
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +171 -68
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js +1 -1
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigs.js +4 -3
- package/dist/cjs/node/plugin/plugins/setGlobalContext.js +1 -1
- package/dist/cjs/node/plugin/plugins/{vite6HmrRegressionWorkaround.js → workaroundVite6HmrRegression.js} +3 -3
- package/dist/cjs/node/plugin/shared/getHttpRequestAsyncStore.js +17 -7
- package/dist/cjs/node/prerender/isPrerenderAutoRunEnabled.js +16 -0
- package/dist/cjs/node/prerender/runPrerender.js +94 -66
- package/dist/cjs/node/prerender/utils.js +1 -0
- package/dist/cjs/node/runtime/globalContext.js +108 -34
- package/dist/cjs/node/runtime/html/injectAssets/getHtmlTags.js +2 -2
- package/dist/cjs/node/runtime/index-common.js +0 -15
- package/dist/cjs/node/runtime/onLoad.js +17 -3
- package/dist/cjs/node/runtime/page-files/setup.js +2 -4
- package/dist/cjs/node/runtime/renderPage/analyzePage.js +2 -2
- package/dist/cjs/node/runtime/renderPage/createHttpResponse/getCacheControl.js +2 -2
- package/dist/cjs/node/runtime/renderPage/loadUserFilesServerSide.js +1 -1
- package/dist/cjs/node/runtime/renderPage/renderPageAlreadyRouted.js +11 -33
- package/dist/cjs/node/runtime/renderPage/resolveRedirects.js +9 -1
- package/dist/cjs/node/runtime/renderPage.js +21 -22
- package/dist/cjs/node/runtime/utils.js +1 -0
- package/dist/cjs/node/runtime-dev/index.js +17 -7
- package/dist/cjs/node/shared/assertRuntimeManifest.js +0 -2
- package/dist/cjs/shared/getPageFiles/analyzeClientSide.js +3 -3
- package/dist/cjs/shared/getPageFiles/{setPageFiles.js → getPageFiles.js} +8 -6
- package/dist/cjs/shared/getPageFiles.js +3 -9
- package/dist/cjs/shared/hooks/getHook.js +3 -3
- package/dist/cjs/shared/{getPageFiles/getExports.js → page-configs/getPageConfigUserFriendly.js} +113 -81
- package/dist/cjs/shared/page-configs/serialize/serializeConfigValues.js +80 -55
- package/dist/cjs/shared/route/loadPageRoutes.js +3 -3
- package/dist/cjs/shared/utils.js +1 -0
- package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
- package/dist/cjs/utils/assert.js +4 -3
- package/dist/cjs/utils/assertSetup.js +47 -16
- package/dist/cjs/utils/debug.js +11 -6
- package/dist/cjs/utils/getGlobalObject.js +1 -2
- package/dist/cjs/utils/objectReplace.js +9 -0
- package/dist/esm/__internal/index.d.ts +3 -5
- package/dist/esm/__internal/index.js +6 -8
- package/dist/esm/client/client-routing-runtime/createPageContext.js +4 -1
- package/dist/esm/client/client-routing-runtime/entry.d.ts +1 -1
- package/dist/esm/client/client-routing-runtime/entry.js +0 -1
- package/dist/esm/client/client-routing-runtime/getPageContextCurrent.d.ts +2 -2
- package/dist/esm/client/client-routing-runtime/getPageContextFromHooks.d.ts +4 -4
- package/dist/esm/client/client-routing-runtime/getPageContextFromHooks.js +1 -1
- package/dist/esm/client/client-routing-runtime/initOnLinkClick.d.ts +4 -0
- package/dist/esm/client/client-routing-runtime/initOnLinkClick.js +13 -3
- package/dist/esm/client/client-routing-runtime/initOnPopState.js +8 -0
- package/dist/esm/client/client-routing-runtime/prefetch/getPrefetchSettings.d.ts +2 -2
- package/dist/esm/client/client-routing-runtime/prefetch.d.ts +2 -2
- package/dist/esm/client/client-routing-runtime/prefetch.js +2 -2
- package/dist/esm/client/client-routing-runtime/skipLink.d.ts +2 -0
- package/dist/esm/client/client-routing-runtime/skipLink.js +1 -0
- package/dist/esm/client/server-routing-runtime/entry.d.ts +1 -1
- package/dist/esm/client/server-routing-runtime/entry.js +0 -1
- package/dist/esm/client/server-routing-runtime/getPageContext.d.ts +1 -1
- package/dist/esm/client/server-routing-runtime/getPageContext.js +5 -2
- package/dist/esm/client/shared/executeOnRenderClientHook.d.ts +2 -2
- package/dist/esm/client/shared/loadUserFilesClientSide.d.ts +2 -2
- package/dist/esm/client/shared/loadUserFilesClientSide.js +2 -2
- package/dist/esm/client/shared/normalizeClientSideUrl.js +2 -3
- package/dist/esm/client/shared/preparePageContextForUserConsumptionClientSide.d.ts +2 -2
- package/dist/esm/node/api/build.js +3 -4
- package/dist/esm/node/api/context.d.ts +3 -1
- package/dist/esm/node/api/context.js +6 -2
- package/dist/esm/node/api/prepareViteApiCall.d.ts +1 -1
- package/dist/esm/node/api/prepareViteApiCall.js +25 -7
- package/dist/esm/node/cli/entry.js +2 -0
- package/dist/esm/node/cli/parseCli.d.ts +1 -1
- package/dist/esm/node/plugin/index.d.ts +1 -1
- package/dist/esm/node/plugin/index.js +5 -5
- package/dist/esm/node/plugin/plugins/autoFullBuild.js +3 -4
- package/dist/esm/node/plugin/plugins/baseUrls.d.ts +1 -1
- package/dist/esm/node/plugin/plugins/baseUrls.js +4 -11
- package/dist/esm/node/plugin/plugins/buildConfig.js +2 -2
- package/dist/esm/node/plugin/plugins/{importBuild → buildEntry}/getVikeManifest.d.ts +1 -1
- package/dist/esm/node/plugin/plugins/{importBuild → buildEntry}/index.d.ts +2 -2
- package/dist/esm/node/plugin/plugins/{importBuild → buildEntry}/index.js +16 -17
- package/dist/esm/node/plugin/plugins/commonConfig.d.ts +3 -0
- package/dist/esm/node/plugin/plugins/commonConfig.js +40 -5
- package/dist/esm/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.d.ts +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.d.ts +6 -9
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +25 -22
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.d.ts +96 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +167 -64
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigs.js +4 -3
- package/dist/esm/node/plugin/plugins/setGlobalContext.js +1 -1
- package/dist/esm/node/plugin/plugins/workaroundVite6HmrRegression.d.ts +3 -0
- package/dist/esm/node/plugin/plugins/{vite6HmrRegressionWorkaround.js → workaroundVite6HmrRegression.js} +3 -3
- package/dist/esm/node/prerender/isPrerenderAutoRunEnabled.d.ts +5 -0
- package/dist/esm/node/prerender/isPrerenderAutoRunEnabled.js +14 -0
- package/dist/esm/node/prerender/runPrerender.d.ts +1 -2
- package/dist/esm/node/prerender/runPrerender.js +78 -60
- package/dist/esm/node/prerender/utils.d.ts +1 -0
- package/dist/esm/node/prerender/utils.js +1 -0
- package/dist/esm/node/runtime/globalContext.d.ts +23 -7
- package/dist/esm/node/runtime/globalContext.js +108 -34
- package/dist/esm/node/runtime/html/injectAssets/getHtmlTags.js +1 -1
- package/dist/esm/node/runtime/index-common.d.ts +0 -1
- package/dist/esm/node/runtime/index-common.js +0 -15
- package/dist/esm/node/runtime/index-deprecated.d.ts +1 -0
- package/dist/esm/node/runtime/onLoad.js +16 -2
- package/dist/esm/node/runtime/page-files/setup.js +3 -3
- package/dist/esm/node/runtime/renderPage/analyzePage.js +1 -1
- package/dist/esm/node/runtime/renderPage/createHttpResponse/getCacheControl.js +1 -1
- package/dist/esm/node/runtime/renderPage/executeOnBeforeRenderAndDataHooks.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/loadUserFilesServerSide.d.ts +1 -1
- package/dist/esm/node/runtime/renderPage/loadUserFilesServerSide.js +2 -2
- package/dist/esm/node/runtime/renderPage/preparePageContextForUserConsumptionServerSide.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.d.ts +31 -46
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.js +11 -33
- package/dist/esm/node/runtime/renderPage/resolveRedirects.d.ts +1 -1
- package/dist/esm/node/runtime/renderPage/resolveRedirects.js +9 -1
- package/dist/esm/node/runtime/renderPage.js +22 -23
- package/dist/esm/node/runtime/utils.d.ts +1 -0
- package/dist/esm/node/runtime/utils.js +1 -0
- package/dist/esm/node/shared/assertPluginManifest.d.ts +0 -1
- package/dist/esm/node/shared/assertRuntimeManifest.d.ts +0 -1
- package/dist/esm/node/shared/assertRuntimeManifest.js +1 -3
- package/dist/esm/shared/getPageFiles/analyzeClientSide.js +1 -1
- package/dist/esm/shared/getPageFiles/{setPageFiles.d.ts → getPageFiles.d.ts} +3 -1
- package/dist/esm/shared/getPageFiles/{setPageFiles.js → getPageFiles.js} +8 -6
- package/dist/esm/shared/getPageFiles.d.ts +2 -5
- package/dist/esm/shared/getPageFiles.js +1 -4
- package/dist/esm/shared/hooks/getHook.d.ts +3 -3
- package/dist/esm/shared/hooks/getHook.js +1 -1
- package/dist/esm/shared/page-configs/Config/PageContextConfig.d.ts +9 -5
- package/dist/esm/shared/page-configs/Config.d.ts +20 -2
- package/dist/esm/shared/page-configs/PageConfig.d.ts +7 -3
- package/dist/esm/shared/{getPageFiles/getExports.d.ts → page-configs/getPageConfigUserFriendly.d.ts} +26 -12
- package/dist/esm/shared/{getPageFiles/getExports.js → page-configs/getPageConfigUserFriendly.js} +112 -80
- package/dist/esm/shared/page-configs/serialize/serializeConfigValues.d.ts +26 -6
- package/dist/esm/shared/page-configs/serialize/serializeConfigValues.js +80 -55
- package/dist/esm/shared/route/executeGuardHook.d.ts +2 -2
- package/dist/esm/shared/route/loadPageRoutes.js +1 -1
- package/dist/esm/shared/types.d.ts +1 -1
- package/dist/esm/shared/utils.d.ts +1 -0
- package/dist/esm/shared/utils.js +1 -0
- 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/assert.js +4 -3
- package/dist/esm/utils/assertSetup.js +47 -16
- package/dist/esm/utils/debug.d.ts +1 -1
- package/dist/esm/utils/debug.js +11 -6
- package/dist/esm/utils/getGlobalObject.js +1 -2
- package/dist/esm/utils/objectReplace.d.ts +1 -0
- package/dist/esm/utils/objectReplace.js +6 -0
- package/dist/esm/utils/projectInfo.d.ts +1 -1
- package/package.json +4 -13
- package/__internal/loadImportBuild.js +0 -3
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveVikeConfigGlobal.js +0 -128
- package/dist/cjs/node/runtime/globalContext/loadImportBuild.js +0 -25
- package/dist/cjs/node/runtime/page-files/getPageFilesExports.js +0 -22
- package/dist/esm/client/client-routing-runtime/pageFiles.d.ts +0 -1
- package/dist/esm/client/client-routing-runtime/pageFiles.js +0 -4
- package/dist/esm/client/server-routing-runtime/pageFiles.d.ts +0 -1
- package/dist/esm/client/server-routing-runtime/pageFiles.js +0 -4
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveVikeConfigGlobal.d.ts +0 -104
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveVikeConfigGlobal.js +0 -123
- package/dist/esm/node/plugin/plugins/vite6HmrRegressionWorkaround.d.ts +0 -3
- package/dist/esm/node/runtime/globalContext/loadImportBuild.d.ts +0 -18
- package/dist/esm/node/runtime/globalContext/loadImportBuild.js +0 -23
- package/dist/esm/node/runtime/page-files/getPageFilesExports.d.ts +0 -2
- package/dist/esm/node/runtime/page-files/getPageFilesExports.js +0 -20
- /package/dist/cjs/node/plugin/plugins/{importBuild → buildEntry}/getVikeManifest.js +0 -0
- /package/dist/cjs/shared/page-configs/{getConfigValue.js → getConfigValueRuntime.js} +0 -0
- /package/dist/esm/node/plugin/plugins/{importBuild → buildEntry}/getVikeManifest.js +0 -0
- /package/dist/esm/shared/page-configs/{getConfigValue.d.ts → getConfigValueRuntime.d.ts} +0 -0
- /package/dist/esm/shared/page-configs/{getConfigValue.js → getConfigValueRuntime.js} +0 -0
|
@@ -3,8 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getGlobalObject = getGlobalObject;
|
|
4
4
|
exports.assertIsSingleModuleInstance = assertIsSingleModuleInstance;
|
|
5
5
|
const assert_js_1 = require("./assert.js");
|
|
6
|
-
const projectInfo_js_1 = require("./projectInfo.js");
|
|
7
|
-
const projectKey = `_${projectInfo_js_1.projectInfo.projectName.toLowerCase()}`;
|
|
8
6
|
/** Share information across module instances. */
|
|
9
7
|
function getGlobalObject(
|
|
10
8
|
// We use the filename (or file path) as key. There should be only one getGlobalObject() usage per file. Thus the key should be unique, assuming the filename (or file path) is unique.
|
|
@@ -21,6 +19,7 @@ key) {
|
|
|
21
19
|
(0, assert_js_1.assert)(!(key in globalObjects));
|
|
22
20
|
}
|
|
23
21
|
function getGlobalObjects() {
|
|
22
|
+
const projectKey = '_vike';
|
|
24
23
|
// @ts-ignore
|
|
25
24
|
const globalObjects = (globalThis[projectKey] = globalThis[projectKey] || {});
|
|
26
25
|
return globalObjects;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.objectReplace = objectReplace;
|
|
4
|
+
function objectReplace(obj, objNew, except) {
|
|
5
|
+
Object.keys(obj)
|
|
6
|
+
.filter((key) => !except?.includes(key))
|
|
7
|
+
.forEach((key) => delete obj[key]);
|
|
8
|
+
Object.assign(obj, objNew);
|
|
9
|
+
}
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
+
export { setGlobalContext_buildEntry } from '../node/runtime/globalContext.js';
|
|
1
2
|
export { route, getPagesAndRoutes };
|
|
2
3
|
export type { PageRoutes, PageFile, PageConfigRuntime as PageConfig };
|
|
3
4
|
export { getMiddlewares };
|
|
4
5
|
import { route as routeInternal, type PageRoutes } from '../shared/route/index.js';
|
|
5
|
-
import {
|
|
6
|
+
import type { PageFile } from '../shared/getPageFiles/getPageFileObject.js';
|
|
6
7
|
import { PageConfigRuntime } from '../shared/page-configs/PageConfig.js';
|
|
7
8
|
/**
|
|
8
|
-
* Used by {@link https://github.com/magne4000/vite-plugin-vercel|vite-plugin-vercel}
|
|
9
|
-
* to compute some rewrite rules and extract { isr } configs.
|
|
10
|
-
* Needs `import 'vike/__internal/setup'`
|
|
11
|
-
* @param config
|
|
9
|
+
* Used by {@link https://github.com/magne4000/vite-plugin-vercel|vite-plugin-vercel} to compute some rewrite rules and extract { isr } configs.
|
|
12
10
|
*/
|
|
13
11
|
declare function getPagesAndRoutes(): Promise<{
|
|
14
12
|
pageRoutes: PageRoutes;
|
|
@@ -1,24 +1,22 @@
|
|
|
1
|
+
// Internals needed by Vike
|
|
2
|
+
export { setGlobalContext_buildEntry } from '../node/runtime/globalContext.js';
|
|
1
3
|
// Internals needed by vite-plugin-vercel
|
|
2
4
|
export { route, getPagesAndRoutes };
|
|
3
5
|
// Internals needed by experimental implementation of vike-telefunc
|
|
4
6
|
export { getMiddlewares };
|
|
5
7
|
import { route as routeInternal } from '../shared/route/index.js';
|
|
6
|
-
import { getPageFilesAll } from '../shared/getPageFiles.js';
|
|
8
|
+
import { getPageFilesAll } from '../shared/getPageFiles/getPageFiles.js';
|
|
7
9
|
import { getGlobalContext, initGlobalContext_getGlobalContextAsync } from '../node/runtime/globalContext.js';
|
|
8
10
|
import { setNodeEnvProduction } from '../utils/assertSetup.js';
|
|
9
|
-
import { getRenderContext } from '../node/runtime/renderPage/renderPageAlreadyRouted.js';
|
|
10
11
|
/**
|
|
11
|
-
* Used by {@link https://github.com/magne4000/vite-plugin-vercel|vite-plugin-vercel}
|
|
12
|
-
* to compute some rewrite rules and extract { isr } configs.
|
|
13
|
-
* Needs `import 'vike/__internal/setup'`
|
|
14
|
-
* @param config
|
|
12
|
+
* Used by {@link https://github.com/magne4000/vite-plugin-vercel|vite-plugin-vercel} to compute some rewrite rules and extract { isr } configs.
|
|
15
13
|
*/
|
|
16
14
|
async function getPagesAndRoutes() {
|
|
17
15
|
setNodeEnvProduction();
|
|
18
|
-
const
|
|
16
|
+
const globalContext = getGlobalContext();
|
|
19
17
|
const {
|
|
20
18
|
//
|
|
21
|
-
pageRoutes, pageFilesAll, pageConfigs, allPageIds } =
|
|
19
|
+
pageRoutes, pageFilesAll, pageConfigs, allPageIds } = globalContext;
|
|
22
20
|
return {
|
|
23
21
|
pageRoutes,
|
|
24
22
|
pageFilesAll,
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
export { createPageContext };
|
|
2
2
|
import { getPageContextUrlComputed } from '../../shared/getPageContextUrlComputed.js';
|
|
3
|
-
import { getPageFilesAll } from '../../shared/getPageFiles.js';
|
|
3
|
+
import { getPageFilesAll, setPageFiles } from '../../shared/getPageFiles/getPageFiles.js';
|
|
4
4
|
import { loadPageRoutes } from '../../shared/route/loadPageRoutes.js';
|
|
5
5
|
import { getBaseServer } from './getBaseServer.js';
|
|
6
6
|
import { assert, isBaseServer, getGlobalObject, objectAssign } from './utils.js';
|
|
7
|
+
// @ts-ignore
|
|
8
|
+
import * as pageFilesExports from 'virtual:vike:importUserCode:client:client-routing';
|
|
7
9
|
const globalObject = getGlobalObject('createPageContext.ts', {});
|
|
10
|
+
setPageFiles(pageFilesExports);
|
|
8
11
|
async function createPageContext(urlOriginal) {
|
|
9
12
|
if (!globalObject.pageFilesData) {
|
|
10
13
|
globalObject.pageFilesData = await getPageFilesAll(true);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export {};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { assertClientRouting } from '../../utils/assertRoutingType.js';
|
|
2
2
|
assertClientRouting();
|
|
3
|
-
import './pageFiles';
|
|
4
3
|
import { initClientRouter } from './initClientRouter.js';
|
|
5
4
|
import { assertSingleInstance_onClientEntryClientRouting } from './utils.js';
|
|
6
5
|
import { removeFoucBuster } from '../shared/removeFoucBuster.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { setPageContextCurrent };
|
|
2
2
|
export { getPageContextCurrent };
|
|
3
|
-
import type {
|
|
4
|
-
type PageContextCurrent =
|
|
3
|
+
import type { PageConfigUserFriendly } from '../../shared/getPageFiles.js';
|
|
4
|
+
type PageContextCurrent = PageConfigUserFriendly & {
|
|
5
5
|
urlPathname: string;
|
|
6
6
|
};
|
|
7
7
|
declare function getPageContextCurrent(): null | PageContextCurrent;
|
|
@@ -5,7 +5,7 @@ export { getPageContextFromClientHooks };
|
|
|
5
5
|
export { setPageContextInitIsPassedToClient };
|
|
6
6
|
export type { PageContextFromServerHooks };
|
|
7
7
|
export type { PageContextFromClientHooks };
|
|
8
|
-
import type {
|
|
8
|
+
import type { PageConfigUserFriendly, PageFile } from '../../shared/getPageFiles.js';
|
|
9
9
|
import type { PageConfigRuntime } from '../../shared/page-configs/PageConfig.js';
|
|
10
10
|
type PageContext = {
|
|
11
11
|
urlOriginal: string;
|
|
@@ -21,9 +21,9 @@ declare function getPageContextFromHooks_serialized(): PageContextSerialized & {
|
|
|
21
21
|
routeParams: Record<string, string>;
|
|
22
22
|
_hasPageContextFromServer: true;
|
|
23
23
|
};
|
|
24
|
-
declare function getPageContextFromHooks_isHydration(pageContext: PageContextSerialized & PageContext &
|
|
24
|
+
declare function getPageContextFromHooks_isHydration(pageContext: PageContextSerialized & PageContext & PageConfigUserFriendly & {
|
|
25
25
|
_hasPageContextFromServer: true;
|
|
26
|
-
}): Promise<PageContextSerialized & PageContext &
|
|
26
|
+
}): Promise<PageContextSerialized & PageContext & PageConfigUserFriendly & {
|
|
27
27
|
_hasPageContextFromServer: true;
|
|
28
28
|
} & {
|
|
29
29
|
_hasPageContextFromClient: boolean;
|
|
@@ -45,5 +45,5 @@ type PageContextFromClientHooks = {
|
|
|
45
45
|
declare function getPageContextFromClientHooks(pageContext: {
|
|
46
46
|
pageId: string;
|
|
47
47
|
_hasPageContextFromServer: boolean;
|
|
48
|
-
} & PageContext &
|
|
48
|
+
} & PageContext & PageConfigUserFriendly, isErrorPage: boolean): Promise<PageContextFromClientHooks>;
|
|
49
49
|
declare function setPageContextInitIsPassedToClient(pageContext: Record<string, unknown>): void;
|
|
@@ -12,7 +12,7 @@ import { preparePageContextForUserConsumptionClientSide } from '../shared/prepar
|
|
|
12
12
|
import { removeBuiltInOverrides } from './getPageContext/removeBuiltInOverrides.js';
|
|
13
13
|
import { getPageContextRequestUrl } from '../../shared/getPageContextRequestUrl.js';
|
|
14
14
|
import { getPageConfig } from '../../shared/page-configs/helpers.js';
|
|
15
|
-
import { getConfigValueRuntime } from '../../shared/page-configs/
|
|
15
|
+
import { getConfigValueRuntime } from '../../shared/page-configs/getConfigValueRuntime.js';
|
|
16
16
|
import { assertOnBeforeRenderHookReturn } from '../../shared/assertOnBeforeRenderHookReturn.js';
|
|
17
17
|
import { executeGuardHook } from '../../shared/route/executeGuardHook.js';
|
|
18
18
|
import { AbortRender, isAbortPageContext } from '../../shared/route/abort.js';
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
// Code adapted from https://github.com/HenrikJoreteg/internal-nav-helper/blob/5199ec5448d0b0db7ec63cf76d88fa6cad878b7d/src/index.js#L11-L29
|
|
2
2
|
export { initOnLinkClick };
|
|
3
|
-
|
|
3
|
+
export { getCurrentLinkClick };
|
|
4
|
+
import { getGlobalObject } from './utils.js';
|
|
4
5
|
import { isSameAsCurrentUrl, skipLink } from './skipLink.js';
|
|
5
6
|
import { renderPageClientSide } from './renderPageClientSide.js';
|
|
6
7
|
import { scrollToHashOrTop } from './setScrollPosition.js';
|
|
8
|
+
const globalObject = getGlobalObject('initOnLinkClick.ts', {});
|
|
7
9
|
function initOnLinkClick() {
|
|
8
10
|
document.addEventListener('click', onClick);
|
|
9
11
|
}
|
|
@@ -14,10 +16,16 @@ async function onClick(ev) {
|
|
|
14
16
|
if (!linkTag)
|
|
15
17
|
return;
|
|
16
18
|
const href = linkTag.getAttribute('href');
|
|
19
|
+
if (href === null)
|
|
20
|
+
return;
|
|
21
|
+
globalObject.currentLinkClick = { href };
|
|
22
|
+
setTimeout(() => {
|
|
23
|
+
delete globalObject.currentLinkClick;
|
|
24
|
+
}, 0);
|
|
17
25
|
// Workaround for Firefox bug: clicking on a hash link that doesn't change the current URL causes Firefox to erroneously set `window.history.state = null` without firing any signal that we can detect.
|
|
18
26
|
// - https://github.com/vikejs/vike/issues/1962
|
|
19
27
|
// - https://github.com/sveltejs/kit/issues/8725
|
|
20
|
-
if (href
|
|
28
|
+
if (href.includes('#') && isSameAsCurrentUrl(href)) {
|
|
21
29
|
// Prevent Firefox from setting `window.history.state` to `null`
|
|
22
30
|
ev.preventDefault();
|
|
23
31
|
// Replicate the browser's native behavior
|
|
@@ -26,7 +34,6 @@ async function onClick(ev) {
|
|
|
26
34
|
}
|
|
27
35
|
if (skipLink(linkTag))
|
|
28
36
|
return;
|
|
29
|
-
assert(href);
|
|
30
37
|
ev.preventDefault();
|
|
31
38
|
let scrollTarget;
|
|
32
39
|
{
|
|
@@ -53,3 +60,6 @@ function findLinkTag(target) {
|
|
|
53
60
|
}
|
|
54
61
|
return target;
|
|
55
62
|
}
|
|
63
|
+
function getCurrentLinkClick() {
|
|
64
|
+
return globalObject.currentLinkClick;
|
|
65
|
+
}
|
|
@@ -4,6 +4,8 @@ import { assertWarning, getGlobalObject } from './utils.js';
|
|
|
4
4
|
import { onPopStateBegin } from './history.js';
|
|
5
5
|
import { renderPageClientSide } from './renderPageClientSide.js';
|
|
6
6
|
import { setScrollPosition } from './setScrollPosition.js';
|
|
7
|
+
import { getCurrentLinkClick } from './initOnLinkClick.js';
|
|
8
|
+
import { isSamePageHashLink } from './skipLink.js';
|
|
7
9
|
const globalObject = getGlobalObject('initOnPopState.ts', { listeners: [] });
|
|
8
10
|
function initOnPopState() {
|
|
9
11
|
// - The popstate event is trigged upon:
|
|
@@ -16,7 +18,13 @@ function initOnPopState() {
|
|
|
16
18
|
// - `location.hash = 'some-hash'`
|
|
17
19
|
// - The `event` argument of `window.addEventListener('popstate', (event) => /*...*/)` is useless: the History API doesn't provide the previous state (the popped state), see https://stackoverflow.com/questions/48055323/is-history-state-always-the-same-as-popstate-event-state
|
|
18
20
|
window.addEventListener('popstate', async () => {
|
|
21
|
+
const currentLinkClick = getCurrentLinkClick();
|
|
19
22
|
const { isNewState, previous, current } = onPopStateBegin();
|
|
23
|
+
// We use currentLinkClick.href instead of current.url because current.url missing text links such as #:~:text=With%20frontmatter-,Global%20metadata,-What%20is%20global (e.g. Chrome strips the `#:~:text=` part from the URL before the popstate event).
|
|
24
|
+
if (currentLinkClick && isSamePageHashLink(currentLinkClick.href)) {
|
|
25
|
+
// Let the browser handle hash links
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
20
28
|
const scrollTarget = current.state.scrollPosition || undefined;
|
|
21
29
|
const isUserPushStateNavigation = current.state.triggeredBy === 'user' || previous.state.triggeredBy === 'user';
|
|
22
30
|
const isHashNavigation = removeHash(current.url) === removeHash(previous.url) && current.url !== previous.url;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export { getPrefetchSettings };
|
|
2
2
|
export { PAGE_CONTEXT_MAX_AGE_DEFAULT };
|
|
3
3
|
export type { PrefetchSettingResolved };
|
|
4
|
-
import type {
|
|
4
|
+
import type { PageConfigUserFriendly } from '../../../shared/getPageFiles.js';
|
|
5
5
|
declare const PAGE_CONTEXT_MAX_AGE_DEFAULT = 5000;
|
|
6
6
|
type PrefetchSettingResolved = {
|
|
7
7
|
staticAssets: false | 'hover' | 'viewport';
|
|
8
8
|
pageContext: false | number;
|
|
9
9
|
};
|
|
10
|
-
declare function getPrefetchSettings(pageContext:
|
|
10
|
+
declare function getPrefetchSettings(pageContext: PageConfigUserFriendly, linkTag: null | HTMLElement): PrefetchSettingResolved;
|
|
@@ -6,7 +6,7 @@ export { addLinkPrefetchHandlers };
|
|
|
6
6
|
export { addLinkPrefetchHandlers_watch };
|
|
7
7
|
export { addLinkPrefetchHandlers_unwatch };
|
|
8
8
|
import { type PageContextFromServerHooks, getPageContextFromServerHooks } from './getPageContextFromHooks.js';
|
|
9
|
-
import type {
|
|
9
|
+
import type { PageConfigUserFriendly, PageFile } from '../../shared/getPageFiles.js';
|
|
10
10
|
import { type PageConfigRuntime } from '../../shared/page-configs/PageConfig.js';
|
|
11
11
|
type ResultPageContextFromServer = Awaited<ReturnType<typeof getPageContextFromServerHooks>>;
|
|
12
12
|
type PageContextForPrefetch = {
|
|
@@ -19,7 +19,7 @@ type PageContextForPrefetch = {
|
|
|
19
19
|
};
|
|
20
20
|
declare function getPageContextPrefetched(pageContext: {
|
|
21
21
|
urlPathname: string;
|
|
22
|
-
} &
|
|
22
|
+
} & PageConfigUserFriendly): null | PageContextFromServerHooks;
|
|
23
23
|
declare function populatePageContextPrefetchCache(pageContext: PageContextForPrefetch, result: ResultPageContextFromServer): void;
|
|
24
24
|
/**
|
|
25
25
|
* Programmatically prefetch client assets.
|
|
@@ -60,8 +60,8 @@ async function prefetchPageContextFromServerHooks(pageContextLink, resultMaxAge)
|
|
|
60
60
|
const result = await getPageContextFromServerHooks(pageContextLink, false);
|
|
61
61
|
setPageContextPrefetchCache(pageContextLink, result, resultMaxAge);
|
|
62
62
|
}
|
|
63
|
-
function populatePageContextPrefetchCache(pageContext /*&
|
|
64
|
-
// TODO/pageContext-prefetch: replace with using pageContext.config.prerender instead. (For being able to do that: eager configs need to be accessible without have to use
|
|
63
|
+
function populatePageContextPrefetchCache(pageContext /*& PageConfigUserFriendly*/, result) {
|
|
64
|
+
// TODO/pageContext-prefetch: replace with using pageContext.config.prerender instead. (For being able to do that: eager configs need to be accessible without have to use PageConfigUserFriendly as it isn't available here.)
|
|
65
65
|
if (!isBrilloutDocpress())
|
|
66
66
|
return;
|
|
67
67
|
setPageContextPrefetchCache(pageContext, result, null);
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export { skipLink };
|
|
2
2
|
export { isSameAsCurrentUrl };
|
|
3
|
+
export { isSamePageHashLink };
|
|
3
4
|
declare function skipLink(linkTag: HTMLElement): boolean;
|
|
5
|
+
declare function isSamePageHashLink(href: string): boolean;
|
|
4
6
|
declare function isSameAsCurrentUrl(href: string): boolean;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { skipLink };
|
|
2
2
|
export { isSameAsCurrentUrl };
|
|
3
|
+
export { isSamePageHashLink };
|
|
3
4
|
import { normalizeClientSideUrl } from '../shared/normalizeClientSideUrl.js';
|
|
4
5
|
import { getBaseServer } from './getBaseServer.js';
|
|
5
6
|
import { assert, parseUrl, isBaseServer, isUrl, isUrlExternal } from './utils.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export {};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { assertServerRouting } from '../../utils/assertRoutingType.js';
|
|
2
2
|
assertServerRouting();
|
|
3
|
-
import './pageFiles';
|
|
4
3
|
import { getPageContext } from './getPageContext.js';
|
|
5
4
|
import { executeOnRenderClientHook } from '../shared/executeOnRenderClientHook.js';
|
|
6
5
|
import { assertHook } from '../../shared/hooks/getHook.js';
|
|
@@ -10,6 +10,6 @@ declare function getPageContext(): Promise<{
|
|
|
10
10
|
} & {
|
|
11
11
|
_pageFilesAll: import("../../shared/getPageFiles.js").PageFile[];
|
|
12
12
|
_pageConfigs: import("../../__internal/index.js").PageConfig[];
|
|
13
|
-
} & import("../../shared/getPageFiles.js").
|
|
13
|
+
} & import("../../shared/getPageFiles.js").PageConfigUserFriendly & {
|
|
14
14
|
_pageFilesLoaded: import("../../shared/getPageFiles.js").PageFile[];
|
|
15
15
|
}>;
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
+
export { getPageContext };
|
|
1
2
|
import { assertUsage, assertWarning, objectAssign } from './utils.js';
|
|
2
3
|
import { getPageContextSerializedInHtml } from '../shared/getPageContextSerializedInHtml.js';
|
|
3
|
-
import { getPageFilesAll } from '../../shared/getPageFiles.js';
|
|
4
|
+
import { getPageFilesAll, setPageFiles } from '../../shared/getPageFiles/getPageFiles.js';
|
|
4
5
|
import { loadUserFilesClientSide } from '../shared/loadUserFilesClientSide.js';
|
|
5
6
|
import { getCurrentUrl } from '../shared/getCurrentUrl.js';
|
|
6
|
-
|
|
7
|
+
// @ts-ignore
|
|
8
|
+
import * as pageFilesExports from 'virtual:vike:importUserCode:client:server-routing';
|
|
7
9
|
const urlFirst = getCurrentUrl({ withoutHash: true });
|
|
10
|
+
setPageFiles(pageFilesExports);
|
|
8
11
|
async function getPageContext() {
|
|
9
12
|
const pageContext = getPageContextSerializedInHtml();
|
|
10
13
|
objectAssign(pageContext, {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { executeOnRenderClientHook };
|
|
2
2
|
export type { PageContextBeforeRenderClient };
|
|
3
|
-
import type { PageFile,
|
|
3
|
+
import type { PageFile, PageConfigUserFriendly } from '../../shared/getPageFiles.js';
|
|
4
4
|
import { type PageContextForUserConsumptionClientSide } from './preparePageContextForUserConsumptionClientSide.js';
|
|
5
5
|
import type { PageConfigRuntime } from '../../shared/page-configs/PageConfig.js';
|
|
6
6
|
type PageContextBeforeRenderClient = {
|
|
@@ -9,5 +9,5 @@ type PageContextBeforeRenderClient = {
|
|
|
9
9
|
urlPathname?: string;
|
|
10
10
|
pageId: string;
|
|
11
11
|
_pageConfigs: PageConfigRuntime[];
|
|
12
|
-
} &
|
|
12
|
+
} & PageConfigUserFriendly & PageContextForUserConsumptionClientSide;
|
|
13
13
|
declare function executeOnRenderClientHook<PC extends PageContextBeforeRenderClient>(pageContext: PC, isClientRouting: boolean): Promise<void>;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export { loadUserFilesClientSide };
|
|
2
2
|
export { isErrorFetchingStaticAssets };
|
|
3
3
|
export type { PageContextUserFiles };
|
|
4
|
-
import { type PageFile, type
|
|
4
|
+
import { type PageFile, type PageConfigUserFriendly } from '../../shared/getPageFiles.js';
|
|
5
5
|
import type { PageConfigRuntime } from '../../shared/page-configs/PageConfig.js';
|
|
6
|
-
type PageContextUserFilesLoaded =
|
|
6
|
+
type PageContextUserFilesLoaded = PageConfigUserFriendly & {
|
|
7
7
|
_pageFilesLoaded: PageFile[];
|
|
8
8
|
};
|
|
9
9
|
type PageContextUserFiles = {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { loadUserFilesClientSide };
|
|
2
2
|
export { isErrorFetchingStaticAssets };
|
|
3
|
-
import { getPageFilesClientSide,
|
|
3
|
+
import { getPageFilesClientSide, getPageConfigUserFriendly } from '../../shared/getPageFiles.js';
|
|
4
4
|
import { findPageConfig } from '../../shared/page-configs/findPageConfig.js';
|
|
5
5
|
import { loadConfigValues } from '../../shared/page-configs/loadConfigValues.js';
|
|
6
6
|
import { objectAssign } from '../server-routing-runtime/utils.js';
|
|
@@ -29,7 +29,7 @@ async function loadUserFilesClientSide(pageId, pageFilesAll, pageConfigs) {
|
|
|
29
29
|
}
|
|
30
30
|
throw err;
|
|
31
31
|
}
|
|
32
|
-
const pageContextExports =
|
|
32
|
+
const pageContextExports = getPageConfigUserFriendly(pageFilesClientSide, pageConfigLoaded);
|
|
33
33
|
const pageContextAddendum = {};
|
|
34
34
|
objectAssign(pageContextAddendum, pageContextExports);
|
|
35
35
|
objectAssign(pageContextAddendum, { _pageFilesLoaded: pageFilesClientSide });
|
|
@@ -2,9 +2,8 @@ export { normalizeClientSideUrl };
|
|
|
2
2
|
import { assert, parseUrl } from './utils.js';
|
|
3
3
|
/** Resolves relative URLs */
|
|
4
4
|
function normalizeClientSideUrl(url, options) {
|
|
5
|
-
// This function doesn't work for `url === '#some-hash'` because `searchOriginal`
|
|
6
|
-
// -
|
|
7
|
-
// - It makes sense that `parseUrl()` returns `searchOriginal === null` since there isn't any search string in `url`.
|
|
5
|
+
// This function doesn't work for `url === '#some-hash'` because `searchOriginal` will be missing: if window.location.href has a search string then it's going to be missing in the returned `urlCurrent` value because `parseUrl(url)` returns `searchOriginal: null` since there isn't any search string in `url`.
|
|
6
|
+
// - Maybe `const { searchOriginal } = parseUrl(window.location.href)` can be a fix. (Let's check how `normalizeClientSideUrl()` is being used.)
|
|
8
7
|
assert(!url.startsWith('#'));
|
|
9
8
|
const { searchOriginal, hashOriginal, pathname } = parseUrl(url, '/');
|
|
10
9
|
let urlCurrent = `${pathname}${searchOriginal || ''}`;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export { preparePageContextForUserConsumptionClientSide };
|
|
2
2
|
export type { PageContextForUserConsumptionClientSide };
|
|
3
|
-
import type {
|
|
3
|
+
import type { PageConfigUserFriendly } from '../../shared/getPageFiles.js';
|
|
4
4
|
import type { PageConfigRuntime } from '../../shared/page-configs/PageConfig.js';
|
|
5
5
|
import { PageContextForPassToClientWarning } from './getPageContextProxyForUser.js';
|
|
6
|
-
type PageContextForUserConsumptionClientSide =
|
|
6
|
+
type PageContextForUserConsumptionClientSide = PageConfigUserFriendly & PageContextForPassToClientWarning & {
|
|
7
7
|
pageId: string;
|
|
8
8
|
_pageConfigs: PageConfigRuntime[];
|
|
9
9
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { build };
|
|
2
2
|
import { prepareViteApiCall } from './prepareViteApiCall.js';
|
|
3
3
|
import { build as buildVite } from 'vite';
|
|
4
|
+
import { isPrerenderAutoRunEnabled } from '../prerender/isPrerenderAutoRunEnabled.js';
|
|
4
5
|
/**
|
|
5
6
|
* Programmatically trigger `$ vike build`
|
|
6
7
|
*
|
|
@@ -13,11 +14,9 @@ async function build(options = {}) {
|
|
|
13
14
|
// Build server-side
|
|
14
15
|
const outputServer = await buildVite(setSSR(viteConfigEnhanced));
|
|
15
16
|
// Pre-render
|
|
16
|
-
if (vikeConfigGlobal
|
|
17
|
-
!vikeConfigGlobal.prerender.disableAutoRun &&
|
|
18
|
-
vikeConfigGlobal.disableAutoFullBuild !== 'prerender') {
|
|
17
|
+
if (isPrerenderAutoRunEnabled(vikeConfigGlobal)) {
|
|
19
18
|
const { runPrerenderFromAutoRun } = await import('../prerender/runPrerender.js');
|
|
20
|
-
await runPrerenderFromAutoRun(viteConfigEnhanced
|
|
19
|
+
await runPrerenderFromAutoRun(viteConfigEnhanced);
|
|
21
20
|
}
|
|
22
21
|
return {
|
|
23
22
|
/* We don't return `viteConfig` because `viteConfigEnhanced` is `InlineConfig` not `ResolvedConfig`
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
export { setOperation };
|
|
2
|
+
export { clearOperation };
|
|
1
3
|
export { isVikeCliOrApi };
|
|
2
|
-
export { setOperation as setOperation };
|
|
3
4
|
import type { Operation } from './types.js';
|
|
4
5
|
declare function isVikeCliOrApi(): boolean;
|
|
5
6
|
declare function setOperation(operation: Operation): void;
|
|
7
|
+
declare function clearOperation(): void;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
export { isVikeCliOrApi };
|
|
2
1
|
// export { getOperation }
|
|
3
|
-
export { setOperation
|
|
2
|
+
export { setOperation };
|
|
3
|
+
export { clearOperation };
|
|
4
|
+
export { isVikeCliOrApi };
|
|
4
5
|
import { assert, getGlobalObject } from './utils.js';
|
|
5
6
|
const globalObject = getGlobalObject('context.ts', {
|
|
6
7
|
apiOperation: undefined
|
|
@@ -17,3 +18,6 @@ function setOperation(operation) {
|
|
|
17
18
|
assert(!globalObject.apiOperation);
|
|
18
19
|
globalObject.apiOperation = operation;
|
|
19
20
|
}
|
|
21
|
+
function clearOperation() {
|
|
22
|
+
globalObject.apiOperation = undefined;
|
|
23
|
+
}
|
|
@@ -6,7 +6,7 @@ import type { InlineConfig, ResolvedConfig } from 'vite';
|
|
|
6
6
|
import type { Operation } from './types.js';
|
|
7
7
|
declare function prepareViteApiCall(viteConfig: InlineConfig | undefined, operation: Operation): Promise<{
|
|
8
8
|
viteConfigEnhanced: InlineConfig | undefined;
|
|
9
|
-
vikeConfigGlobal: import("../plugin/plugins/importUserCode/v1-design/getVikeConfig
|
|
9
|
+
vikeConfigGlobal: import("../plugin/plugins/importUserCode/v1-design/getVikeConfig.js").VikeConfigGlobal;
|
|
10
10
|
}>;
|
|
11
11
|
declare function getViteRoot(operation: 'build' | 'dev' | 'preview' | 'prerender'): Promise<string>;
|
|
12
12
|
declare function normalizeViteRoot(root: string): string;
|
|
@@ -3,26 +3,44 @@ export { getViteRoot };
|
|
|
3
3
|
export { assertViteRoot };
|
|
4
4
|
export { normalizeViteRoot };
|
|
5
5
|
// TODO: enable Vike extensions to add Vite plugins
|
|
6
|
-
import { loadConfigFromFile, resolveConfig } from 'vite';
|
|
7
|
-
import { setOperation } from './context.js';
|
|
6
|
+
import { loadConfigFromFile, mergeConfig, resolveConfig } from 'vite';
|
|
7
|
+
import { clearOperation, setOperation } from './context.js';
|
|
8
8
|
import { getVikeConfig2 } from '../plugin/plugins/importUserCode/v1-design/getVikeConfig.js';
|
|
9
9
|
import path from 'path';
|
|
10
|
-
import { assert, assertUsage, getGlobalObject, toPosixPath } from './utils.js';
|
|
10
|
+
import { assert, assertUsage, getGlobalObject, isObject, toPosixPath } from './utils.js';
|
|
11
11
|
import pc from '@brillout/picocolors';
|
|
12
|
+
import { clearGlobalContext } from '../runtime/globalContext.js';
|
|
12
13
|
const globalObject = getGlobalObject('prepareViteApiCall.ts', {});
|
|
13
14
|
async function prepareViteApiCall(viteConfig, operation) {
|
|
15
|
+
clear();
|
|
14
16
|
setOperation(operation);
|
|
15
17
|
return enhanceViteConfig(viteConfig, operation);
|
|
16
18
|
}
|
|
19
|
+
// For subsequent API calls, e.g. calling prerender() after build()
|
|
20
|
+
function clear() {
|
|
21
|
+
clearOperation();
|
|
22
|
+
clearGlobalContext();
|
|
23
|
+
}
|
|
17
24
|
async function enhanceViteConfig(viteConfig, operation) {
|
|
18
|
-
const
|
|
19
|
-
await assertViteRoot2(root, viteConfigEnhanced, operation);
|
|
20
|
-
const
|
|
25
|
+
const viteInfo = await getInfoFromVite(viteConfig, operation);
|
|
26
|
+
await assertViteRoot2(viteInfo.root, viteInfo.viteConfigEnhanced, operation);
|
|
27
|
+
const vikeConfig = await getVikeConfig2(viteInfo.root, operation === 'dev', viteInfo.vikeVitePluginOptions);
|
|
28
|
+
const viteConfigEnhanced = addViteSettingsSetByVikeConfig(viteInfo.viteConfigEnhanced, vikeConfig);
|
|
21
29
|
return {
|
|
22
30
|
viteConfigEnhanced,
|
|
23
|
-
vikeConfigGlobal
|
|
31
|
+
vikeConfigGlobal: vikeConfig.vikeConfigGlobal
|
|
24
32
|
};
|
|
25
33
|
}
|
|
34
|
+
function addViteSettingsSetByVikeConfig(viteConfigEnhanced, vikeConfig) {
|
|
35
|
+
const viteConfigs = vikeConfig.global.from.configsCumulative.vite;
|
|
36
|
+
if (!viteConfigs)
|
|
37
|
+
return viteConfigEnhanced;
|
|
38
|
+
viteConfigs.values.forEach((v) => {
|
|
39
|
+
assertUsage(isObject(v.value), `${v.definedAt} should be an object`);
|
|
40
|
+
viteConfigEnhanced = mergeConfig(viteConfigEnhanced ?? {}, v.value);
|
|
41
|
+
});
|
|
42
|
+
return viteConfigEnhanced;
|
|
43
|
+
}
|
|
26
44
|
async function getViteRoot(operation) {
|
|
27
45
|
if (!globalObject.root)
|
|
28
46
|
await getInfoFromVite(undefined, operation);
|
|
@@ -3,5 +3,5 @@ export { plugin };
|
|
|
3
3
|
export { plugin as ssr };
|
|
4
4
|
export type { VikeVitePluginOptions as UserConfig };
|
|
5
5
|
export { PROJECT_VERSION as version } from './utils.js';
|
|
6
|
-
import type { VikeVitePluginOptions } from './plugins/importUserCode/v1-design/getVikeConfig
|
|
6
|
+
import type { VikeVitePluginOptions } from './plugins/importUserCode/v1-design/getVikeConfig.js';
|
|
7
7
|
declare function plugin(vikeVitePluginOptions?: VikeVitePluginOptions): any;
|
|
@@ -17,7 +17,7 @@ import { extractAssetsPlugin } from './plugins/extractAssetsPlugin.js';
|
|
|
17
17
|
import { extractExportNamesPlugin } from './plugins/extractExportNamesPlugin.js';
|
|
18
18
|
import { suppressRollupWarning } from './plugins/suppressRollupWarning.js';
|
|
19
19
|
import { setGlobalContext } from './plugins/setGlobalContext.js';
|
|
20
|
-
import {
|
|
20
|
+
import { buildEntry } from './plugins/buildEntry/index.js';
|
|
21
21
|
import { commonConfig } from './plugins/commonConfig.js';
|
|
22
22
|
import { baseUrls } from './plugins/baseUrls.js';
|
|
23
23
|
import { envVarsPlugin } from './plugins/envVars.js';
|
|
@@ -26,7 +26,7 @@ import { fileEnv } from './plugins/fileEnv.js';
|
|
|
26
26
|
import { setResolveClientEntriesDev } from '../runtime/renderPage/getPageAssets.js';
|
|
27
27
|
import { resolveClientEntriesDev } from './resolveClientEntriesDev.js';
|
|
28
28
|
import { workaroundCssModuleHmr } from './plugins/workaroundCssModuleHmr.js';
|
|
29
|
-
import {
|
|
29
|
+
import { workaroundVite6HmrRegression } from './plugins/workaroundVite6HmrRegression.js';
|
|
30
30
|
markSetup_vikeVitePlugin();
|
|
31
31
|
assertViteVersion();
|
|
32
32
|
setResolveClientEntriesDev(resolveClientEntriesDev);
|
|
@@ -46,12 +46,12 @@ function plugin(vikeVitePluginOptions = {}) {
|
|
|
46
46
|
extractExportNamesPlugin(),
|
|
47
47
|
suppressRollupWarning(),
|
|
48
48
|
...setGlobalContext(),
|
|
49
|
-
...
|
|
50
|
-
baseUrls(
|
|
49
|
+
...buildEntry(),
|
|
50
|
+
baseUrls(),
|
|
51
51
|
envVarsPlugin(),
|
|
52
52
|
fileEnv(),
|
|
53
53
|
workaroundCssModuleHmr(),
|
|
54
|
-
|
|
54
|
+
workaroundVite6HmrRegression()
|
|
55
55
|
];
|
|
56
56
|
Object.assign(plugins, { __vikeVitePluginOptions: vikeVitePluginOptions });
|
|
57
57
|
return plugins;
|
|
@@ -3,6 +3,7 @@ export { autoFullBuild };
|
|
|
3
3
|
import { build } from 'vite';
|
|
4
4
|
import { assertWarning } from '../utils.js';
|
|
5
5
|
import { runPrerenderFromAutoRun, runPrerender_forceExit } from '../../prerender/runPrerender.js';
|
|
6
|
+
import { isPrerenderAutoRunEnabled } from '../../prerender/isPrerenderAutoRunEnabled.js';
|
|
6
7
|
import { isViteCliCall, getViteConfigFromCli } from '../shared/isViteCliCall.js';
|
|
7
8
|
import pc from '@brillout/picocolors';
|
|
8
9
|
import { logErrorHint } from '../../runtime/renderPage/logErrorHint.js';
|
|
@@ -90,10 +91,8 @@ async function triggerFullBuild(config, vikeConfigGlobal, bundle) {
|
|
|
90
91
|
logErrorHint(err);
|
|
91
92
|
process.exit(1);
|
|
92
93
|
}
|
|
93
|
-
if (vikeConfigGlobal
|
|
94
|
-
|
|
95
|
-
vikeConfigGlobal.disableAutoFullBuild !== 'prerender') {
|
|
96
|
-
await runPrerenderFromAutoRun(configInline, false);
|
|
94
|
+
if (isPrerenderAutoRunEnabled(vikeConfigGlobal)) {
|
|
95
|
+
await runPrerenderFromAutoRun(configInline);
|
|
97
96
|
forceExit = true;
|
|
98
97
|
}
|
|
99
98
|
}
|