vike 0.4.144-commit-de18325 → 0.4.145-commit-2520555
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 +1 -1
- package/dist/cjs/node/plugin/plugins/config/index.js +3 -3
- package/dist/cjs/node/plugin/plugins/devConfig/determineOptimizeDeps.js +1 -1
- package/dist/cjs/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.js +1 -1
- package/dist/cjs/node/plugin/plugins/importUserCode/index.js +1 -1
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +1 -1
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +5 -2
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js +4 -2
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigs.js +18 -6
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/transpileAndExecuteFile.js +2 -2
- package/dist/cjs/node/prerender/runPrerender.js +17 -8
- package/dist/cjs/node/runtime/renderPage/log404/index.js +2 -1
- package/dist/cjs/node/shared/getConfigVike.js +4 -1
- package/dist/cjs/shared/page-configs/serialize/parseConfigValuesImported.js +8 -5
- package/dist/cjs/shared/route/noRouteMatch.js +4 -0
- package/dist/cjs/utils/isExternalLink.js +7 -0
- package/dist/cjs/utils/onPageVisibilityChange.js +19 -0
- package/dist/cjs/utils/projectInfo.js +1 -1
- package/dist/esm/client/client-routing-runtime/createPageContext.js +0 -1
- package/dist/esm/client/client-routing-runtime/getBaseServer.d.ts +2 -1
- package/dist/esm/client/client-routing-runtime/getBaseServer.js +2 -1
- package/dist/esm/client/client-routing-runtime/getPageContextFromHooks.d.ts +39 -0
- package/dist/esm/client/client-routing-runtime/{getPageContext.js → getPageContextFromHooks.js} +48 -74
- package/dist/esm/client/client-routing-runtime/history.js +9 -5
- package/dist/esm/client/client-routing-runtime/installClientRouter.d.ts +0 -19
- package/dist/esm/client/client-routing-runtime/installClientRouter.js +11 -488
- package/dist/esm/client/client-routing-runtime/isClientSideRoutable.d.ts +3 -3
- package/dist/esm/client/client-routing-runtime/isClientSideRoutable.js +4 -7
- package/dist/esm/client/client-routing-runtime/navigate.js +2 -3
- package/dist/esm/client/client-routing-runtime/onBrowserHistoryNavigation.d.ts +4 -0
- package/dist/esm/client/client-routing-runtime/onBrowserHistoryNavigation.js +63 -0
- package/dist/esm/client/client-routing-runtime/onLinkClick.d.ts +2 -0
- package/dist/esm/client/client-routing-runtime/onLinkClick.js +40 -0
- package/dist/esm/client/client-routing-runtime/prefetch.js +7 -8
- package/dist/esm/client/client-routing-runtime/renderPageClientSide.d.ts +19 -0
- package/dist/esm/client/client-routing-runtime/renderPageClientSide.js +347 -0
- package/dist/esm/client/client-routing-runtime/scrollRestoration.d.ts +6 -0
- package/dist/esm/client/client-routing-runtime/scrollRestoration.js +25 -0
- package/dist/esm/client/client-routing-runtime/setScrollPosition.d.ts +7 -0
- package/dist/esm/client/client-routing-runtime/setScrollPosition.js +77 -0
- package/dist/esm/client/client-routing-runtime/skipLink.js +9 -4
- package/dist/esm/client/client-routing-runtime/utils.d.ts +2 -0
- package/dist/esm/client/client-routing-runtime/utils.js +2 -0
- package/dist/esm/node/plugin/plugins/buildConfig.js +2 -2
- package/dist/esm/node/plugin/plugins/config/index.js +4 -4
- package/dist/esm/node/plugin/plugins/devConfig/determineOptimizeDeps.js +2 -2
- package/dist/esm/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.js +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/index.js +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.d.ts +2 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +6 -3
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.d.ts +2 -2
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js +4 -2
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigs.d.ts +2 -2
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigs.js +18 -6
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/transpileAndExecuteFile.js +3 -3
- package/dist/esm/node/prerender/runPrerender.js +17 -8
- package/dist/esm/node/runtime/renderPage/log404/index.js +2 -1
- package/dist/esm/node/shared/getConfigVike.d.ts +2 -1
- package/dist/esm/node/shared/getConfigVike.js +4 -1
- package/dist/esm/shared/page-configs/serialize/parseConfigValuesImported.js +9 -3
- package/dist/esm/shared/route/noRouteMatch.d.ts +1 -0
- package/dist/esm/shared/route/noRouteMatch.js +1 -0
- package/dist/esm/utils/onPageVisibilityChange.d.ts +4 -0
- package/dist/esm/utils/onPageVisibilityChange.js +16 -0
- package/dist/esm/utils/projectInfo.d.ts +1 -1
- package/dist/esm/utils/projectInfo.js +1 -1
- package/node/cli/bin-entry.js +1 -1
- package/package.json +1 -1
- package/dist/esm/client/client-routing-runtime/getPageContext.d.ts +0 -28
- package/dist/esm/client/client-routing-runtime/navigationState.d.ts +0 -5
- package/dist/esm/client/client-routing-runtime/navigationState.js +0 -14
- /package/dist/esm/{client/client-routing-runtime → utils}/isExternalLink.d.ts +0 -0
- /package/dist/esm/{client/client-routing-runtime → utils}/isExternalLink.js +0 -0
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
export { determineOptimizeDeps };
|
|
2
2
|
import { findPageFiles } from '../../shared/findPageFiles.js';
|
|
3
|
-
import { assert, getFilePathAbsolute,
|
|
3
|
+
import { assert, getFilePathAbsolute, isNotNullish, isNpmPackageImport, unique } from '../../utils.js';
|
|
4
4
|
import { getVikeConfig } from '../importUserCode/v1-design/getVikeConfig.js';
|
|
5
5
|
import { getConfigValueSourcesRelevant } from '../../shared/getConfigValueSourcesRelevant.js';
|
|
6
6
|
import { analyzeClientEntries } from '../buildConfig.js';
|
|
7
7
|
import { virtualFileIdImportUserCodeClientCR, virtualFileIdImportUserCodeClientSR } from '../../../shared/virtual-files/virtualFileImportUserCode.js';
|
|
8
8
|
async function determineOptimizeDeps(config, configVike, isDev) {
|
|
9
|
-
const { pageConfigs } = await getVikeConfig(config
|
|
9
|
+
const { pageConfigs } = await getVikeConfig(config, isDev);
|
|
10
10
|
const { entries, include } = await getPageDeps(config, pageConfigs, isDev);
|
|
11
11
|
{
|
|
12
12
|
// This actually doesn't work: Vite's dep optimizer doesn't seem to be able to crawl virtual files.
|
|
@@ -140,7 +140,7 @@ export const pageFilesList = [];
|
|
|
140
140
|
export const neverLoaded = {};
|
|
141
141
|
export const isGeneratedFile = true;
|
|
142
142
|
|
|
143
|
-
${await getVirtualFilePageConfigs(
|
|
143
|
+
${await getVirtualFilePageConfigs(isForClientSide, isDev, id, isClientRouting, config)}
|
|
144
144
|
|
|
145
145
|
`;
|
|
146
146
|
fileTypes
|
|
@@ -47,7 +47,7 @@ function importUserCode() {
|
|
|
47
47
|
return undefined;
|
|
48
48
|
id = getVirtualFileId(id);
|
|
49
49
|
if (isVirtualFileIdPageConfigValuesAll(id)) {
|
|
50
|
-
const code = await getVirtualFilePageConfigValuesAll(id,
|
|
50
|
+
const code = await getVirtualFilePageConfigValuesAll(id, isDev, config);
|
|
51
51
|
return code;
|
|
52
52
|
}
|
|
53
53
|
if (isVirtualFileIdImportUserCode(id)) {
|
|
@@ -4,6 +4,7 @@ export { vikeConfigDependencies };
|
|
|
4
4
|
export { isVikeConfigFile };
|
|
5
5
|
import type { PageConfigGlobalBuildTime, PageConfigBuildTime } from '../../../../../shared/page-configs/PageConfig.js';
|
|
6
6
|
import type { ExtensionResolved } from '../../../../../shared/ConfigVike.js';
|
|
7
|
+
import type { ResolvedConfig } from 'vite';
|
|
7
8
|
type VikeConfig = {
|
|
8
9
|
pageConfigs: PageConfigBuildTime[];
|
|
9
10
|
pageConfigGlobal: PageConfigGlobalBuildTime;
|
|
@@ -11,5 +12,5 @@ type VikeConfig = {
|
|
|
11
12
|
};
|
|
12
13
|
declare const vikeConfigDependencies: Set<string>;
|
|
13
14
|
declare function reloadVikeConfig(userRootDir: string, outDirRoot: string, extensions: ExtensionResolved[]): void;
|
|
14
|
-
declare function getVikeConfig(
|
|
15
|
+
declare function getVikeConfig(config: ResolvedConfig, isDev: boolean, tolerateInvalidConfig?: boolean, extensions?: ExtensionResolved[]): Promise<VikeConfig>;
|
|
15
16
|
declare function isVikeConfigFile(filePath: string): boolean;
|
|
@@ -2,7 +2,7 @@ export { getVikeConfig };
|
|
|
2
2
|
export { reloadVikeConfig };
|
|
3
3
|
export { vikeConfigDependencies };
|
|
4
4
|
export { isVikeConfigFile };
|
|
5
|
-
import { assertPosixPath, assert, isObject, assertUsage, toPosixPath, assertWarning, objectEntries, hasProp, arrayIncludes, assertIsNotProductionRuntime, getMostSimilar, isNpmPackageImport, joinEnglish, lowerFirst, scriptFileExtensions, mergeCumulativeValues, requireResolve } from '../../../utils.js';
|
|
5
|
+
import { assertPosixPath, assert, isObject, assertUsage, toPosixPath, assertWarning, objectEntries, hasProp, arrayIncludes, assertIsNotProductionRuntime, getMostSimilar, isNpmPackageImport, joinEnglish, lowerFirst, scriptFileExtensions, mergeCumulativeValues, requireResolve, getOutDirs } from '../../../utils.js';
|
|
6
6
|
import path from 'path';
|
|
7
7
|
import { configDefinitionsBuiltIn, configDefinitionsBuiltInGlobal } from './getVikeConfig/configDefinitionsBuiltIn.js';
|
|
8
8
|
import glob from 'fast-glob';
|
|
@@ -17,6 +17,7 @@ import pc from '@brillout/picocolors';
|
|
|
17
17
|
import { getConfigDefinedAtString } from '../../../../../shared/page-configs/helpers.js';
|
|
18
18
|
import { assertExportsOfConfigFile, assertExportsOfValueFile } from '../../../../../shared/page-configs/assertExports.js';
|
|
19
19
|
import { getConfigValueSerialized } from './getVirtualFilePageConfigs.js';
|
|
20
|
+
import { getConfigVike } from '../../../../shared/getConfigVike.js';
|
|
20
21
|
assertIsNotProductionRuntime();
|
|
21
22
|
let devServerIsCorrupt = false;
|
|
22
23
|
let wasConfigInvalid = null;
|
|
@@ -60,9 +61,11 @@ async function handleReloadSideEffects() {
|
|
|
60
61
|
}
|
|
61
62
|
}
|
|
62
63
|
}
|
|
63
|
-
async function getVikeConfig(
|
|
64
|
+
async function getVikeConfig(config, isDev, tolerateInvalidConfig = false, extensions) {
|
|
65
|
+
const { outDirRoot } = getOutDirs(config);
|
|
66
|
+
const userRootDir = config.root;
|
|
64
67
|
if (!vikeConfigPromise) {
|
|
65
|
-
vikeConfigPromise = loadVikeConfig_withErrorHandling(userRootDir, outDirRoot, isDev, extensions, tolerateInvalidConfig);
|
|
68
|
+
vikeConfigPromise = loadVikeConfig_withErrorHandling(userRootDir, outDirRoot, isDev, extensions ?? (await getConfigVike(config)).extensions, tolerateInvalidConfig);
|
|
66
69
|
}
|
|
67
70
|
return await vikeConfigPromise;
|
|
68
71
|
}
|
package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { getVirtualFilePageConfigValuesAll };
|
|
2
|
-
import type {
|
|
3
|
-
declare function getVirtualFilePageConfigValuesAll(id: string,
|
|
2
|
+
import type { ResolvedConfig } from 'vite';
|
|
3
|
+
declare function getVirtualFilePageConfigValuesAll(id: string, isDev: boolean, config: ResolvedConfig): Promise<string>;
|
package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js
CHANGED
|
@@ -8,7 +8,8 @@ import { getConfigValue } from '../../../../../shared/page-configs/helpers.js';
|
|
|
8
8
|
import { getConfigValueSourcesRelevant } from '../../../shared/getConfigValueSourcesRelevant.js';
|
|
9
9
|
import { isRuntimeEnvMatch } from './isRuntimeEnvMatch.js';
|
|
10
10
|
import { serializeConfigValueImported } from '../../../../../shared/page-configs/serialize/serializeConfigValue.js';
|
|
11
|
-
|
|
11
|
+
import { getConfigVike } from '../../../../shared/getConfigVike.js';
|
|
12
|
+
async function getVirtualFilePageConfigValuesAll(id, isDev, config) {
|
|
12
13
|
const result = isVirtualFileIdPageConfigValuesAll(id);
|
|
13
14
|
assert(result);
|
|
14
15
|
/* This assertion fails when using includeAssetsImportedByServer
|
|
@@ -18,9 +19,10 @@ async function getVirtualFilePageConfigValuesAll(id, userRootDir, outDirRoot, is
|
|
|
18
19
|
}
|
|
19
20
|
*/
|
|
20
21
|
const { pageId, isForClientSide } = result;
|
|
21
|
-
const { pageConfigs } = await getVikeConfig(
|
|
22
|
+
const { pageConfigs } = await getVikeConfig(config, isDev, true);
|
|
22
23
|
const pageConfig = pageConfigs.find((pageConfig) => pageConfig.pageId === pageId);
|
|
23
24
|
assert(pageConfig);
|
|
25
|
+
const configVike = await getConfigVike(config);
|
|
24
26
|
const code = getLoadConfigValuesAll(pageConfig, isForClientSide, pageId, configVike.includeAssetsImportedByServer, isDev);
|
|
25
27
|
debug(id, isForClientSide ? 'CLIENT-SIDE' : 'SERVER-SIDE', code);
|
|
26
28
|
return code;
|
package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigs.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { getVirtualFilePageConfigs };
|
|
2
2
|
export { getConfigValueSerialized };
|
|
3
3
|
import type { DefinedAt } from '../../../../../shared/page-configs/PageConfig.js';
|
|
4
|
-
import type {
|
|
5
|
-
declare function getVirtualFilePageConfigs(
|
|
4
|
+
import type { ResolvedConfig } from 'vite';
|
|
5
|
+
declare function getVirtualFilePageConfigs(isForClientSide: boolean, isDev: boolean, id: string, isClientRouting: boolean, config: ResolvedConfig): Promise<string>;
|
|
6
6
|
declare function getConfigValueSerialized(value: unknown, configName: string, definedAt: DefinedAt): string;
|
|
@@ -10,14 +10,22 @@ import { getVikeConfig } from './getVikeConfig.js';
|
|
|
10
10
|
import { isRuntimeEnvMatch } from './isRuntimeEnvMatch.js';
|
|
11
11
|
import { getConfigValueFilePathToShowToUser } from '../../../../../shared/page-configs/helpers.js';
|
|
12
12
|
import { serializeConfigValue, serializeConfigValueImported } from '../../../../../shared/page-configs/serialize/serializeConfigValue.js';
|
|
13
|
-
async function getVirtualFilePageConfigs(
|
|
14
|
-
const { pageConfigs, pageConfigGlobal } = await getVikeConfig(
|
|
15
|
-
return
|
|
13
|
+
async function getVirtualFilePageConfigs(isForClientSide, isDev, id, isClientRouting, config) {
|
|
14
|
+
const { pageConfigs, pageConfigGlobal } = await getVikeConfig(config, isDev, true);
|
|
15
|
+
return getCode(pageConfigs, pageConfigGlobal, isForClientSide, isDev, id, isClientRouting);
|
|
16
16
|
}
|
|
17
|
-
function
|
|
17
|
+
function getCode(pageConfigs, pageConfigGlobal, isForClientSide, isDev, id, isClientRouting) {
|
|
18
18
|
const lines = [];
|
|
19
19
|
const importStatements = [];
|
|
20
20
|
const varCounterContainer = { varCounter: 0 };
|
|
21
|
+
lines.push(getCodePageConfigsSerialized(pageConfigs, isForClientSide, isClientRouting, importStatements, varCounterContainer));
|
|
22
|
+
lines.push(getCodePageConfigGlobalSerialized(pageConfigGlobal, isForClientSide, isDev, importStatements, varCounterContainer));
|
|
23
|
+
const code = [...importStatements, ...lines].join('\n');
|
|
24
|
+
debug(id, isForClientSide ? 'CLIENT-SIDE' : 'SERVER-SIDE', code);
|
|
25
|
+
return code;
|
|
26
|
+
}
|
|
27
|
+
function getCodePageConfigsSerialized(pageConfigs, isForClientSide, isClientRouting, importStatements, varCounterContainer) {
|
|
28
|
+
const lines = [];
|
|
21
29
|
lines.push('export const pageConfigsSerialized = [');
|
|
22
30
|
pageConfigs.forEach((pageConfig) => {
|
|
23
31
|
const { pageId, routeFilesystem, isErrorPage } = pageConfig;
|
|
@@ -71,6 +79,11 @@ function getContent(pageConfigs, pageConfigGlobal, isForClientSide, isDev, id, i
|
|
|
71
79
|
lines.push(` },`);
|
|
72
80
|
});
|
|
73
81
|
lines.push('];');
|
|
82
|
+
const code = lines.join('\n');
|
|
83
|
+
return code;
|
|
84
|
+
}
|
|
85
|
+
function getCodePageConfigGlobalSerialized(pageConfigGlobal, isForClientSide, isDev, importStatements, varCounterContainer) {
|
|
86
|
+
const lines = [];
|
|
74
87
|
lines.push('export const pageConfigGlobalSerialized = {');
|
|
75
88
|
/* Nothing (yet)
|
|
76
89
|
lines.push(` configValuesSerialized: {`)
|
|
@@ -97,8 +110,7 @@ function getContent(pageConfigs, pageConfigGlobal, isForClientSide, isDev, id, i
|
|
|
97
110
|
});
|
|
98
111
|
lines.push(` ],`);
|
|
99
112
|
lines.push('};');
|
|
100
|
-
const code =
|
|
101
|
-
debug(id, isForClientSide ? 'CLIENT-SIDE' : 'SERVER-SIDE', code);
|
|
113
|
+
const code = lines.join('\n');
|
|
102
114
|
return code;
|
|
103
115
|
}
|
|
104
116
|
function getConfigValueSerialized(value, configName, definedAt) {
|
|
@@ -7,7 +7,7 @@ import fs from 'fs';
|
|
|
7
7
|
import path from 'path';
|
|
8
8
|
import pc from '@brillout/picocolors';
|
|
9
9
|
import { import_ } from '@brillout/import';
|
|
10
|
-
import { assertPosixPath, getRandomId, assertIsNotProductionRuntime, assert, unique, assertWarning, isObject, toPosixPath
|
|
10
|
+
import { assertPosixPath, getRandomId, assertIsNotProductionRuntime, assert, unique, assertWarning, isObject, toPosixPath } from '../../../utils.js';
|
|
11
11
|
import { isImportData, replaceImportStatements } from './replaceImportStatements.js';
|
|
12
12
|
import { vikeConfigDependencies } from './getVikeConfig.js';
|
|
13
13
|
import 'source-map-support/register.js';
|
|
@@ -226,11 +226,11 @@ function assertImportsAreReExported(fileImports, fileExports, filePathToShowToUs
|
|
|
226
226
|
const importStatements = unique(fileImportsUnused.map((fi) => fi.importStatementCode));
|
|
227
227
|
const importNamesUnused = fileImportsUnused.map((fi) => pc.cyan(fi.importLocalName)).join(', ');
|
|
228
228
|
const singular = fileImportsUnused.length === 1;
|
|
229
|
-
|
|
229
|
+
assertWarning(fileImportsUnused.length === 0, [
|
|
230
230
|
`${filePathToShowToUser} imports the following:`,
|
|
231
231
|
...importStatements.map((s) => pc.cyan(` ${s}`)),
|
|
232
232
|
`But the import${singular ? '' : 's'} ${importNamesUnused} ${singular ? "isn't" : "aren't"} re-exported at ${pc.cyan('export default { ... }')} and therefore ${singular ? 'has' : 'have'} no effect, see explanation at https://vike.dev/header-file`
|
|
233
|
-
].join('\n'));
|
|
233
|
+
].join('\n'), { onlyOnce: true });
|
|
234
234
|
}
|
|
235
235
|
function getExportedStrings(obj) {
|
|
236
236
|
const exportedStrings = [];
|
|
@@ -24,6 +24,8 @@ import { assertPathIsFilesystemAbsolute } from '../../utils/assertPathIsFilesyst
|
|
|
24
24
|
import { isAbortError } from '../../shared/route/abort.js';
|
|
25
25
|
import { loadPageFilesServerSide } from '../runtime/renderPage/loadPageFilesServerSide.js';
|
|
26
26
|
import { assertHookFn } from '../../shared/hooks/getHook.js';
|
|
27
|
+
import { noRouteMatch } from '../../shared/route/noRouteMatch.js';
|
|
28
|
+
import { getVikeConfig } from '../plugin/plugins/importUserCode/v1-design/getVikeConfig.js';
|
|
27
29
|
async function prerenderFromAPI(options = {}) {
|
|
28
30
|
await runPrerender(options, 'prerender()');
|
|
29
31
|
}
|
|
@@ -67,7 +69,8 @@ async function runPrerender(options, manuallyTriggered) {
|
|
|
67
69
|
pageContextInit: options.pageContextInit ?? null
|
|
68
70
|
});
|
|
69
71
|
const doNotPrerenderList = [];
|
|
70
|
-
await
|
|
72
|
+
const vikeConfig = await getVikeConfig(viteConfig, false);
|
|
73
|
+
await collectDoNoPrerenderList(renderContext, vikeConfig.pageConfigs, doNotPrerenderList, concurrencyLimit);
|
|
71
74
|
await callOnBeforePrerenderStartHooks(prerenderContext, renderContext, concurrencyLimit);
|
|
72
75
|
await handlePagesWithStaticRoutes(prerenderContext, renderContext, doNotPrerenderList, concurrencyLimit);
|
|
73
76
|
await callOnPrerenderStartHook(prerenderContext, renderContext);
|
|
@@ -82,8 +85,9 @@ async function runPrerender(options, manuallyTriggered) {
|
|
|
82
85
|
await Promise.all(htmlFiles.map((htmlFile) => writeHtmlFile(htmlFile, root, outDirClient, concurrencyLimit, options.onPagePrerender, logLevel)));
|
|
83
86
|
warnMissingPages(prerenderPageIds, doNotPrerenderList, renderContext, partial);
|
|
84
87
|
}
|
|
85
|
-
async function collectDoNoPrerenderList(renderContext, doNotPrerenderList, concurrencyLimit) {
|
|
86
|
-
|
|
88
|
+
async function collectDoNoPrerenderList(renderContext, pageConfigs, doNotPrerenderList, concurrencyLimit) {
|
|
89
|
+
// V1 design
|
|
90
|
+
pageConfigs.forEach((pageConfig) => {
|
|
87
91
|
const configName = 'prerender';
|
|
88
92
|
const configValue = getConfigValue(pageConfig, configName, 'boolean');
|
|
89
93
|
if (configValue?.value === false) {
|
|
@@ -97,6 +101,8 @@ async function collectDoNoPrerenderList(renderContext, doNotPrerenderList, concu
|
|
|
97
101
|
});
|
|
98
102
|
}
|
|
99
103
|
});
|
|
104
|
+
// Old design
|
|
105
|
+
// TODO/v1-release: remove
|
|
100
106
|
await Promise.all(renderContext.pageFilesAll
|
|
101
107
|
.filter((p) => {
|
|
102
108
|
assertExportNames(p);
|
|
@@ -422,7 +428,7 @@ async function routeAndPrerender(prerenderContext, htmlFiles, prerenderPageIds,
|
|
|
422
428
|
}
|
|
423
429
|
if (hookName) {
|
|
424
430
|
assert(hookFilePath);
|
|
425
|
-
assertUsage(false, `The ${hookName}() hook defined by ${hookFilePath} returns a URL ${pc.cyan(urlOriginal)} that
|
|
431
|
+
assertUsage(false, `The ${hookName}() hook defined by ${hookFilePath} returns a URL ${pc.cyan(urlOriginal)} that ${noRouteMatch}. Make sure that the URLs returned by ${hookName}() always match the route of a page.`);
|
|
426
432
|
}
|
|
427
433
|
else {
|
|
428
434
|
// `prerenderHookFile` is `null` when the URL was deduced by the Filesytem Routing of `.page.js` files. The `onBeforeRoute()` can override Filesystem Routing; it is therefore expected that the deduced URL may not match any page.
|
|
@@ -486,15 +492,18 @@ function warnContradictoryNoPrerenderList(prerenderPageIds, doNotPrerenderList)
|
|
|
486
492
|
}
|
|
487
493
|
function warnMissingPages(prerenderPageIds, doNotPrerenderList, renderContext, partial) {
|
|
488
494
|
const isV1 = renderContext.pageConfigs.length > 0;
|
|
489
|
-
const hookName = isV1 ? '
|
|
490
|
-
|
|
495
|
+
const hookName = isV1 ? 'onBeforePrerenderStart' : 'prerender';
|
|
496
|
+
/* TODO/after-v1-design-release: document setting `prerender: false` as an alternative to using prerender.partial (both in the warnings and the docs)
|
|
497
|
+
const optOutName = isV1 ? 'prerender' : 'doNotPrerender'
|
|
498
|
+
const msgAddendum = `Explicitly opt-out by setting the config ${optOutName} to ${isV1 ? 'false' : 'true'} or use the option prerender.partial`
|
|
499
|
+
*/
|
|
491
500
|
renderContext.allPageIds
|
|
492
501
|
.filter((pageId) => !prerenderPageIds[pageId])
|
|
493
502
|
.filter((pageId) => !doNotPrerenderList.find((p) => p.pageId === pageId))
|
|
494
503
|
.filter((pageId) => !isErrorPage(pageId, renderContext.pageConfigs))
|
|
495
504
|
.forEach((pageId) => {
|
|
496
|
-
const pageAt =
|
|
497
|
-
assertWarning(partial, `Cannot pre-render page ${pageAt} because it has a non-static route,
|
|
505
|
+
const pageAt = isV1 ? pageId : `\`${pageId}.page.*\``;
|
|
506
|
+
assertWarning(partial, `Cannot pre-render page ${pageAt} because it has a non-static route, while no ${hookName}() hook returned any URL matching the page's route. You need to use a ${hookName}() hook (https://vike.dev/${hookName}) providing a list of URLs for ${pageAt} that should be pre-rendered. If you don't want to pre-render ${pageAt} then use the option prerender.partial (https://vike.dev/prerender-config#partial) to suppress this warning.`, { onlyOnce: true });
|
|
498
507
|
});
|
|
499
508
|
}
|
|
500
509
|
async function prerender404(htmlFiles, renderContext, prerenderContext) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { log404 };
|
|
2
2
|
// Exported for ./index.spec.ts
|
|
3
3
|
export { getRoutesInfo };
|
|
4
|
+
import { noRouteMatch } from '../../../../shared/route/noRouteMatch.js';
|
|
4
5
|
import { getGlobalContext } from '../../globalContext.js';
|
|
5
6
|
import { assert, assertUsage, assertInfo, compareString, stripAnsi, getTerminalWidth, truncateString } from '../../utils.js';
|
|
6
7
|
import pc from '@brillout/picocolors';
|
|
@@ -15,7 +16,7 @@ async function log404(pageContext) {
|
|
|
15
16
|
const globalContext = getGlobalContext();
|
|
16
17
|
if (!globalContext.isProduction && !isFileRequest(urlPathname) && !pageContext.isClientSideNavigation) {
|
|
17
18
|
const routesInfo = getRoutesInfo(pageRoutes);
|
|
18
|
-
let msg = `URL ${pc.cyan(urlPathname)}
|
|
19
|
+
let msg = `URL ${pc.cyan(urlPathname)} ${noRouteMatch}`;
|
|
19
20
|
const outro = 'See https://vike.dev/routing for more information about routing.';
|
|
20
21
|
if (!routesInfo) {
|
|
21
22
|
msg = `${msg}. ${pc.dim(outro)}`;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { getConfigVike };
|
|
2
|
+
import { ResolvedConfig } from 'vite';
|
|
2
3
|
import type { ConfigVikeResolved } from '../../shared/ConfigVike.js';
|
|
3
|
-
declare function getConfigVike(config:
|
|
4
|
+
declare function getConfigVike(config: ResolvedConfig): Promise<ConfigVikeResolved>;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
export { getConfigVike };
|
|
2
|
+
import { assert } from './utils.js';
|
|
2
3
|
async function getConfigVike(config) {
|
|
3
|
-
const
|
|
4
|
+
const { configVikePromise } = config;
|
|
5
|
+
assert(configVikePromise);
|
|
6
|
+
const configVike = await configVikePromise;
|
|
4
7
|
return configVike;
|
|
5
8
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
export { parseConfigValuesImported };
|
|
2
|
-
import { assert
|
|
2
|
+
import { assert } from '../../utils.js';
|
|
3
3
|
import { assertExportsOfValueFile } from '../assertExports.js';
|
|
4
|
-
import pc from '@brillout/picocolors';
|
|
5
4
|
function parseConfigValuesImported(configValuesImported) {
|
|
6
5
|
const configValues = {};
|
|
7
6
|
const addConfigValue = (configName, value, importPath, exportName) => {
|
|
@@ -44,5 +43,12 @@ function parseConfigValuesImported(configValuesImported) {
|
|
|
44
43
|
}
|
|
45
44
|
function assertIsNotNull(configValue, configName, importPath) {
|
|
46
45
|
assert(!importPath.includes('+config.'));
|
|
47
|
-
|
|
46
|
+
/* Re-use this for:
|
|
47
|
+
* - upcoming config.requestPageContextOnNavigation
|
|
48
|
+
* - for cumulative values in the future: we don't need this for now because, currently, cumulative values are never imported.
|
|
49
|
+
assertUsage(
|
|
50
|
+
configValue !== null,
|
|
51
|
+
`Set ${pc.cyan(configName)} to ${pc.cyan('null')} in a +config.h.js file instead of ${importPath}`
|
|
52
|
+
)
|
|
53
|
+
*/
|
|
48
54
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const noRouteMatch = "doesn't match the route of any of your pages";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const noRouteMatch = "doesn't match the route of any of your pages";
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export { onPageHide };
|
|
2
|
+
export { onPageShow };
|
|
3
|
+
function onPageHide(listener) {
|
|
4
|
+
window.addEventListener('visibilitychange', () => {
|
|
5
|
+
if (document.visibilityState === 'hidden') {
|
|
6
|
+
listener();
|
|
7
|
+
}
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
function onPageShow(listener) {
|
|
11
|
+
window.addEventListener('visibilitychange', () => {
|
|
12
|
+
if (document.visibilityState === 'visible') {
|
|
13
|
+
listener();
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
}
|
|
@@ -5,7 +5,7 @@ type ProjectVersion = typeof projectInfo.projectVersion;
|
|
|
5
5
|
type ProjectTag = `[${PackageName}]` | `[${PackageName}@${ProjectVersion}]`;
|
|
6
6
|
declare const projectInfo: {
|
|
7
7
|
projectName: "Vike";
|
|
8
|
-
projectVersion: "0.4.
|
|
8
|
+
projectVersion: "0.4.145-commit-2520555";
|
|
9
9
|
npmPackageName: "vike";
|
|
10
10
|
githubRepository: "https://github.com/vikejs/vike";
|
|
11
11
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { projectInfo };
|
|
2
2
|
import { onProjectInfo } from './assertSingleInstance.js';
|
|
3
|
-
const PROJECT_VERSION = '0.4.
|
|
3
|
+
const PROJECT_VERSION = '0.4.145-commit-2520555';
|
|
4
4
|
const projectInfo = {
|
|
5
5
|
projectName: 'Vike',
|
|
6
6
|
projectVersion: PROJECT_VERSION,
|
package/node/cli/bin-entry.js
CHANGED
package/package.json
CHANGED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
export { getPageContext };
|
|
2
|
-
export { getPageContextErrorPage };
|
|
3
|
-
export { checkIf404 };
|
|
4
|
-
export { isAlreadyServerSideRouted };
|
|
5
|
-
import type { PageContextExports, PageFile } from '../../shared/getPageFiles.js';
|
|
6
|
-
import type { PageContextUrlComputedPropsInternal } from '../../shared/addUrlComputedProps.js';
|
|
7
|
-
import { PageContextForRoute } from '../../shared/route/index.js';
|
|
8
|
-
import type { PageConfigRuntime } from '../../shared/page-configs/PageConfig.js';
|
|
9
|
-
import type { PageContextForPassToClientWarning } from '../shared/getPageContextProxyForUser.js';
|
|
10
|
-
type PageContextAddendum = {
|
|
11
|
-
_pageId: string;
|
|
12
|
-
isHydration: boolean;
|
|
13
|
-
_pageFilesLoaded: PageFile[];
|
|
14
|
-
} & PageContextExports & PageContextForPassToClientWarning;
|
|
15
|
-
type PageContextPassThrough = PageContextUrlComputedPropsInternal & PageContextForRoute & {
|
|
16
|
-
isBackwardNavigation: boolean | null;
|
|
17
|
-
};
|
|
18
|
-
declare function getPageContext(pageContext: {
|
|
19
|
-
_isFirstRenderAttempt: boolean;
|
|
20
|
-
} & PageContextPassThrough): Promise<PageContextAddendum>;
|
|
21
|
-
declare function getPageContextErrorPage(pageContext: {
|
|
22
|
-
urlOriginal: string;
|
|
23
|
-
_allPageIds: string[];
|
|
24
|
-
_pageFilesAll: PageFile[];
|
|
25
|
-
_pageConfigs: PageConfigRuntime[];
|
|
26
|
-
} & PageContextPassThrough): Promise<PageContextAddendum>;
|
|
27
|
-
declare function checkIf404(err: unknown): boolean;
|
|
28
|
-
declare function isAlreadyServerSideRouted(err: unknown): boolean;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { getCurrentUrl, getGlobalObject } from '../server-routing-runtime/utils.js';
|
|
2
|
-
const globalObject = getGlobalObject('navigationState.ts', {});
|
|
3
|
-
const urlFirst = getCurrentUrl();
|
|
4
|
-
export const navigationState = {
|
|
5
|
-
markNavigationChange() {
|
|
6
|
-
globalObject.navigationChanged = true;
|
|
7
|
-
},
|
|
8
|
-
get noNavigationChangeYet() {
|
|
9
|
-
return !globalObject.navigationChanged && this.isFirstUrl(getCurrentUrl());
|
|
10
|
-
},
|
|
11
|
-
isFirstUrl(url) {
|
|
12
|
-
return url === urlFirst;
|
|
13
|
-
}
|
|
14
|
-
};
|
|
File without changes
|
|
File without changes
|