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
|
@@ -73,7 +73,7 @@ exports.buildConfig = buildConfig;
|
|
|
73
73
|
async function getEntries(config) {
|
|
74
74
|
const configVike = await (0, getConfigVike_js_1.getConfigVike)(config);
|
|
75
75
|
const pageFileEntries = await getPageFileEntries(config, configVike.includeAssetsImportedByServer); // TODO/v1-release: remove
|
|
76
|
-
const { pageConfigs } = await (0, getVikeConfig_js_1.getVikeConfig)(config
|
|
76
|
+
const { pageConfigs } = await (0, getVikeConfig_js_1.getVikeConfig)(config, false);
|
|
77
77
|
(0, utils_js_1.assertUsage)(Object.keys(pageFileEntries).length !== 0 || pageConfigs.length !== 0, 'At least one page should be defined, see https://vike.dev/add');
|
|
78
78
|
if ((0, utils_js_1.viteIsSSR)(config)) {
|
|
79
79
|
const serverEntries = analyzeServerEntries(pageConfigs);
|
|
@@ -17,20 +17,20 @@ function resolveVikeConfig(vikeConfig) {
|
|
|
17
17
|
name: 'vike:resolveVikeConfig',
|
|
18
18
|
enforce: 'pre',
|
|
19
19
|
async configResolved(config) {
|
|
20
|
-
const promise =
|
|
20
|
+
const promise = getConfigVikPromise(vikeConfig, config);
|
|
21
21
|
config.configVikePromise = promise;
|
|
22
22
|
await promise;
|
|
23
23
|
}
|
|
24
24
|
};
|
|
25
25
|
}
|
|
26
26
|
exports.resolveVikeConfig = resolveVikeConfig;
|
|
27
|
-
async function
|
|
27
|
+
async function getConfigVikPromise(vikeConfig, config) {
|
|
28
28
|
const fromPluginOptions = (vikeConfig ?? {});
|
|
29
29
|
const fromViteConfig = (config.vike ?? {});
|
|
30
30
|
const fromStemPackages = await (0, findConfigVikeFromStemPackages_js_1.findConfigVikeFromStemPackages)(config.root);
|
|
31
31
|
const configs = [fromPluginOptions, ...fromStemPackages, fromViteConfig];
|
|
32
32
|
const extensions = (0, resolveExtensions_js_1.resolveExtensions)(configs, config);
|
|
33
|
-
const { globalVikeConfig: fromPlusConfigFile } = await (0, getVikeConfig_js_1.getVikeConfig)(config
|
|
33
|
+
const { globalVikeConfig: fromPlusConfigFile } = await (0, getVikeConfig_js_1.getVikeConfig)(config, (0, utils_js_1.isDev2)(config), false, extensions);
|
|
34
34
|
configs.push(fromPlusConfigFile);
|
|
35
35
|
(0, assertVikeConfig_js_1.assertVikeConfig)(fromPlusConfigFile, ({ prop, errMsg }) => {
|
|
36
36
|
// TODO: add config file path ?
|
|
@@ -8,7 +8,7 @@ const getConfigValueSourcesRelevant_js_1 = require("../../shared/getConfigValueS
|
|
|
8
8
|
const buildConfig_js_1 = require("../buildConfig.js");
|
|
9
9
|
const virtualFileImportUserCode_js_1 = require("../../../shared/virtual-files/virtualFileImportUserCode.js");
|
|
10
10
|
async function determineOptimizeDeps(config, configVike, isDev) {
|
|
11
|
-
const { pageConfigs } = await (0, getVikeConfig_js_1.getVikeConfig)(config
|
|
11
|
+
const { pageConfigs } = await (0, getVikeConfig_js_1.getVikeConfig)(config, isDev);
|
|
12
12
|
const { entries, include } = await getPageDeps(config, pageConfigs, isDev);
|
|
13
13
|
{
|
|
14
14
|
// This actually doesn't work: Vite's dep optimizer doesn't seem to be able to crawl virtual files.
|
|
@@ -146,7 +146,7 @@ export const pageFilesList = [];
|
|
|
146
146
|
export const neverLoaded = {};
|
|
147
147
|
export const isGeneratedFile = true;
|
|
148
148
|
|
|
149
|
-
${await (0, getVirtualFilePageConfigs_js_1.getVirtualFilePageConfigs)(
|
|
149
|
+
${await (0, getVirtualFilePageConfigs_js_1.getVirtualFilePageConfigs)(isForClientSide, isDev, id, isClientRouting, config)}
|
|
150
150
|
|
|
151
151
|
`;
|
|
152
152
|
fileTypes_js_1.fileTypes
|
|
@@ -52,7 +52,7 @@ function importUserCode() {
|
|
|
52
52
|
return undefined;
|
|
53
53
|
id = (0, utils_js_1.getVirtualFileId)(id);
|
|
54
54
|
if ((0, virtualFilePageConfigValuesAll_js_1.isVirtualFileIdPageConfigValuesAll)(id)) {
|
|
55
|
-
const code = await (0, getVirtualFilePageConfigValuesAll_js_1.getVirtualFilePageConfigValuesAll)(id,
|
|
55
|
+
const code = await (0, getVirtualFilePageConfigValuesAll_js_1.getVirtualFilePageConfigValuesAll)(id, isDev, config);
|
|
56
56
|
return code;
|
|
57
57
|
}
|
|
58
58
|
if ((0, virtualFileImportUserCode_js_1.isVirtualFileIdImportUserCode)(id)) {
|
|
@@ -19,6 +19,7 @@ const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
|
19
19
|
const helpers_js_1 = require("../../../../../shared/page-configs/helpers.js");
|
|
20
20
|
const assertExports_js_1 = require("../../../../../shared/page-configs/assertExports.js");
|
|
21
21
|
const getVirtualFilePageConfigs_js_1 = require("./getVirtualFilePageConfigs.js");
|
|
22
|
+
const getConfigVike_js_1 = require("../../../../shared/getConfigVike.js");
|
|
22
23
|
(0, utils_js_1.assertIsNotProductionRuntime)();
|
|
23
24
|
let devServerIsCorrupt = false;
|
|
24
25
|
let wasConfigInvalid = null;
|
|
@@ -64,9 +65,11 @@ async function handleReloadSideEffects() {
|
|
|
64
65
|
}
|
|
65
66
|
}
|
|
66
67
|
}
|
|
67
|
-
async function getVikeConfig(
|
|
68
|
+
async function getVikeConfig(config, isDev, tolerateInvalidConfig = false, extensions) {
|
|
69
|
+
const { outDirRoot } = (0, utils_js_1.getOutDirs)(config);
|
|
70
|
+
const userRootDir = config.root;
|
|
68
71
|
if (!vikeConfigPromise) {
|
|
69
|
-
vikeConfigPromise = loadVikeConfig_withErrorHandling(userRootDir, outDirRoot, isDev, extensions, tolerateInvalidConfig);
|
|
72
|
+
vikeConfigPromise = loadVikeConfig_withErrorHandling(userRootDir, outDirRoot, isDev, extensions ?? (await (0, getConfigVike_js_1.getConfigVike)(config)).extensions, tolerateInvalidConfig);
|
|
70
73
|
}
|
|
71
74
|
return await vikeConfigPromise;
|
|
72
75
|
}
|
package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js
CHANGED
|
@@ -10,7 +10,8 @@ const helpers_js_1 = require("../../../../../shared/page-configs/helpers.js");
|
|
|
10
10
|
const getConfigValueSourcesRelevant_js_1 = require("../../../shared/getConfigValueSourcesRelevant.js");
|
|
11
11
|
const isRuntimeEnvMatch_js_1 = require("./isRuntimeEnvMatch.js");
|
|
12
12
|
const serializeConfigValue_js_1 = require("../../../../../shared/page-configs/serialize/serializeConfigValue.js");
|
|
13
|
-
|
|
13
|
+
const getConfigVike_js_1 = require("../../../../shared/getConfigVike.js");
|
|
14
|
+
async function getVirtualFilePageConfigValuesAll(id, isDev, config) {
|
|
14
15
|
const result = (0, virtualFilePageConfigValuesAll_js_1.isVirtualFileIdPageConfigValuesAll)(id);
|
|
15
16
|
(0, utils_js_1.assert)(result);
|
|
16
17
|
/* This assertion fails when using includeAssetsImportedByServer
|
|
@@ -20,9 +21,10 @@ async function getVirtualFilePageConfigValuesAll(id, userRootDir, outDirRoot, is
|
|
|
20
21
|
}
|
|
21
22
|
*/
|
|
22
23
|
const { pageId, isForClientSide } = result;
|
|
23
|
-
const { pageConfigs } = await (0, getVikeConfig_js_1.getVikeConfig)(
|
|
24
|
+
const { pageConfigs } = await (0, getVikeConfig_js_1.getVikeConfig)(config, isDev, true);
|
|
24
25
|
const pageConfig = pageConfigs.find((pageConfig) => pageConfig.pageId === pageId);
|
|
25
26
|
(0, utils_js_1.assert)(pageConfig);
|
|
27
|
+
const configVike = await (0, getConfigVike_js_1.getConfigVike)(config);
|
|
26
28
|
const code = getLoadConfigValuesAll(pageConfig, isForClientSide, pageId, configVike.includeAssetsImportedByServer, isDev);
|
|
27
29
|
(0, debug_js_1.debug)(id, isForClientSide ? 'CLIENT-SIDE' : 'SERVER-SIDE', code);
|
|
28
30
|
return code;
|
|
@@ -14,15 +14,23 @@ const getVikeConfig_js_1 = require("./getVikeConfig.js");
|
|
|
14
14
|
const isRuntimeEnvMatch_js_1 = require("./isRuntimeEnvMatch.js");
|
|
15
15
|
const helpers_js_2 = require("../../../../../shared/page-configs/helpers.js");
|
|
16
16
|
const serializeConfigValue_js_1 = require("../../../../../shared/page-configs/serialize/serializeConfigValue.js");
|
|
17
|
-
async function getVirtualFilePageConfigs(
|
|
18
|
-
const { pageConfigs, pageConfigGlobal } = await (0, getVikeConfig_js_1.getVikeConfig)(
|
|
19
|
-
return
|
|
17
|
+
async function getVirtualFilePageConfigs(isForClientSide, isDev, id, isClientRouting, config) {
|
|
18
|
+
const { pageConfigs, pageConfigGlobal } = await (0, getVikeConfig_js_1.getVikeConfig)(config, isDev, true);
|
|
19
|
+
return getCode(pageConfigs, pageConfigGlobal, isForClientSide, isDev, id, isClientRouting);
|
|
20
20
|
}
|
|
21
21
|
exports.getVirtualFilePageConfigs = getVirtualFilePageConfigs;
|
|
22
|
-
function
|
|
22
|
+
function getCode(pageConfigs, pageConfigGlobal, isForClientSide, isDev, id, isClientRouting) {
|
|
23
23
|
const lines = [];
|
|
24
24
|
const importStatements = [];
|
|
25
25
|
const varCounterContainer = { varCounter: 0 };
|
|
26
|
+
lines.push(getCodePageConfigsSerialized(pageConfigs, isForClientSide, isClientRouting, importStatements, varCounterContainer));
|
|
27
|
+
lines.push(getCodePageConfigGlobalSerialized(pageConfigGlobal, isForClientSide, isDev, importStatements, varCounterContainer));
|
|
28
|
+
const code = [...importStatements, ...lines].join('\n');
|
|
29
|
+
(0, debug_js_1.debug)(id, isForClientSide ? 'CLIENT-SIDE' : 'SERVER-SIDE', code);
|
|
30
|
+
return code;
|
|
31
|
+
}
|
|
32
|
+
function getCodePageConfigsSerialized(pageConfigs, isForClientSide, isClientRouting, importStatements, varCounterContainer) {
|
|
33
|
+
const lines = [];
|
|
26
34
|
lines.push('export const pageConfigsSerialized = [');
|
|
27
35
|
pageConfigs.forEach((pageConfig) => {
|
|
28
36
|
const { pageId, routeFilesystem, isErrorPage } = pageConfig;
|
|
@@ -76,6 +84,11 @@ function getContent(pageConfigs, pageConfigGlobal, isForClientSide, isDev, id, i
|
|
|
76
84
|
lines.push(` },`);
|
|
77
85
|
});
|
|
78
86
|
lines.push('];');
|
|
87
|
+
const code = lines.join('\n');
|
|
88
|
+
return code;
|
|
89
|
+
}
|
|
90
|
+
function getCodePageConfigGlobalSerialized(pageConfigGlobal, isForClientSide, isDev, importStatements, varCounterContainer) {
|
|
91
|
+
const lines = [];
|
|
79
92
|
lines.push('export const pageConfigGlobalSerialized = {');
|
|
80
93
|
/* Nothing (yet)
|
|
81
94
|
lines.push(` configValuesSerialized: {`)
|
|
@@ -102,8 +115,7 @@ function getContent(pageConfigs, pageConfigGlobal, isForClientSide, isDev, id, i
|
|
|
102
115
|
});
|
|
103
116
|
lines.push(` ],`);
|
|
104
117
|
lines.push('};');
|
|
105
|
-
const code =
|
|
106
|
-
(0, debug_js_1.debug)(id, isForClientSide ? 'CLIENT-SIDE' : 'SERVER-SIDE', code);
|
|
118
|
+
const code = lines.join('\n');
|
|
107
119
|
return code;
|
|
108
120
|
}
|
|
109
121
|
function getConfigValueSerialized(value, configName, definedAt) {
|
|
@@ -232,11 +232,11 @@ function assertImportsAreReExported(fileImports, fileExports, filePathToShowToUs
|
|
|
232
232
|
const importStatements = (0, utils_js_1.unique)(fileImportsUnused.map((fi) => fi.importStatementCode));
|
|
233
233
|
const importNamesUnused = fileImportsUnused.map((fi) => picocolors_1.default.cyan(fi.importLocalName)).join(', ');
|
|
234
234
|
const singular = fileImportsUnused.length === 1;
|
|
235
|
-
(0, utils_js_1.
|
|
235
|
+
(0, utils_js_1.assertWarning)(fileImportsUnused.length === 0, [
|
|
236
236
|
`${filePathToShowToUser} imports the following:`,
|
|
237
237
|
...importStatements.map((s) => picocolors_1.default.cyan(` ${s}`)),
|
|
238
238
|
`But the import${singular ? '' : 's'} ${importNamesUnused} ${singular ? "isn't" : "aren't"} re-exported at ${picocolors_1.default.cyan('export default { ... }')} and therefore ${singular ? 'has' : 'have'} no effect, see explanation at https://vike.dev/header-file`
|
|
239
|
-
].join('\n'));
|
|
239
|
+
].join('\n'), { onlyOnce: true });
|
|
240
240
|
}
|
|
241
241
|
function getExportedStrings(obj) {
|
|
242
242
|
const exportedStrings = [];
|
|
@@ -49,6 +49,8 @@ const assertPathIsFilesystemAbsolute_js_1 = require("../../utils/assertPathIsFil
|
|
|
49
49
|
const abort_js_1 = require("../../shared/route/abort.js");
|
|
50
50
|
const loadPageFilesServerSide_js_1 = require("../runtime/renderPage/loadPageFilesServerSide.js");
|
|
51
51
|
const getHook_js_1 = require("../../shared/hooks/getHook.js");
|
|
52
|
+
const noRouteMatch_js_1 = require("../../shared/route/noRouteMatch.js");
|
|
53
|
+
const getVikeConfig_js_1 = require("../plugin/plugins/importUserCode/v1-design/getVikeConfig.js");
|
|
52
54
|
async function prerenderFromAPI(options = {}) {
|
|
53
55
|
await runPrerender(options, 'prerender()');
|
|
54
56
|
}
|
|
@@ -95,7 +97,8 @@ async function runPrerender(options, manuallyTriggered) {
|
|
|
95
97
|
pageContextInit: options.pageContextInit ?? null
|
|
96
98
|
});
|
|
97
99
|
const doNotPrerenderList = [];
|
|
98
|
-
await
|
|
100
|
+
const vikeConfig = await (0, getVikeConfig_js_1.getVikeConfig)(viteConfig, false);
|
|
101
|
+
await collectDoNoPrerenderList(renderContext, vikeConfig.pageConfigs, doNotPrerenderList, concurrencyLimit);
|
|
99
102
|
await callOnBeforePrerenderStartHooks(prerenderContext, renderContext, concurrencyLimit);
|
|
100
103
|
await handlePagesWithStaticRoutes(prerenderContext, renderContext, doNotPrerenderList, concurrencyLimit);
|
|
101
104
|
await callOnPrerenderStartHook(prerenderContext, renderContext);
|
|
@@ -110,8 +113,9 @@ async function runPrerender(options, manuallyTriggered) {
|
|
|
110
113
|
await Promise.all(htmlFiles.map((htmlFile) => writeHtmlFile(htmlFile, root, outDirClient, concurrencyLimit, options.onPagePrerender, logLevel)));
|
|
111
114
|
warnMissingPages(prerenderPageIds, doNotPrerenderList, renderContext, partial);
|
|
112
115
|
}
|
|
113
|
-
async function collectDoNoPrerenderList(renderContext, doNotPrerenderList, concurrencyLimit) {
|
|
114
|
-
|
|
116
|
+
async function collectDoNoPrerenderList(renderContext, pageConfigs, doNotPrerenderList, concurrencyLimit) {
|
|
117
|
+
// V1 design
|
|
118
|
+
pageConfigs.forEach((pageConfig) => {
|
|
115
119
|
const configName = 'prerender';
|
|
116
120
|
const configValue = (0, helpers_js_1.getConfigValue)(pageConfig, configName, 'boolean');
|
|
117
121
|
if (configValue?.value === false) {
|
|
@@ -125,6 +129,8 @@ async function collectDoNoPrerenderList(renderContext, doNotPrerenderList, concu
|
|
|
125
129
|
});
|
|
126
130
|
}
|
|
127
131
|
});
|
|
132
|
+
// Old design
|
|
133
|
+
// TODO/v1-release: remove
|
|
128
134
|
await Promise.all(renderContext.pageFilesAll
|
|
129
135
|
.filter((p) => {
|
|
130
136
|
assertExportNames(p);
|
|
@@ -450,7 +456,7 @@ async function routeAndPrerender(prerenderContext, htmlFiles, prerenderPageIds,
|
|
|
450
456
|
}
|
|
451
457
|
if (hookName) {
|
|
452
458
|
(0, utils_js_1.assert)(hookFilePath);
|
|
453
|
-
(0, utils_js_1.assertUsage)(false, `The ${hookName}() hook defined by ${hookFilePath} returns a URL ${picocolors_1.default.cyan(urlOriginal)} that
|
|
459
|
+
(0, utils_js_1.assertUsage)(false, `The ${hookName}() hook defined by ${hookFilePath} returns a URL ${picocolors_1.default.cyan(urlOriginal)} that ${noRouteMatch_js_1.noRouteMatch}. Make sure that the URLs returned by ${hookName}() always match the route of a page.`);
|
|
454
460
|
}
|
|
455
461
|
else {
|
|
456
462
|
// `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.
|
|
@@ -514,15 +520,18 @@ function warnContradictoryNoPrerenderList(prerenderPageIds, doNotPrerenderList)
|
|
|
514
520
|
}
|
|
515
521
|
function warnMissingPages(prerenderPageIds, doNotPrerenderList, renderContext, partial) {
|
|
516
522
|
const isV1 = renderContext.pageConfigs.length > 0;
|
|
517
|
-
const hookName = isV1 ? '
|
|
518
|
-
|
|
523
|
+
const hookName = isV1 ? 'onBeforePrerenderStart' : 'prerender';
|
|
524
|
+
/* TODO/after-v1-design-release: document setting `prerender: false` as an alternative to using prerender.partial (both in the warnings and the docs)
|
|
525
|
+
const optOutName = isV1 ? 'prerender' : 'doNotPrerender'
|
|
526
|
+
const msgAddendum = `Explicitly opt-out by setting the config ${optOutName} to ${isV1 ? 'false' : 'true'} or use the option prerender.partial`
|
|
527
|
+
*/
|
|
519
528
|
renderContext.allPageIds
|
|
520
529
|
.filter((pageId) => !prerenderPageIds[pageId])
|
|
521
530
|
.filter((pageId) => !doNotPrerenderList.find((p) => p.pageId === pageId))
|
|
522
531
|
.filter((pageId) => !(0, error_page_js_1.isErrorPage)(pageId, renderContext.pageConfigs))
|
|
523
532
|
.forEach((pageId) => {
|
|
524
|
-
const pageAt =
|
|
525
|
-
(0, utils_js_1.assertWarning)(partial, `Cannot pre-render page ${pageAt} because it has a non-static route,
|
|
533
|
+
const pageAt = isV1 ? pageId : `\`${pageId}.page.*\``;
|
|
534
|
+
(0, utils_js_1.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 });
|
|
526
535
|
});
|
|
527
536
|
}
|
|
528
537
|
async function prerender404(htmlFiles, renderContext, prerenderContext) {
|
|
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.getRoutesInfo = exports.log404 = void 0;
|
|
7
|
+
const noRouteMatch_js_1 = require("../../../../shared/route/noRouteMatch.js");
|
|
7
8
|
const globalContext_js_1 = require("../../globalContext.js");
|
|
8
9
|
const utils_js_1 = require("../../utils.js");
|
|
9
10
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
@@ -18,7 +19,7 @@ async function log404(pageContext) {
|
|
|
18
19
|
const globalContext = (0, globalContext_js_1.getGlobalContext)();
|
|
19
20
|
if (!globalContext.isProduction && !isFileRequest(urlPathname) && !pageContext.isClientSideNavigation) {
|
|
20
21
|
const routesInfo = getRoutesInfo(pageRoutes);
|
|
21
|
-
let msg = `URL ${picocolors_1.default.cyan(urlPathname)}
|
|
22
|
+
let msg = `URL ${picocolors_1.default.cyan(urlPathname)} ${noRouteMatch_js_1.noRouteMatch}`;
|
|
22
23
|
const outro = 'See https://vike.dev/routing for more information about routing.';
|
|
23
24
|
if (!routesInfo) {
|
|
24
25
|
msg = `${msg}. ${picocolors_1.default.dim(outro)}`;
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getConfigVike = void 0;
|
|
4
|
+
const utils_js_1 = require("./utils.js");
|
|
4
5
|
async function getConfigVike(config) {
|
|
5
|
-
const
|
|
6
|
+
const { configVikePromise } = config;
|
|
7
|
+
(0, utils_js_1.assert)(configVikePromise);
|
|
8
|
+
const configVike = await configVikePromise;
|
|
6
9
|
return configVike;
|
|
7
10
|
}
|
|
8
11
|
exports.getConfigVike = getConfigVike;
|
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.parseConfigValuesImported = void 0;
|
|
7
4
|
const utils_js_1 = require("../../utils.js");
|
|
8
5
|
const assertExports_js_1 = require("../assertExports.js");
|
|
9
|
-
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
10
6
|
function parseConfigValuesImported(configValuesImported) {
|
|
11
7
|
const configValues = {};
|
|
12
8
|
const addConfigValue = (configName, value, importPath, exportName) => {
|
|
@@ -50,5 +46,12 @@ function parseConfigValuesImported(configValuesImported) {
|
|
|
50
46
|
exports.parseConfigValuesImported = parseConfigValuesImported;
|
|
51
47
|
function assertIsNotNull(configValue, configName, importPath) {
|
|
52
48
|
(0, utils_js_1.assert)(!importPath.includes('+config.'));
|
|
53
|
-
|
|
49
|
+
/* Re-use this for:
|
|
50
|
+
* - upcoming config.requestPageContextOnNavigation
|
|
51
|
+
* - for cumulative values in the future: we don't need this for now because, currently, cumulative values are never imported.
|
|
52
|
+
assertUsage(
|
|
53
|
+
configValue !== null,
|
|
54
|
+
`Set ${pc.cyan(configName)} to ${pc.cyan('null')} in a +config.h.js file instead of ${importPath}`
|
|
55
|
+
)
|
|
56
|
+
*/
|
|
54
57
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isExternalLink = void 0;
|
|
4
|
+
function isExternalLink(url) {
|
|
5
|
+
return !url.startsWith('/') && !url.startsWith('.') && !url.startsWith('?') && url !== '';
|
|
6
|
+
}
|
|
7
|
+
exports.isExternalLink = isExternalLink;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.onPageShow = exports.onPageHide = void 0;
|
|
4
|
+
function onPageHide(listener) {
|
|
5
|
+
window.addEventListener('visibilitychange', () => {
|
|
6
|
+
if (document.visibilityState === 'hidden') {
|
|
7
|
+
listener();
|
|
8
|
+
}
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
exports.onPageHide = onPageHide;
|
|
12
|
+
function onPageShow(listener) {
|
|
13
|
+
window.addEventListener('visibilitychange', () => {
|
|
14
|
+
if (document.visibilityState === 'visible') {
|
|
15
|
+
listener();
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
exports.onPageShow = onPageShow;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.projectInfo = void 0;
|
|
4
4
|
const assertSingleInstance_js_1 = require("./assertSingleInstance.js");
|
|
5
|
-
const PROJECT_VERSION = '0.4.
|
|
5
|
+
const PROJECT_VERSION = '0.4.145-commit-2520555';
|
|
6
6
|
const projectInfo = {
|
|
7
7
|
projectName: 'Vike',
|
|
8
8
|
projectVersion: PROJECT_VERSION,
|
|
@@ -22,7 +22,6 @@ async function createPageContext(urlOriginal) {
|
|
|
22
22
|
_urlRewrite: null,
|
|
23
23
|
_baseServer: baseServer,
|
|
24
24
|
_isProduction: isProd,
|
|
25
|
-
// TODO: use GlobalContext instead
|
|
26
25
|
_pageFilesAll: pageFilesAll,
|
|
27
26
|
_pageConfigs: pageConfigs,
|
|
28
27
|
_pageConfigGlobal: pageConfigGlobal,
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export { getBaseServer };
|
|
2
|
+
declare function getBaseServer(): string;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
export { getBaseServer };
|
|
1
2
|
import { assert } from '../server-routing-runtime/utils.js';
|
|
2
|
-
|
|
3
|
+
function getBaseServer() {
|
|
3
4
|
// @ts-ignore Since dist/cjs/client/ is never used, we can ignore this error.
|
|
4
5
|
const baseServer = import.meta.env.BASE_SERVER;
|
|
5
6
|
assert(isBaseServer(baseServer));
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export { getPageContextFromHooks_firstRender };
|
|
2
|
+
export { getPageContextFromHooks_uponNavigation };
|
|
3
|
+
export { getPageContextFromHooks_errorPage };
|
|
4
|
+
export { isAlreadyServerSideRouted };
|
|
5
|
+
export type { PageContextFromHooks };
|
|
6
|
+
import type { PageContextExports, PageFile } from '../../shared/getPageFiles.js';
|
|
7
|
+
import type { PageContextUrlComputedPropsInternal } from '../../shared/addUrlComputedProps.js';
|
|
8
|
+
import type { PageContextForRoute } from '../../shared/route/index.js';
|
|
9
|
+
import type { PageConfigRuntime } from '../../shared/page-configs/PageConfig.js';
|
|
10
|
+
import type { PageContextForPassToClientWarning } from '../shared/getPageContextProxyForUser.js';
|
|
11
|
+
/** - pageContext set by user hooks
|
|
12
|
+
* - pageContext set by loadPageFilesClientSide()
|
|
13
|
+
* - misc:
|
|
14
|
+
* - pageContext.isHydration
|
|
15
|
+
* - pageContext._pageId
|
|
16
|
+
* - pageContext._hasPageContextFromClient
|
|
17
|
+
* - pageContext._hasPageContextFromServer
|
|
18
|
+
*/
|
|
19
|
+
type PageContextFromHooks = {
|
|
20
|
+
_pageId: string;
|
|
21
|
+
isHydration: boolean;
|
|
22
|
+
_pageFilesLoaded: PageFile[];
|
|
23
|
+
} & PageContextExports & PageContextForPassToClientWarning;
|
|
24
|
+
type PageContext = PageContextUrlComputedPropsInternal & PageContextForRoute & {
|
|
25
|
+
_allPageIds: string[];
|
|
26
|
+
_pageFilesAll: PageFile[];
|
|
27
|
+
_pageConfigs: PageConfigRuntime[];
|
|
28
|
+
isBackwardNavigation: boolean | null;
|
|
29
|
+
};
|
|
30
|
+
declare function getPageContextFromHooks_firstRender(pageContext: {
|
|
31
|
+
urlOriginal: string;
|
|
32
|
+
} & PageContext): Promise<PageContextFromHooks>;
|
|
33
|
+
declare function getPageContextFromHooks_errorPage(pageContext: {
|
|
34
|
+
urlOriginal: string;
|
|
35
|
+
} & PageContext): Promise<PageContextFromHooks>;
|
|
36
|
+
declare function getPageContextFromHooks_uponNavigation(pageContext: {
|
|
37
|
+
_pageId: string;
|
|
38
|
+
} & PageContext): Promise<PageContextFromHooks>;
|
|
39
|
+
declare function isAlreadyServerSideRouted(err: unknown): boolean;
|