vike 0.4.143 → 0.4.144-commit-e40e9b1
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/index.js +2 -2
- package/dist/cjs/node/plugin/plugins/buildConfig.js +1 -1
- package/dist/cjs/node/plugin/plugins/config/index.js +1 -1
- package/dist/cjs/node/plugin/plugins/devConfig/determineOptimizeDeps.js +31 -30
- package/dist/cjs/node/plugin/plugins/importUserCode/generateEagerImport.js +19 -8
- package/dist/cjs/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.js +19 -10
- package/dist/cjs/node/plugin/plugins/importUserCode/index.js +2 -2
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getFilePathToShowToUser.js +6 -0
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +4 -4
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +228 -186
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js +11 -35
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigs.js +60 -95
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/helpers.js +12 -5
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/isRuntimeEnvMatch.js +18 -0
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/replaceImportStatements.js +25 -25
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/transpileAndExecuteFile.js +14 -13
- package/dist/cjs/node/plugin/shared/findPageFiles.js +2 -1
- package/dist/cjs/node/plugin/shared/{getConfigValueSource.js → getConfigValueSourcesRelevant.js} +1 -12
- package/dist/cjs/node/plugin/shared/loggerNotProd.js +1 -1
- package/dist/cjs/node/plugin/utils.js +2 -3
- package/dist/cjs/node/prerender/runPrerender.js +18 -20
- package/dist/cjs/node/runtime/html/injectAssets/getHtmlTags.js +1 -1
- package/dist/cjs/node/runtime/renderPage/analyzePage.js +2 -2
- package/dist/cjs/node/runtime/renderPage/loadPageFilesServerSide.js +2 -2
- package/dist/cjs/node/runtime/renderPage/log404/index.js +10 -5
- package/dist/cjs/node/runtime/renderPage/renderPageAlreadyRouted.js +3 -2
- package/dist/cjs/node/runtime/renderPage.js +1 -1
- package/dist/cjs/node/shared/getClientEntryFilePath.js +1 -7
- package/dist/cjs/shared/assertPageContextProvidedByUser.js +1 -1
- package/dist/cjs/shared/error-page.js +1 -1
- package/dist/cjs/shared/getPageFiles/getExports.js +8 -11
- package/dist/cjs/shared/getPageFiles/parseGlobResults.js +10 -44
- package/dist/cjs/shared/hooks/getHook.js +3 -1
- package/dist/cjs/shared/page-configs/assertExports.js +60 -0
- package/dist/cjs/shared/page-configs/getExportPath.js +9 -10
- package/dist/cjs/shared/page-configs/loadConfigValues.js +18 -0
- package/dist/cjs/shared/page-configs/serialize/PageConfigSerialized.js +2 -0
- package/dist/cjs/shared/page-configs/serialize/assertPageConfigs.js +19 -0
- package/dist/cjs/shared/page-configs/serialize/parseConfigValuesImported.js +56 -0
- package/dist/cjs/shared/page-configs/serialize/parsePageConfigs.js +65 -0
- package/dist/cjs/shared/page-configs/serialize/serializeConfigValue.js +58 -0
- package/dist/cjs/shared/page-configs/utils.js +65 -42
- package/dist/cjs/shared/route/loadPageRoutes.js +12 -15
- package/dist/cjs/shared/route/resolveRedirects.js +1 -1
- package/dist/cjs/shared/route/resolveRouteFunction.js +1 -0
- package/dist/cjs/shared/utils.js +0 -1
- package/dist/cjs/utils/getOutDirs.js +25 -18
- package/dist/cjs/utils/getValuePrintable.js +1 -1
- package/dist/cjs/utils/objectAssign.js +3 -1
- package/dist/cjs/utils/projectInfo.js +1 -1
- package/dist/cjs/utils/{resolve.js → requireResolve.js} +3 -3
- package/dist/cjs/utils/warnIfErrorIsNotObject.js +1 -1
- package/dist/esm/__internal/index.d.ts +3 -3
- package/dist/esm/client/client-routing-runtime/createPageContext.d.ts +2 -2
- package/dist/esm/client/client-routing-runtime/getPageContext.d.ts +2 -2
- package/dist/esm/client/client-routing-runtime/getPageId.d.ts +2 -2
- package/dist/esm/client/client-routing-runtime/useClientRouter.js +3 -3
- package/dist/esm/client/server-routing-runtime/getPageContext.d.ts +1 -1
- package/dist/esm/client/shared/executeOnRenderClientHook.d.ts +2 -2
- package/dist/esm/client/shared/loadPageFilesClientSide.d.ts +2 -2
- package/dist/esm/client/shared/loadPageFilesClientSide.js +2 -2
- package/dist/esm/client/shared/preparePageContextForUserConsumptionClientSide.d.ts +2 -2
- package/dist/esm/node/plugin/index.js +3 -2
- package/dist/esm/node/plugin/plugins/buildConfig.js +2 -2
- package/dist/esm/node/plugin/plugins/config/index.js +2 -2
- package/dist/esm/node/plugin/plugins/devConfig/determineOptimizeDeps.js +31 -30
- package/dist/esm/node/plugin/plugins/importUserCode/generateEagerImport.d.ts +13 -2
- package/dist/esm/node/plugin/plugins/importUserCode/generateEagerImport.js +19 -8
- package/dist/esm/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.js +20 -11
- package/dist/esm/node/plugin/plugins/importUserCode/index.js +3 -3
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getFilePathToShowToUser.d.ts +19 -2
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getFilePathToShowToUser.js +6 -0
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.d.ts +5 -4
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +4 -4
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.d.ts +4 -4
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +229 -187
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.d.ts +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js +11 -32
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigs.d.ts +3 -3
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigs.js +60 -95
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/helpers.d.ts +3 -3
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/helpers.js +12 -5
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/isRuntimeEnvMatch.d.ts +7 -0
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/isRuntimeEnvMatch.js +15 -0
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/replaceImportStatements.d.ts +18 -6
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/replaceImportStatements.js +25 -25
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/transpileAndExecuteFile.d.ts +2 -2
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/transpileAndExecuteFile.js +14 -13
- package/dist/esm/node/plugin/shared/findPageFiles.js +3 -2
- package/dist/esm/node/plugin/shared/{getConfigValueSource.d.ts → getConfigValueSourcesRelevant.d.ts} +0 -2
- package/dist/esm/node/plugin/shared/{getConfigValueSource.js → getConfigValueSourcesRelevant.js} +0 -11
- package/dist/esm/node/plugin/shared/loggerNotProd.js +2 -2
- package/dist/esm/node/plugin/utils.d.ts +1 -2
- package/dist/esm/node/plugin/utils.js +2 -3
- package/dist/esm/node/prerender/runPrerender.js +20 -22
- package/dist/esm/node/runtime/html/injectAssets/getHtmlTags.js +1 -1
- package/dist/esm/node/runtime/html/injectAssets.d.ts +2 -2
- package/dist/esm/node/runtime/html/serializePageContextClientSide.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/analyzePage.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/analyzePage.js +2 -2
- package/dist/esm/node/runtime/renderPage/createHttpResponseObject.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/debugPageFiles.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/executeOnRenderHtmlHook.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/handleErrorWithoutErrorPage.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/loadPageFilesServerSide.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/loadPageFilesServerSide.js +2 -2
- package/dist/esm/node/runtime/renderPage/log404/index.js +10 -5
- package/dist/esm/node/runtime/renderPage/preparePageContextForUserConsumptionServerSide.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.d.ts +13 -13
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.js +3 -2
- package/dist/esm/node/runtime/renderPage.js +1 -1
- package/dist/esm/node/shared/getClientEntryFilePath.d.ts +2 -2
- package/dist/esm/node/shared/getClientEntryFilePath.js +2 -8
- package/dist/esm/shared/addIs404ToPageProps.d.ts +2 -2
- package/dist/esm/shared/addUrlComputedProps.d.ts +4 -2
- package/dist/esm/shared/assertPageContextProvidedByUser.js +1 -1
- package/dist/esm/shared/error-page.d.ts +3 -3
- package/dist/esm/shared/error-page.js +1 -1
- package/dist/esm/shared/getPageFiles/analyzeClientSide.d.ts +2 -2
- package/dist/esm/shared/getPageFiles/getExports.d.ts +3 -4
- package/dist/esm/shared/getPageFiles/getExports.js +7 -10
- package/dist/esm/shared/getPageFiles/parseGlobResults.d.ts +3 -3
- package/dist/esm/shared/getPageFiles/parseGlobResults.js +9 -43
- package/dist/esm/shared/getPageFiles/setPageFiles.d.ts +3 -3
- package/dist/esm/shared/hooks/getHook.js +3 -1
- package/dist/esm/shared/page-configs/Config.d.ts +201 -14
- package/dist/esm/shared/page-configs/PageConfig.d.ts +80 -73
- package/dist/esm/shared/page-configs/assertExports.d.ts +6 -0
- package/dist/esm/shared/page-configs/assertExports.js +54 -0
- package/dist/esm/shared/page-configs/findPageConfig.d.ts +2 -2
- package/dist/esm/shared/page-configs/getExportPath.d.ts +1 -1
- package/dist/esm/shared/page-configs/getExportPath.js +9 -10
- package/dist/esm/shared/page-configs/loadConfigValues.d.ts +3 -0
- package/dist/esm/shared/page-configs/loadConfigValues.js +15 -0
- package/dist/esm/shared/page-configs/serialize/PageConfigSerialized.d.ts +32 -0
- package/dist/esm/shared/page-configs/serialize/PageConfigSerialized.js +1 -0
- package/dist/esm/shared/page-configs/serialize/assertPageConfigs.d.ts +5 -0
- package/dist/esm/shared/page-configs/serialize/assertPageConfigs.js +16 -0
- package/dist/esm/shared/page-configs/serialize/parseConfigValuesImported.d.ts +4 -0
- package/dist/esm/shared/page-configs/serialize/parseConfigValuesImported.js +50 -0
- package/dist/esm/shared/page-configs/serialize/parsePageConfigs.d.ts +7 -0
- package/dist/esm/shared/page-configs/serialize/parsePageConfigs.js +62 -0
- package/dist/esm/shared/page-configs/serialize/serializeConfigValue.d.ts +8 -0
- package/dist/esm/shared/page-configs/serialize/serializeConfigValue.js +52 -0
- package/dist/esm/shared/page-configs/utils.d.ts +21 -14
- package/dist/esm/shared/page-configs/utils.js +64 -41
- package/dist/esm/shared/route/executeGuardHook.d.ts +2 -2
- package/dist/esm/shared/route/index.d.ts +3 -3
- package/dist/esm/shared/route/loadPageRoutes.d.ts +2 -2
- package/dist/esm/shared/route/loadPageRoutes.js +13 -16
- package/dist/esm/shared/route/resolveRedirects.js +1 -1
- package/dist/esm/shared/route/resolveRouteFunction.js +1 -0
- package/dist/esm/shared/types.d.ts +8 -6
- package/dist/esm/shared/utils.d.ts +0 -1
- package/dist/esm/shared/utils.js +0 -1
- package/dist/esm/types/index.d.ts +2 -1
- package/dist/esm/utils/getOutDirs.d.ts +0 -2
- package/dist/esm/utils/getOutDirs.js +24 -17
- package/dist/esm/utils/getValuePrintable.js +1 -1
- package/dist/esm/utils/objectAssign.js +3 -1
- package/dist/esm/utils/projectInfo.d.ts +1 -1
- package/dist/esm/utils/projectInfo.js +1 -1
- package/dist/esm/utils/requireResolve.d.ts +2 -0
- package/dist/esm/utils/{resolve.js → requireResolve.js} +2 -2
- package/dist/esm/utils/warnIfErrorIsNotObject.js +1 -1
- package/package.json +2 -2
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/isConfigEnvMatch.js +0 -13
- package/dist/cjs/shared/getPageFiles/assertPageConfigs.js +0 -19
- package/dist/cjs/shared/page-configs/loadPageCode.js +0 -63
- package/dist/cjs/utils/assertDefaultExport.js +0 -53
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/isConfigEnvMatch.d.ts +0 -3
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/isConfigEnvMatch.js +0 -10
- package/dist/esm/shared/getPageFiles/assertPageConfigs.d.ts +0 -5
- package/dist/esm/shared/getPageFiles/assertPageConfigs.js +0 -16
- package/dist/esm/shared/page-configs/loadPageCode.d.ts +0 -3
- package/dist/esm/shared/page-configs/loadPageCode.js +0 -57
- package/dist/esm/utils/assertDefaultExport.d.ts +0 -8
- package/dist/esm/utils/assertDefaultExport.js +0 -47
- package/dist/esm/utils/resolve.d.ts +0 -2
- /package/dist/cjs/shared/getPageFiles/{assertExports.js → assert_exports_old_design.js} +0 -0
- /package/dist/esm/shared/getPageFiles/{assertExports.d.ts → assert_exports_old_design.d.ts} +0 -0
- /package/dist/esm/shared/getPageFiles/{assertExports.js → assert_exports_old_design.js} +0 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parsePageConfigs = void 0;
|
|
4
|
+
const parse_1 = require("@brillout/json-serializer/parse");
|
|
5
|
+
const parseConfigValuesImported_js_1 = require("./parseConfigValuesImported.js");
|
|
6
|
+
const utils_js_1 = require("../../utils.js");
|
|
7
|
+
const utils_js_2 = require("../utils.js");
|
|
8
|
+
function parsePageConfigs(pageConfigsSerialized, pageConfigGlobalSerialized) {
|
|
9
|
+
const pageConfigs = pageConfigsSerialized.map((pageConfigSerialized) => {
|
|
10
|
+
const configValues = {};
|
|
11
|
+
{
|
|
12
|
+
const { configValuesSerialized } = pageConfigSerialized;
|
|
13
|
+
Object.entries(configValuesSerialized).forEach(([configName, configValueSeriliazed]) => {
|
|
14
|
+
{
|
|
15
|
+
const { valueSerialized, definedAt } = configValueSeriliazed;
|
|
16
|
+
(0, utils_js_1.assert)(valueSerialized);
|
|
17
|
+
(0, utils_js_1.assert)(!configValues[configName]);
|
|
18
|
+
configValues[configName] = {
|
|
19
|
+
value: (0, parse_1.parse)(valueSerialized),
|
|
20
|
+
definedAt
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
{
|
|
26
|
+
const { configValuesImported } = pageConfigSerialized;
|
|
27
|
+
const configValuesAddendum = (0, parseConfigValuesImported_js_1.parseConfigValuesImported)(configValuesImported);
|
|
28
|
+
Object.assign(configValues, configValuesAddendum);
|
|
29
|
+
}
|
|
30
|
+
const { pageId, isErrorPage, routeFilesystem, loadConfigValuesAll } = pageConfigSerialized;
|
|
31
|
+
assertRouteConfigValue(configValues);
|
|
32
|
+
return {
|
|
33
|
+
pageId,
|
|
34
|
+
isErrorPage,
|
|
35
|
+
routeFilesystem,
|
|
36
|
+
configValues,
|
|
37
|
+
loadConfigValuesAll
|
|
38
|
+
};
|
|
39
|
+
});
|
|
40
|
+
const pageConfigGlobal = { configValues: {} };
|
|
41
|
+
{
|
|
42
|
+
const configValuesAddendum = (0, parseConfigValuesImported_js_1.parseConfigValuesImported)(pageConfigGlobalSerialized.configValuesImported);
|
|
43
|
+
Object.assign(pageConfigGlobal.configValues, configValuesAddendum);
|
|
44
|
+
}
|
|
45
|
+
return { pageConfigs, pageConfigGlobal };
|
|
46
|
+
}
|
|
47
|
+
exports.parsePageConfigs = parsePageConfigs;
|
|
48
|
+
function assertRouteConfigValue(configValues) {
|
|
49
|
+
const configName = 'route';
|
|
50
|
+
const configValue = configValues[configName];
|
|
51
|
+
if (!configValue)
|
|
52
|
+
return;
|
|
53
|
+
const { value } = configValue;
|
|
54
|
+
const configValueType = typeof value;
|
|
55
|
+
const configDefinedAt = (0, utils_js_2.getConfigDefinedAtString)(configName, configValue, true);
|
|
56
|
+
(0, utils_js_1.assertUsage)(configValueType === 'string' || (0, utils_js_1.isCallable)(value), `${configDefinedAt} has an invalid type '${configValueType}': it should be a string or a function instead, see https://vike.dev/route`);
|
|
57
|
+
/* We don't use assertRouteString() in order to avoid unnecessarily bloating the client-side bundle when using Server Routing:
|
|
58
|
+
* - When using Server Routing, this file is loaded => loading assertRouteString() would bloat the client bundle.
|
|
59
|
+
* - assertRouteString() is already called on the server-side
|
|
60
|
+
* - When using Server Routing, client-side validation is superfluous as Route Strings only need to be validated on the server-side
|
|
61
|
+
if (typeof configValue === 'string') {
|
|
62
|
+
assertRouteString(configValue, `${configElement.configDefinedAt} defines an`)
|
|
63
|
+
}
|
|
64
|
+
*/
|
|
65
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.serializeConfigValueImported = exports.serializeConfigValue = void 0;
|
|
7
|
+
// This file is never loaded on the client-side but we save it under the vike/shared/ directory in order to collocate it with:
|
|
8
|
+
// - vike/shared/page-configs/serialize/parsePageConfigs.ts
|
|
9
|
+
// - vike/shared/page-configs/serialize/parseConfigValuesImported.ts
|
|
10
|
+
// Both parsePageConfigs() parseConfigValuesImported() and are loaded on the client-side and server-side
|
|
11
|
+
const assertIsNotProductionRuntime_js_1 = require("../../../utils/assertIsNotProductionRuntime.js");
|
|
12
|
+
(0, assertIsNotProductionRuntime_js_1.assertIsNotProductionRuntime)();
|
|
13
|
+
const path_1 = __importDefault(require("path"));
|
|
14
|
+
const utils_js_1 = require("../../utils.js");
|
|
15
|
+
const generateEagerImport_js_1 = require("../../../node/plugin/plugins/importUserCode/generateEagerImport.js");
|
|
16
|
+
function serializeConfigValue(lines, configName, configValueSerialized) {
|
|
17
|
+
let whitespace = ' ';
|
|
18
|
+
lines.push(`${whitespace}['${configName}']: {`);
|
|
19
|
+
whitespace += ' ';
|
|
20
|
+
Object.entries(configValueSerialized).forEach(([key, val]) => {
|
|
21
|
+
const valSerialized = key === 'definedAt' ? JSON.stringify(val) : val;
|
|
22
|
+
lines.push(`${whitespace} ${key}: ${valSerialized},`);
|
|
23
|
+
});
|
|
24
|
+
whitespace = whitespace.slice(2);
|
|
25
|
+
lines.push(`${whitespace}},`);
|
|
26
|
+
}
|
|
27
|
+
exports.serializeConfigValue = serializeConfigValue;
|
|
28
|
+
function serializeConfigValueImported(configValueSource, configName, whitespace, varCounterContainer, importStatements) {
|
|
29
|
+
(0, utils_js_1.assert)(!configValueSource.valueIsFilePath);
|
|
30
|
+
(0, utils_js_1.assert)(whitespace.replaceAll(' ', '').length === 0);
|
|
31
|
+
const { valueIsImportedAtRuntime, definedAtInfo } = configValueSource;
|
|
32
|
+
(0, utils_js_1.assert)(valueIsImportedAtRuntime);
|
|
33
|
+
const { filePathRelativeToUserRootDir, importPathAbsolute, exportName } = definedAtInfo;
|
|
34
|
+
const importPath = filePathRelativeToUserRootDir ?? importPathAbsolute;
|
|
35
|
+
(0, utils_js_1.assertPosixPath)(importPath);
|
|
36
|
+
const fileName = path_1.default.posix.basename(importPath);
|
|
37
|
+
const isValueFile = fileName.startsWith('+');
|
|
38
|
+
if (isValueFile)
|
|
39
|
+
(0, utils_js_1.assert)(exportName === undefined);
|
|
40
|
+
const { importName, importStatement } = (0, generateEagerImport_js_1.generateEagerImport)(importPath, varCounterContainer.varCounter++, exportName);
|
|
41
|
+
importStatements.push(importStatement);
|
|
42
|
+
const lines = [];
|
|
43
|
+
lines.push(` {`);
|
|
44
|
+
lines.push(` configName: '${configName}',`);
|
|
45
|
+
lines.push(` importPath: '${importPath}',`);
|
|
46
|
+
lines.push(` isValueFile: ${JSON.stringify(isValueFile)},`);
|
|
47
|
+
if (isValueFile) {
|
|
48
|
+
lines.push(` exportValues: ${importName},`);
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
lines.push(` exportValue: ${importName},`);
|
|
52
|
+
(0, utils_js_1.assert)(exportName);
|
|
53
|
+
lines.push(` exportName: ${JSON.stringify(exportName)},`);
|
|
54
|
+
}
|
|
55
|
+
lines.push(` },`);
|
|
56
|
+
return lines;
|
|
57
|
+
}
|
|
58
|
+
exports.serializeConfigValueImported = serializeConfigValueImported;
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.getHookFilePathToShowToUser = exports.getConfigValueFilePathToShowToUser = exports.getDefinedAtString = exports.getConfigDefinedAtString = exports.getPageConfig = exports.getConfigValue = void 0;
|
|
7
7
|
const utils_js_1 = require("../utils.js");
|
|
8
8
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
9
9
|
const getExportPath_js_1 = require("./getExportPath.js");
|
|
@@ -12,33 +12,30 @@ function getConfigValue(pageConfig, configName, type) {
|
|
|
12
12
|
const configValue = getConfigValueEntry(pageConfig, configName);
|
|
13
13
|
if (configValue === null)
|
|
14
14
|
return null;
|
|
15
|
-
const { value,
|
|
15
|
+
const { value, definedAt } = configValue;
|
|
16
16
|
if (type)
|
|
17
|
-
assertConfigValueType(value, type, configName,
|
|
18
|
-
return
|
|
17
|
+
assertConfigValueType(value, type, configName, definedAt);
|
|
18
|
+
return configValue;
|
|
19
19
|
}
|
|
20
20
|
exports.getConfigValue = getConfigValue;
|
|
21
|
-
function
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
(0, utils_js_1.
|
|
30
|
-
return definedAtInfo;
|
|
21
|
+
function assertConfigValueType(value, type, configName, definedAt) {
|
|
22
|
+
(0, utils_js_1.assert)(value !== null);
|
|
23
|
+
const typeActual = typeof value;
|
|
24
|
+
if (typeActual === type)
|
|
25
|
+
return;
|
|
26
|
+
const valuePrintable = (0, utils_js_1.getValuePrintable)(value);
|
|
27
|
+
const problem = valuePrintable !== null ? `value ${picocolors_1.default.cyan(valuePrintable)}` : `type ${picocolors_1.default.cyan(typeActual)}`;
|
|
28
|
+
const configDefinedAt = getConfigDefinedAtString(configName, { definedAt }, true);
|
|
29
|
+
(0, utils_js_1.assertUsage)(false, `${configDefinedAt} has an invalid ${problem}: it should be a ${picocolors_1.default.cyan(type)} instead`);
|
|
31
30
|
}
|
|
32
|
-
exports.getConfigDefinedAtInfo = getConfigDefinedAtInfo;
|
|
33
31
|
function getConfigValueEntry(pageConfig, configName) {
|
|
34
32
|
const configValue = pageConfig.configValues[configName];
|
|
35
33
|
if (!configValue)
|
|
36
34
|
return null;
|
|
37
|
-
const { value, definedAtInfo } = configValue;
|
|
38
35
|
// Enable users to suppress global config values by setting the local config value to null
|
|
39
|
-
if (value === null)
|
|
36
|
+
if (configValue.value === null)
|
|
40
37
|
return null;
|
|
41
|
-
return
|
|
38
|
+
return configValue;
|
|
42
39
|
}
|
|
43
40
|
function getPageConfig(pageId, pageConfigs) {
|
|
44
41
|
const pageConfig = pageConfigs.find((p) => p.pageId === pageId);
|
|
@@ -47,34 +44,60 @@ function getPageConfig(pageId, pageConfigs) {
|
|
|
47
44
|
return pageConfig;
|
|
48
45
|
}
|
|
49
46
|
exports.getPageConfig = getPageConfig;
|
|
50
|
-
function
|
|
51
|
-
|
|
52
|
-
const typeActual = typeof value;
|
|
53
|
-
if (typeActual === type)
|
|
54
|
-
return;
|
|
55
|
-
const valuePrintable = (0, utils_js_1.getValuePrintable)(value);
|
|
56
|
-
const problem = valuePrintable !== null ? `value ${picocolors_1.default.cyan(valuePrintable)}` : `type ${picocolors_1.default.cyan(typeActual)}`;
|
|
57
|
-
const configDefinedAt = getConfigDefinedAtString(configName, { definedAtInfo }, true);
|
|
58
|
-
(0, utils_js_1.assertUsage)(false, `${configDefinedAt} has an invalid ${problem}: it should be a ${picocolors_1.default.cyan(type)} instead`);
|
|
59
|
-
}
|
|
60
|
-
function getConfigDefinedAtString(configName, { definedAtInfo }, sentenceBegin, append) {
|
|
61
|
-
let configDefinedAt = `${sentenceBegin ? `Config` : `config`} ${picocolors_1.default.cyan(configName)}`;
|
|
62
|
-
if (definedAtInfo !== null) {
|
|
63
|
-
configDefinedAt = `${configDefinedAt} defined at ${getDefinedAtString(definedAtInfo, append)}`;
|
|
64
|
-
}
|
|
47
|
+
function getConfigDefinedAtString(configName, { definedAt }, sentenceBegin) {
|
|
48
|
+
const configDefinedAt = `${sentenceBegin ? `Config` : `config`} ${picocolors_1.default.cyan(configName)} defined ${getSourceString(definedAt, configName)}`;
|
|
65
49
|
return configDefinedAt;
|
|
66
50
|
}
|
|
67
51
|
exports.getConfigDefinedAtString = getConfigDefinedAtString;
|
|
68
|
-
function
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
const exportPath = (0, getExportPath_js_1.getExportPath)(fileExportPath);
|
|
72
|
-
if (exportPath) {
|
|
73
|
-
definedAt = `${definedAt} > ${picocolors_1.default.cyan(exportPath)}`;
|
|
52
|
+
function getSourceString(definedAt, configName) {
|
|
53
|
+
if (definedAt.isComputed) {
|
|
54
|
+
return 'internally';
|
|
74
55
|
}
|
|
75
|
-
|
|
76
|
-
|
|
56
|
+
let files;
|
|
57
|
+
if (definedAt.isCumulative) {
|
|
58
|
+
files = definedAt.files;
|
|
77
59
|
}
|
|
78
|
-
|
|
60
|
+
else {
|
|
61
|
+
files = [definedAt.file];
|
|
62
|
+
}
|
|
63
|
+
(0, utils_js_1.assert)(files.length >= 1);
|
|
64
|
+
const sourceString = files
|
|
65
|
+
.map((source) => {
|
|
66
|
+
const { filePathToShowToUser, fileExportPath } = source;
|
|
67
|
+
let s = filePathToShowToUser;
|
|
68
|
+
const exportPath = (0, getExportPath_js_1.getExportPath)(fileExportPath, configName);
|
|
69
|
+
if (exportPath) {
|
|
70
|
+
s = `${s} > ${picocolors_1.default.cyan(exportPath)}`;
|
|
71
|
+
}
|
|
72
|
+
if (definedAt.isEffect) {
|
|
73
|
+
s = `${s} > (${picocolors_1.default.blue('effect')})`;
|
|
74
|
+
}
|
|
75
|
+
return s;
|
|
76
|
+
})
|
|
77
|
+
.join(' / ');
|
|
78
|
+
return `at ${sourceString}`;
|
|
79
|
+
}
|
|
80
|
+
function getDefinedAtString(configValue, configName) {
|
|
81
|
+
let sourceString = getSourceString(configValue.definedAt, configName);
|
|
82
|
+
if (sourceString.startsWith('at '))
|
|
83
|
+
sourceString = sourceString.slice('at '.length);
|
|
84
|
+
return sourceString;
|
|
79
85
|
}
|
|
80
86
|
exports.getDefinedAtString = getDefinedAtString;
|
|
87
|
+
function getConfigValueFilePathToShowToUser({ definedAt }) {
|
|
88
|
+
// A unique file path only exists if the config value isn't cumulative nor computed:
|
|
89
|
+
// - cumulative config values have multiple file paths
|
|
90
|
+
// - computed values don't have any file path
|
|
91
|
+
if (definedAt.isComputed || definedAt.isCumulative)
|
|
92
|
+
return null;
|
|
93
|
+
const { filePathToShowToUser } = definedAt.file;
|
|
94
|
+
(0, utils_js_1.assert)(filePathToShowToUser);
|
|
95
|
+
return filePathToShowToUser;
|
|
96
|
+
}
|
|
97
|
+
exports.getConfigValueFilePathToShowToUser = getConfigValueFilePathToShowToUser;
|
|
98
|
+
function getHookFilePathToShowToUser({ definedAt }) {
|
|
99
|
+
const filePathToShowToUser = getConfigValueFilePathToShowToUser({ definedAt });
|
|
100
|
+
(0, utils_js_1.assert)(filePathToShowToUser);
|
|
101
|
+
return filePathToShowToUser;
|
|
102
|
+
}
|
|
103
|
+
exports.getHookFilePathToShowToUser = getHookFilePathToShowToUser;
|
|
@@ -33,9 +33,8 @@ function getPageRoutes(filesystemRoots, pageFilesAll, pageConfigs, allPageIds) {
|
|
|
33
33
|
const configName = 'route';
|
|
34
34
|
const configValue = (0, utils_js_3.getConfigValue)(pageConfig, configName);
|
|
35
35
|
if (configValue) {
|
|
36
|
-
const definedAtInfo = (0, utils_js_3.getConfigDefinedAtInfo)(pageConfig, configName);
|
|
37
36
|
const route = configValue.value;
|
|
38
|
-
const definedAt = (0, utils_js_3.getDefinedAtString)(
|
|
37
|
+
const definedAt = (0, utils_js_3.getDefinedAtString)(configValue, configName);
|
|
39
38
|
if (typeof route === 'string') {
|
|
40
39
|
pageRoute = {
|
|
41
40
|
pageId,
|
|
@@ -140,19 +139,17 @@ function getPageRoutes(filesystemRoots, pageFilesAll, pageConfigs, allPageIds) {
|
|
|
140
139
|
function getGlobalHooks(pageFilesAll, pageConfigs, pageConfigGlobal) {
|
|
141
140
|
// V1 Design
|
|
142
141
|
if (pageConfigs.length > 0) {
|
|
143
|
-
if (pageConfigGlobal.onBeforeRoute) {
|
|
144
|
-
const
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
return { onBeforeRouteHook, filesystemRoots: null };
|
|
155
|
-
}
|
|
142
|
+
if (pageConfigGlobal.configValues.onBeforeRoute?.value) {
|
|
143
|
+
const configValue = pageConfigGlobal.configValues.onBeforeRoute;
|
|
144
|
+
const { value: hookFn } = configValue;
|
|
145
|
+
const hookFilePath = (0, utils_js_3.getHookFilePathToShowToUser)(configValue);
|
|
146
|
+
// TODO: use getConfigDefinedAtString()
|
|
147
|
+
(0, utils_js_1.assertUsage)((0, utils_js_2.isCallable)(hookFn), `The hook onBeforeRoute() defined by ${hookFilePath} should be a function.`);
|
|
148
|
+
const onBeforeRouteHook = {
|
|
149
|
+
hookFilePath: hookFilePath,
|
|
150
|
+
onBeforeRoute: hookFn
|
|
151
|
+
};
|
|
152
|
+
return { onBeforeRouteHook, filesystemRoots: null };
|
|
156
153
|
}
|
|
157
154
|
return { onBeforeRouteHook: null, filesystemRoots: null };
|
|
158
155
|
}
|
|
@@ -10,7 +10,7 @@ const resolveRouteString_js_1 = require("./resolveRouteString.js");
|
|
|
10
10
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
11
11
|
(0, assertIsNotBrowser_js_1.assertIsNotBrowser)(); // Don't bloat the client
|
|
12
12
|
// TODO/v1-release: update
|
|
13
|
-
const configSrc = '[vite.config.js >
|
|
13
|
+
const configSrc = '[vite.config.js > vike({ redirects })]';
|
|
14
14
|
function resolveRedirects(redirects, urlPathname) {
|
|
15
15
|
for (const [urlSource, urlTarget] of Object.entries(redirects)) {
|
|
16
16
|
const urlResolved = resolveRouteStringRedirect(urlSource, urlTarget, urlPathname);
|
|
@@ -22,6 +22,7 @@ async function resolveRouteFunction(routeFunction, pageContext, routeDefinedAt)
|
|
|
22
22
|
result = {};
|
|
23
23
|
}
|
|
24
24
|
(0, utils_js_1.assertUsage)((0, utils_js_1.isPlainObject)(result), `The Route Function ${routeDefinedAt} should return a boolean or a plain JavaScript object (but it's ${picocolors_1.default.cyan(`typeof result === ${JSON.stringify(typeof result)}`)} instead)`);
|
|
25
|
+
// AFAICT this return interface is superfluous. Should we soft-deprecate it and remove it?
|
|
25
26
|
if ('match' in result) {
|
|
26
27
|
const { match } = result;
|
|
27
28
|
(0, utils_js_1.assertUsage)(typeof match === 'boolean', `The ${picocolors_1.default.cyan('match')} value returned by the Route Function ${routeDefinedAt} should be a boolean.`);
|
package/dist/cjs/shared/utils.js
CHANGED
|
@@ -38,7 +38,6 @@ __exportStar(require("../utils/projectInfo.js"), exports);
|
|
|
38
38
|
__exportStar(require("../utils/hasPropertyGetter.js"), exports);
|
|
39
39
|
__exportStar(require("../utils/isPromise.js"), exports);
|
|
40
40
|
__exportStar(require("../utils/checkType.js"), exports);
|
|
41
|
-
__exportStar(require("../utils/assertDefaultExport.js"), exports);
|
|
42
41
|
__exportStar(require("../utils/objectEntries.js"), exports);
|
|
43
42
|
__exportStar(require("../utils/getValuePrintable.js"), exports);
|
|
44
43
|
__exportStar(require("../utils/escapeRegex.js"), exports);
|
|
@@ -3,30 +3,32 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.resolveOutDir = exports.
|
|
6
|
+
exports.resolveOutDir = exports.getOutDirs = void 0;
|
|
7
7
|
const viteIsSSR_js_1 = require("./viteIsSSR.js");
|
|
8
8
|
const assert_js_1 = require("./assert.js");
|
|
9
9
|
const path_shim_js_1 = require("./path-shim.js");
|
|
10
10
|
const filesystemPathHandling_js_1 = require("./filesystemPathHandling.js");
|
|
11
11
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
12
12
|
function getOutDirs(config) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
let outDirRoot;
|
|
14
|
+
{
|
|
15
|
+
const outDir = getOutDirFromViteResolvedConfig(config);
|
|
16
|
+
if (isOutDirRoot(outDir)) {
|
|
17
|
+
outDirRoot = outDir;
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
assertOutDirResolved(outDir, config);
|
|
21
|
+
(0, assert_js_1.assert)(outDir.endsWith('/server') || outDir.endsWith('/client'));
|
|
22
|
+
(0, assert_js_1.assert)('/client'.length === '/server'.length);
|
|
23
|
+
outDirRoot = outDir.slice(0, -1 * '/client'.length);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
18
26
|
return getOutDirsAll(outDirRoot, config.root);
|
|
19
27
|
}
|
|
20
28
|
exports.getOutDirs = getOutDirs;
|
|
21
|
-
function getOutDirs_prerender(config) {
|
|
22
|
-
const outDirRoot = getOutDirFromResolvedConfig(config);
|
|
23
|
-
(0, assert_js_1.assert)(isOutDirRoot(outDirRoot));
|
|
24
|
-
return getOutDirsAll(outDirRoot, config.root);
|
|
25
|
-
}
|
|
26
|
-
exports.getOutDirs_prerender = getOutDirs_prerender;
|
|
27
29
|
/** Appends `client/` or `server/` to `config.build.outDir` */
|
|
28
30
|
function resolveOutDir(config) {
|
|
29
|
-
const outDir =
|
|
31
|
+
const outDir = getOutDirFromViteUserConfig(config) || 'dist';
|
|
30
32
|
// outDir may already be resolved when using Telefunc + vike (because both Telefunc and vike use this logic)
|
|
31
33
|
if (!isOutDirRoot(outDir)) {
|
|
32
34
|
assertOutDirResolved(outDir, config);
|
|
@@ -45,6 +47,7 @@ function resolveOutDir(config) {
|
|
|
45
47
|
exports.resolveOutDir = resolveOutDir;
|
|
46
48
|
function determineOutDirs(outDirRoot) {
|
|
47
49
|
(0, filesystemPathHandling_js_1.assertPosixPath)(outDirRoot);
|
|
50
|
+
(0, assert_js_1.assert)(!outDirRoot.endsWith('/'));
|
|
48
51
|
(0, assert_js_1.assert)(isOutDirRoot(outDirRoot));
|
|
49
52
|
const outDirClient = (0, path_shim_js_1.pathJoin)(outDirRoot, 'client');
|
|
50
53
|
const outDirServer = (0, path_shim_js_1.pathJoin)(outDirRoot, 'server');
|
|
@@ -95,18 +98,22 @@ function assertOutDirResolved(outDir, config) {
|
|
|
95
98
|
(0, assert_js_1.assertUsage)(outDir.endsWith('/client'), wrongUsage);
|
|
96
99
|
}
|
|
97
100
|
}
|
|
98
|
-
function
|
|
101
|
+
function getOutDirFromViteUserConfig(config) {
|
|
99
102
|
let outDir = config.build?.outDir;
|
|
100
103
|
if (outDir === undefined)
|
|
101
104
|
return undefined;
|
|
102
|
-
|
|
103
|
-
outDir = (0, filesystemPathHandling_js_1.toPosixPath)(outDir);
|
|
105
|
+
outDir = normalize(outDir);
|
|
104
106
|
return outDir;
|
|
105
107
|
}
|
|
106
|
-
function
|
|
108
|
+
function getOutDirFromViteResolvedConfig(config) {
|
|
107
109
|
let outDir = config.build.outDir;
|
|
108
|
-
|
|
110
|
+
(0, assert_js_1.assert)(outDir);
|
|
111
|
+
outDir = normalize(outDir);
|
|
112
|
+
return outDir;
|
|
113
|
+
}
|
|
114
|
+
function normalize(outDir) {
|
|
109
115
|
outDir = (0, filesystemPathHandling_js_1.toPosixPath)(outDir);
|
|
116
|
+
outDir = outDir.replace(/\/+$/, ''); // remove trailing slashes
|
|
110
117
|
return outDir;
|
|
111
118
|
}
|
|
112
119
|
function outDirIsAbsolutePath(outDir) {
|
|
@@ -4,7 +4,7 @@ exports.getValuePrintable = void 0;
|
|
|
4
4
|
function getValuePrintable(value) {
|
|
5
5
|
if ([null, undefined].includes(value))
|
|
6
6
|
return String(value);
|
|
7
|
-
if (['
|
|
7
|
+
if (['boolean', 'number', 'string'].includes(typeof value))
|
|
8
8
|
return JSON.stringify(value);
|
|
9
9
|
return null;
|
|
10
10
|
}
|
|
@@ -5,6 +5,8 @@ exports.objectAssign = void 0;
|
|
|
5
5
|
// - With type inference
|
|
6
6
|
// - Preserves property descriptors, which we need for preserving the getters added by addUrlComputedProps()
|
|
7
7
|
function objectAssign(obj, objAddendum) {
|
|
8
|
-
|
|
8
|
+
if (objAddendum) {
|
|
9
|
+
Object.defineProperties(obj, Object.getOwnPropertyDescriptors(objAddendum));
|
|
10
|
+
}
|
|
9
11
|
}
|
|
10
12
|
exports.objectAssign = objectAssign;
|
|
@@ -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.144-commit-e40e9b1';
|
|
6
6
|
const projectInfo = {
|
|
7
7
|
projectName: 'Vike',
|
|
8
8
|
projectVersion: PROJECT_VERSION,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.requireResolve = void 0;
|
|
4
4
|
const assert_js_1 = require("./assert.js");
|
|
5
5
|
const assertIsNotBrowser_js_1 = require("./assertIsNotBrowser.js");
|
|
6
6
|
const assertIsNotProductionRuntime_js_1 = require("./assertIsNotProductionRuntime.js");
|
|
@@ -12,7 +12,7 @@ const importMetaUrl = `file://${__filename}`;
|
|
|
12
12
|
const require_ = (0, module_1.createRequire)(importMetaUrl);
|
|
13
13
|
(0, assertIsNotBrowser_js_1.assertIsNotBrowser)();
|
|
14
14
|
(0, assertIsNotProductionRuntime_js_1.assertIsNotProductionRuntime)();
|
|
15
|
-
function
|
|
15
|
+
function requireResolve(importPath, cwd) {
|
|
16
16
|
(0, filesystemPathHandling_js_1.assertPosixPath)(cwd);
|
|
17
17
|
const clean = addFileExtensionsToRequireResolve();
|
|
18
18
|
importPath = removeFileExtention(importPath);
|
|
@@ -31,7 +31,7 @@ function resolve(importPath, cwd) {
|
|
|
31
31
|
}
|
|
32
32
|
return importedFile;
|
|
33
33
|
}
|
|
34
|
-
exports.
|
|
34
|
+
exports.requireResolve = requireResolve;
|
|
35
35
|
function removeFileExtention(importPath) {
|
|
36
36
|
for (const ext of isScriptFile_js_1.scriptFileExtensionList) {
|
|
37
37
|
const suffix = `.${ext}`;
|
|
@@ -12,7 +12,7 @@ const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
|
12
12
|
// It would be cleaner to:
|
|
13
13
|
// - Call assertUsageErrorIsObject() right after calling the user's hook
|
|
14
14
|
// - Attach the original error: assertUsageError.originalErrorValue = err
|
|
15
|
-
// - Show the original error in
|
|
15
|
+
// - Show the original error in Vike's error handling
|
|
16
16
|
// - Use assertErrorIsObject() throughout Vike's source code
|
|
17
17
|
function warnIfErrorIsNotObject(err) {
|
|
18
18
|
if (!(0, isObject_js_1.isObject)(err)) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { route, type PageRoutes } from '../shared/route/index.js';
|
|
2
2
|
import { type PageFile } from '../shared/getPageFiles.js';
|
|
3
|
-
import {
|
|
3
|
+
import { PageConfigRuntime } from '../shared/page-configs/PageConfig.js';
|
|
4
4
|
export { route, getPagesAndRoutes };
|
|
5
|
-
export type { PageRoutes, PageFile, PageConfig };
|
|
5
|
+
export type { PageRoutes, PageFile, PageConfigRuntime as PageConfig };
|
|
6
6
|
/**
|
|
7
7
|
* Used by {@link https://github.com/magne4000/vite-plugin-vercel|vite-plugin-vercel}
|
|
8
8
|
* to compute some rewrite rules and extract { isr } configs.
|
|
@@ -12,6 +12,6 @@ export type { PageRoutes, PageFile, PageConfig };
|
|
|
12
12
|
declare function getPagesAndRoutes(): Promise<{
|
|
13
13
|
pageRoutes: PageRoutes;
|
|
14
14
|
pageFilesAll: PageFile[];
|
|
15
|
-
pageConfigs:
|
|
15
|
+
pageConfigs: PageConfigRuntime[];
|
|
16
16
|
allPageIds: string[];
|
|
17
17
|
}>;
|
|
@@ -8,8 +8,8 @@ declare function createPageContext<T extends {
|
|
|
8
8
|
_baseServer: string;
|
|
9
9
|
_isProduction: boolean;
|
|
10
10
|
_pageFilesAll: import("../../shared/getPageFiles/getPageFileObject.js").PageFile[];
|
|
11
|
-
_pageConfigs: import("../../shared/page-configs/PageConfig.js").
|
|
12
|
-
_pageConfigGlobal: import("../../shared/page-configs/PageConfig.js").
|
|
11
|
+
_pageConfigs: import("../../shared/page-configs/PageConfig.js").PageConfigRuntime[];
|
|
12
|
+
_pageConfigGlobal: import("../../shared/page-configs/PageConfig.js").PageConfigGlobalRuntime;
|
|
13
13
|
_allPageIds: string[];
|
|
14
14
|
_pageRoutes: import("../../shared/route/loadPageRoutes.js").PageRoutes;
|
|
15
15
|
_onBeforeRouteHook: import("../../shared/route/executeOnBeforeRouteHook.js").OnBeforeRouteHook | null;
|
|
@@ -5,7 +5,7 @@ export { isAlreadyServerSideRouted };
|
|
|
5
5
|
import type { PageContextExports, PageFile } from '../../shared/getPageFiles.js';
|
|
6
6
|
import type { PageContextUrlComputedPropsInternal } from '../../shared/addUrlComputedProps.js';
|
|
7
7
|
import { PageContextForRoute } from '../../shared/route/index.js';
|
|
8
|
-
import type {
|
|
8
|
+
import type { PageConfigRuntime } from '../../shared/page-configs/PageConfig.js';
|
|
9
9
|
import type { PageContextForPassToClientWarning } from '../shared/getPageContextProxyForUser.js';
|
|
10
10
|
type PageContextAddendum = {
|
|
11
11
|
_pageId: string;
|
|
@@ -23,7 +23,7 @@ declare function getPageContextErrorPage(pageContext: {
|
|
|
23
23
|
_allPageIds: string[];
|
|
24
24
|
_isFirstRenderAttempt: boolean;
|
|
25
25
|
_pageFilesAll: PageFile[];
|
|
26
|
-
_pageConfigs:
|
|
26
|
+
_pageConfigs: PageConfigRuntime[];
|
|
27
27
|
} & PageContextPassThrough): Promise<PageContextAddendum>;
|
|
28
28
|
declare function checkIf404(err: unknown): boolean;
|
|
29
29
|
declare function isAlreadyServerSideRouted(err: unknown): boolean;
|
|
@@ -2,9 +2,9 @@ export { getPageId };
|
|
|
2
2
|
declare function getPageId(url: string): Promise<{
|
|
3
3
|
pageId: null;
|
|
4
4
|
pageFilesAll: import("../../shared/getPageFiles/getPageFileObject.js").PageFile[];
|
|
5
|
-
pageConfigs: import("../../shared/page-configs/PageConfig.js").
|
|
5
|
+
pageConfigs: import("../../shared/page-configs/PageConfig.js").PageConfigRuntime[];
|
|
6
6
|
} | {
|
|
7
7
|
pageId: string;
|
|
8
8
|
pageFilesAll: import("../../shared/getPageFiles/getPageFileObject.js").PageFile[];
|
|
9
|
-
pageConfigs: import("../../shared/page-configs/PageConfig.js").
|
|
9
|
+
pageConfigs: import("../../shared/page-configs/PageConfig.js").PageConfigRuntime[];
|
|
10
10
|
}>;
|
|
@@ -103,7 +103,7 @@ function useClientRouter() {
|
|
|
103
103
|
// Start transition before any await's
|
|
104
104
|
if (renderingNumber > 1) {
|
|
105
105
|
if (isTransitioning === false) {
|
|
106
|
-
globalObject.onPageTransitionStart?.(pageContextBase);
|
|
106
|
+
await globalObject.onPageTransitionStart?.(pageContextBase);
|
|
107
107
|
isTransitioning = true;
|
|
108
108
|
}
|
|
109
109
|
}
|
|
@@ -265,7 +265,7 @@ function useClientRouter() {
|
|
|
265
265
|
else if (renderingNumber === renderingCounter) {
|
|
266
266
|
if (pageContext.exports.onPageTransitionEnd) {
|
|
267
267
|
assertHook(pageContext, 'onPageTransitionEnd');
|
|
268
|
-
pageContext.exports.onPageTransitionEnd(pageContext);
|
|
268
|
+
await pageContext.exports.onPageTransitionEnd(pageContext);
|
|
269
269
|
}
|
|
270
270
|
isTransitioning = false;
|
|
271
271
|
}
|
|
@@ -320,7 +320,7 @@ function onBrowserHistoryNavigation(callback) {
|
|
|
320
320
|
if (isHashNavigation) {
|
|
321
321
|
// - `history.state` is uninitialized (`null`) when:
|
|
322
322
|
// - The vike app runs `window.location.hash = '#section'`.
|
|
323
|
-
// - The user clicks on an anchor link `<a href="#section">Section</a>`. (Because
|
|
323
|
+
// - The user clicks on an anchor link `<a href="#section">Section</a>`. (Because Vike's `onLinkClick()` handler skips hash links.)
|
|
324
324
|
// - `history.state` is `null` when uninitialized: https://developer.mozilla.org/en-US/docs/Web/API/History/state
|
|
325
325
|
// - Alternatively, we completely take over hash navigation and reproduce the browser's native behavior upon hash navigation.
|
|
326
326
|
// - Problem: we cannot intercept `window.location.hash = '#section'`. (Or maybe we can with the `hashchange` event?)
|
|
@@ -8,7 +8,7 @@ declare function getPageContext(): Promise<{
|
|
|
8
8
|
_hasPageContextFromClient: boolean;
|
|
9
9
|
} & {
|
|
10
10
|
_pageFilesAll: import("../../shared/getPageFiles/getPageFileObject.js").PageFile[];
|
|
11
|
-
_pageConfigs: import("../../shared/page-configs/PageConfig.js").
|
|
11
|
+
_pageConfigs: import("../../shared/page-configs/PageConfig.js").PageConfigRuntime[];
|
|
12
12
|
} & import("../../shared/getPageFiles/getExports.js").PageContextExports & {
|
|
13
13
|
_pageFilesLoaded: import("../../shared/getPageFiles/getPageFileObject.js").PageFile[];
|
|
14
14
|
}>;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
export { executeOnRenderClientHook };
|
|
2
2
|
import type { PageFile, PageContextExports } from '../../shared/getPageFiles.js';
|
|
3
3
|
import { type PageContextForUserConsumptionClientSide } from './preparePageContextForUserConsumptionClientSide.js';
|
|
4
|
-
import type {
|
|
4
|
+
import type { PageConfigRuntime } from '../../shared/page-configs/PageConfig.js';
|
|
5
5
|
declare function executeOnRenderClientHook<PC extends {
|
|
6
6
|
_pageFilesLoaded: PageFile[];
|
|
7
7
|
urlOriginal?: string;
|
|
8
8
|
urlPathname?: string;
|
|
9
9
|
_pageId: string;
|
|
10
|
-
_pageConfigs:
|
|
10
|
+
_pageConfigs: PageConfigRuntime[];
|
|
11
11
|
} & PageContextExports & PageContextForUserConsumptionClientSide>(pageContext: PC, isClientRouting: boolean): Promise<void>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { type PageFile, type PageContextExports } from '../../shared/getPageFiles.js';
|
|
2
|
-
import type {
|
|
2
|
+
import type { PageConfigRuntime } from '../../shared/page-configs/PageConfig.js';
|
|
3
3
|
export { loadPageFilesClientSide };
|
|
4
4
|
export { isErrorFetchingStaticAssets };
|
|
5
|
-
declare function loadPageFilesClientSide(pageFilesAll: PageFile[], pageConfigs:
|
|
5
|
+
declare function loadPageFilesClientSide(pageFilesAll: PageFile[], pageConfigs: PageConfigRuntime[], pageId: string): Promise<PageContextExports & {
|
|
6
6
|
_pageFilesLoaded: PageFile[];
|
|
7
7
|
}>;
|
|
8
8
|
declare function isErrorFetchingStaticAssets(err: unknown): boolean;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getPageFilesClientSide, getExports } from '../../shared/getPageFiles.js';
|
|
2
2
|
import { findPageConfig } from '../../shared/page-configs/findPageConfig.js';
|
|
3
|
-
import {
|
|
3
|
+
import { loadConfigValues } from '../../shared/page-configs/loadConfigValues.js';
|
|
4
4
|
export { loadPageFilesClientSide };
|
|
5
5
|
export { isErrorFetchingStaticAssets };
|
|
6
6
|
const stamp = '__whileFetchingAssets';
|
|
@@ -13,7 +13,7 @@ async function loadPageFilesClientSide(pageFilesAll, pageConfigs, pageId) {
|
|
|
13
13
|
try {
|
|
14
14
|
// prettier-ignore
|
|
15
15
|
const result = await Promise.all([
|
|
16
|
-
pageConfig &&
|
|
16
|
+
pageConfig && loadConfigValues(pageConfig, isDev),
|
|
17
17
|
...pageFilesClientSide.map((p) => p.loadFile?.()),
|
|
18
18
|
]);
|
|
19
19
|
pageConfigLoaded = result[0];
|