vike 0.4.143 → 0.4.144-commit-68c730d
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 +4 -4
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getFilePathToShowToUser.js +7 -1
- 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 +251 -209
- 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 +25 -24
- 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/getFilePathAbsolute.js +11 -11
- 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/parseUrl.js +1 -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 +5 -5
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getFilePathToShowToUser.d.ts +20 -3
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getFilePathToShowToUser.js +7 -1
- 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 +252 -210
- 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 +25 -24
- 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/getFilePathAbsolute.d.ts +1 -1
- package/dist/esm/utils/getFilePathAbsolute.js +11 -11
- 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/parseUrl.js +1 -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 -3
- 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
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
export { getConfigValue };
|
|
2
2
|
export { getPageConfig };
|
|
3
3
|
export { getConfigDefinedAtString };
|
|
4
|
-
export { getConfigDefinedAtInfo };
|
|
5
4
|
export { getDefinedAtString };
|
|
5
|
+
export { getConfigValueFilePathToShowToUser };
|
|
6
|
+
export { getHookFilePathToShowToUser };
|
|
6
7
|
import { assert, assertUsage, getValuePrintable } from '../utils.js';
|
|
7
8
|
import pc from '@brillout/picocolors';
|
|
8
9
|
import { getExportPath } from './getExportPath.js';
|
|
@@ -11,31 +12,29 @@ function getConfigValue(pageConfig, configName, type) {
|
|
|
11
12
|
const configValue = getConfigValueEntry(pageConfig, configName);
|
|
12
13
|
if (configValue === null)
|
|
13
14
|
return null;
|
|
14
|
-
const { value,
|
|
15
|
+
const { value, definedAt } = configValue;
|
|
15
16
|
if (type)
|
|
16
|
-
assertConfigValueType(value, type, configName,
|
|
17
|
-
return
|
|
17
|
+
assertConfigValueType(value, type, configName, definedAt);
|
|
18
|
+
return configValue;
|
|
18
19
|
}
|
|
19
|
-
function
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
return definedAtInfo;
|
|
20
|
+
function assertConfigValueType(value, type, configName, definedAt) {
|
|
21
|
+
assert(value !== null);
|
|
22
|
+
const typeActual = typeof value;
|
|
23
|
+
if (typeActual === type)
|
|
24
|
+
return;
|
|
25
|
+
const valuePrintable = getValuePrintable(value);
|
|
26
|
+
const problem = valuePrintable !== null ? `value ${pc.cyan(valuePrintable)}` : `type ${pc.cyan(typeActual)}`;
|
|
27
|
+
const configDefinedAt = getConfigDefinedAtString(configName, { definedAt }, true);
|
|
28
|
+
assertUsage(false, `${configDefinedAt} has an invalid ${problem}: it should be a ${pc.cyan(type)} instead`);
|
|
29
29
|
}
|
|
30
30
|
function getConfigValueEntry(pageConfig, configName) {
|
|
31
31
|
const configValue = pageConfig.configValues[configName];
|
|
32
32
|
if (!configValue)
|
|
33
33
|
return null;
|
|
34
|
-
const { value, definedAtInfo } = configValue;
|
|
35
34
|
// Enable users to suppress global config values by setting the local config value to null
|
|
36
|
-
if (value === null)
|
|
35
|
+
if (configValue.value === null)
|
|
37
36
|
return null;
|
|
38
|
-
return
|
|
37
|
+
return configValue;
|
|
39
38
|
}
|
|
40
39
|
function getPageConfig(pageId, pageConfigs) {
|
|
41
40
|
const pageConfig = pageConfigs.find((p) => p.pageId === pageId);
|
|
@@ -43,32 +42,56 @@ function getPageConfig(pageId, pageConfigs) {
|
|
|
43
42
|
assert(pageConfig);
|
|
44
43
|
return pageConfig;
|
|
45
44
|
}
|
|
46
|
-
function
|
|
47
|
-
|
|
48
|
-
const typeActual = typeof value;
|
|
49
|
-
if (typeActual === type)
|
|
50
|
-
return;
|
|
51
|
-
const valuePrintable = getValuePrintable(value);
|
|
52
|
-
const problem = valuePrintable !== null ? `value ${pc.cyan(valuePrintable)}` : `type ${pc.cyan(typeActual)}`;
|
|
53
|
-
const configDefinedAt = getConfigDefinedAtString(configName, { definedAtInfo }, true);
|
|
54
|
-
assertUsage(false, `${configDefinedAt} has an invalid ${problem}: it should be a ${pc.cyan(type)} instead`);
|
|
55
|
-
}
|
|
56
|
-
function getConfigDefinedAtString(configName, { definedAtInfo }, sentenceBegin, append) {
|
|
57
|
-
let configDefinedAt = `${sentenceBegin ? `Config` : `config`} ${pc.cyan(configName)}`;
|
|
58
|
-
if (definedAtInfo !== null) {
|
|
59
|
-
configDefinedAt = `${configDefinedAt} defined at ${getDefinedAtString(definedAtInfo, append)}`;
|
|
60
|
-
}
|
|
45
|
+
function getConfigDefinedAtString(configName, { definedAt }, sentenceBegin) {
|
|
46
|
+
const configDefinedAt = `${sentenceBegin ? `Config` : `config`} ${pc.cyan(configName)} defined ${getSourceString(definedAt, configName)}`;
|
|
61
47
|
return configDefinedAt;
|
|
62
48
|
}
|
|
63
|
-
function
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
const exportPath = getExportPath(fileExportPath);
|
|
67
|
-
if (exportPath) {
|
|
68
|
-
definedAt = `${definedAt} > ${pc.cyan(exportPath)}`;
|
|
49
|
+
function getSourceString(definedAt, configName) {
|
|
50
|
+
if (definedAt.isComputed) {
|
|
51
|
+
return 'internally';
|
|
69
52
|
}
|
|
70
|
-
|
|
71
|
-
|
|
53
|
+
let files;
|
|
54
|
+
if (definedAt.isCumulative) {
|
|
55
|
+
files = definedAt.files;
|
|
72
56
|
}
|
|
73
|
-
|
|
57
|
+
else {
|
|
58
|
+
files = [definedAt.file];
|
|
59
|
+
}
|
|
60
|
+
assert(files.length >= 1);
|
|
61
|
+
const sourceString = files
|
|
62
|
+
.map((source) => {
|
|
63
|
+
const { filePathToShowToUser, fileExportPath } = source;
|
|
64
|
+
let s = filePathToShowToUser;
|
|
65
|
+
const exportPath = getExportPath(fileExportPath, configName);
|
|
66
|
+
if (exportPath) {
|
|
67
|
+
s = `${s} > ${pc.cyan(exportPath)}`;
|
|
68
|
+
}
|
|
69
|
+
if (definedAt.isEffect) {
|
|
70
|
+
s = `${s} > (${pc.blue('effect')})`;
|
|
71
|
+
}
|
|
72
|
+
return s;
|
|
73
|
+
})
|
|
74
|
+
.join(' / ');
|
|
75
|
+
return `at ${sourceString}`;
|
|
76
|
+
}
|
|
77
|
+
function getDefinedAtString(configValue, configName) {
|
|
78
|
+
let sourceString = getSourceString(configValue.definedAt, configName);
|
|
79
|
+
if (sourceString.startsWith('at '))
|
|
80
|
+
sourceString = sourceString.slice('at '.length);
|
|
81
|
+
return sourceString;
|
|
82
|
+
}
|
|
83
|
+
function getConfigValueFilePathToShowToUser({ definedAt }) {
|
|
84
|
+
// A unique file path only exists if the config value isn't cumulative nor computed:
|
|
85
|
+
// - cumulative config values have multiple file paths
|
|
86
|
+
// - computed values don't have any file path
|
|
87
|
+
if (definedAt.isComputed || definedAt.isCumulative)
|
|
88
|
+
return null;
|
|
89
|
+
const { filePathToShowToUser } = definedAt.file;
|
|
90
|
+
assert(filePathToShowToUser);
|
|
91
|
+
return filePathToShowToUser;
|
|
92
|
+
}
|
|
93
|
+
function getHookFilePathToShowToUser({ definedAt }) {
|
|
94
|
+
const filePathToShowToUser = getConfigValueFilePathToShowToUser({ definedAt });
|
|
95
|
+
assert(filePathToShowToUser);
|
|
96
|
+
return filePathToShowToUser;
|
|
74
97
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export { executeGuardHook };
|
|
2
2
|
import type { PageContextExports, PageFile } from '../getPageFiles.js';
|
|
3
|
-
import type {
|
|
3
|
+
import type { PageConfigRuntime } from '../page-configs/PageConfig.js';
|
|
4
4
|
declare function executeGuardHook<T extends PageContextExports & {
|
|
5
5
|
_pageId: string;
|
|
6
6
|
_pageFilesAll: PageFile[];
|
|
7
|
-
_pageConfigs:
|
|
7
|
+
_pageConfigs: PageConfigRuntime[];
|
|
8
8
|
}>(pageContext: T, prepareForUserConsumption: (pageConfig: T) => T | void): Promise<void>;
|
|
@@ -4,12 +4,12 @@ import type { PageFile } from '../getPageFiles.js';
|
|
|
4
4
|
import { PageContextUrlComputedPropsInternal, PageContextUrlSources } from '../addUrlComputedProps.js';
|
|
5
5
|
import { type OnBeforeRouteHook } from './executeOnBeforeRouteHook.js';
|
|
6
6
|
import type { PageRoutes, RouteType } from './loadPageRoutes.js';
|
|
7
|
-
import type {
|
|
7
|
+
import type { PageConfigRuntime, PageConfigGlobalRuntime } from '../page-configs/PageConfig.js';
|
|
8
8
|
type PageContextForRoute = PageContextUrlComputedPropsInternal & {
|
|
9
9
|
_pageFilesAll: PageFile[];
|
|
10
|
-
_pageConfigs:
|
|
10
|
+
_pageConfigs: PageConfigRuntime[];
|
|
11
11
|
_allPageIds: string[];
|
|
12
|
-
_pageConfigGlobal:
|
|
12
|
+
_pageConfigGlobal: PageConfigGlobalRuntime;
|
|
13
13
|
_pageRoutes: PageRoutes;
|
|
14
14
|
_onBeforeRouteHook: OnBeforeRouteHook | null;
|
|
15
15
|
} & PageContextUrlSources;
|
|
@@ -3,7 +3,7 @@ export type { PageRoutes };
|
|
|
3
3
|
export type { RouteType };
|
|
4
4
|
import type { PageFile } from '../getPageFiles.js';
|
|
5
5
|
import type { OnBeforeRouteHook } from './executeOnBeforeRouteHook.js';
|
|
6
|
-
import type {
|
|
6
|
+
import type { PageConfigRuntime, PageConfigGlobalRuntime } from '../page-configs/PageConfig.js';
|
|
7
7
|
type PageRoute = {
|
|
8
8
|
pageId: string;
|
|
9
9
|
comesFromV1PageConfig: boolean;
|
|
@@ -23,7 +23,7 @@ type PageRoute = {
|
|
|
23
23
|
});
|
|
24
24
|
type PageRoutes = PageRoute[];
|
|
25
25
|
type RouteType = 'STRING' | 'FUNCTION' | 'FILESYSTEM';
|
|
26
|
-
declare function loadPageRoutes(pageFilesAll: PageFile[], pageConfigs:
|
|
26
|
+
declare function loadPageRoutes(pageFilesAll: PageFile[], pageConfigs: PageConfigRuntime[], pageConfigGlobal: PageConfigGlobalRuntime, allPageIds: string[]): Promise<{
|
|
27
27
|
pageRoutes: PageRoutes;
|
|
28
28
|
onBeforeRouteHook: null | OnBeforeRouteHook;
|
|
29
29
|
}>;
|
|
@@ -3,7 +3,7 @@ import { isErrorPageId } from '../error-page.js';
|
|
|
3
3
|
import { assert, assertUsage, hasProp, slice } from './utils.js';
|
|
4
4
|
import { deduceRouteStringFromFilesystemPath } from './deduceRouteStringFromFilesystemPath.js';
|
|
5
5
|
import { isCallable } from '../utils.js';
|
|
6
|
-
import {
|
|
6
|
+
import { getConfigValue, getDefinedAtString, getHookFilePathToShowToUser } from '../page-configs/utils.js';
|
|
7
7
|
import { warnDeprecatedAllowKey } from './resolveRouteFunction.js';
|
|
8
8
|
async function loadPageRoutes(
|
|
9
9
|
// TODO: remove all arguments and use GlobalContext instead
|
|
@@ -30,9 +30,8 @@ function getPageRoutes(filesystemRoots, pageFilesAll, pageConfigs, allPageIds) {
|
|
|
30
30
|
const configName = 'route';
|
|
31
31
|
const configValue = getConfigValue(pageConfig, configName);
|
|
32
32
|
if (configValue) {
|
|
33
|
-
const definedAtInfo = getConfigDefinedAtInfo(pageConfig, configName);
|
|
34
33
|
const route = configValue.value;
|
|
35
|
-
const definedAt = getDefinedAtString(
|
|
34
|
+
const definedAt = getDefinedAtString(configValue, configName);
|
|
36
35
|
if (typeof route === 'string') {
|
|
37
36
|
pageRoute = {
|
|
38
37
|
pageId,
|
|
@@ -137,19 +136,17 @@ function getPageRoutes(filesystemRoots, pageFilesAll, pageConfigs, allPageIds) {
|
|
|
137
136
|
function getGlobalHooks(pageFilesAll, pageConfigs, pageConfigGlobal) {
|
|
138
137
|
// V1 Design
|
|
139
138
|
if (pageConfigs.length > 0) {
|
|
140
|
-
if (pageConfigGlobal.onBeforeRoute) {
|
|
141
|
-
const
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
return { onBeforeRouteHook, filesystemRoots: null };
|
|
152
|
-
}
|
|
139
|
+
if (pageConfigGlobal.configValues.onBeforeRoute?.value) {
|
|
140
|
+
const configValue = pageConfigGlobal.configValues.onBeforeRoute;
|
|
141
|
+
const { value: hookFn } = configValue;
|
|
142
|
+
const hookFilePath = getHookFilePathToShowToUser(configValue);
|
|
143
|
+
// TODO: use getConfigDefinedAtString()
|
|
144
|
+
assertUsage(isCallable(hookFn), `The hook onBeforeRoute() defined by ${hookFilePath} should be a function.`);
|
|
145
|
+
const onBeforeRouteHook = {
|
|
146
|
+
hookFilePath: hookFilePath,
|
|
147
|
+
onBeforeRoute: hookFn
|
|
148
|
+
};
|
|
149
|
+
return { onBeforeRouteHook, filesystemRoots: null };
|
|
153
150
|
}
|
|
154
151
|
return { onBeforeRouteHook: null, filesystemRoots: null };
|
|
155
152
|
}
|
|
@@ -7,7 +7,7 @@ import { assertRouteString, resolveRouteString } from './resolveRouteString.js';
|
|
|
7
7
|
import pc from '@brillout/picocolors';
|
|
8
8
|
assertIsNotBrowser(); // Don't bloat the client
|
|
9
9
|
// TODO/v1-release: update
|
|
10
|
-
const configSrc = '[vite.config.js >
|
|
10
|
+
const configSrc = '[vite.config.js > vike({ redirects })]';
|
|
11
11
|
function resolveRedirects(redirects, urlPathname) {
|
|
12
12
|
for (const [urlSource, urlTarget] of Object.entries(redirects)) {
|
|
13
13
|
const urlResolved = resolveRouteStringRedirect(urlSource, urlTarget, urlPathname);
|
|
@@ -20,6 +20,7 @@ async function resolveRouteFunction(routeFunction, pageContext, routeDefinedAt)
|
|
|
20
20
|
result = {};
|
|
21
21
|
}
|
|
22
22
|
assertUsage(isPlainObject(result), `The Route Function ${routeDefinedAt} should return a boolean or a plain JavaScript object (but it's ${pc.cyan(`typeof result === ${JSON.stringify(typeof result)}`)} instead)`);
|
|
23
|
+
// AFAICT this return interface is superfluous. Should we soft-deprecate it and remove it?
|
|
23
24
|
if ('match' in result) {
|
|
24
25
|
const { match } = result;
|
|
25
26
|
assertUsage(typeof match === 'boolean', `The ${pc.cyan('match')} value returned by the Route Function ${routeDefinedAt} should be a boolean.`);
|
|
@@ -12,18 +12,17 @@ import type { ConfigEntries, ExportsAll } from './getPageFiles/getExports.js';
|
|
|
12
12
|
import type { Config } from './page-configs/Config.js';
|
|
13
13
|
import type { PageContextConfig } from './page-configs/Config/PageContextConfig.js';
|
|
14
14
|
import type { AbortStatusCode } from './route/abort.js';
|
|
15
|
-
type PageContext = PageContextWithClientRouting;
|
|
16
|
-
type PageContextClient = PageContextClientWithClientRouting;
|
|
17
|
-
type PageContextWithClientRouting = PageContextClientWithClientRouting | PageContextServer;
|
|
18
|
-
type PageContextWithServerRouting = PageContextClientWithServerRouting | PageContextServer;
|
|
19
15
|
type PageContextServer = PageContextBuiltInServer & Vike.PageContext;
|
|
20
|
-
type
|
|
16
|
+
type PageContext = PageContextClient | PageContextServer;
|
|
17
|
+
type PageContextClient = PageContextBuiltInClientWithClientRouting & Vike.PageContext;
|
|
18
|
+
type PageContextWithServerRouting = PageContextClientWithServerRouting | PageContextServer;
|
|
21
19
|
type PageContextClientWithServerRouting = PageContextBuiltInClientWithServerRouting & Vike.PageContext;
|
|
22
20
|
/** Built-in `pageContext` properties set by vike.
|
|
23
21
|
*
|
|
24
22
|
* https://vike.dev/pageContext
|
|
25
23
|
*/
|
|
26
24
|
type PageContextBuiltInServer<Page = [never]> = PageContextBuiltInCommon<Page> & PageContextUrlComputedPropsServer;
|
|
25
|
+
/** For Vike internal use */
|
|
27
26
|
type PageContextBuiltInServerInternal<Page = [never]> = PageContextBuiltInCommon<Page> & PageContextUrlComputedPropsInternal;
|
|
28
27
|
type PageContextBuiltInCommon<Page = [never]> = {
|
|
29
28
|
/** The `export { Page }` of your `.page.js` file.
|
|
@@ -57,7 +56,10 @@ type PageContextBuiltInCommon<Page = [never]> = {
|
|
|
57
56
|
* https://vike.dev/exports
|
|
58
57
|
*/
|
|
59
58
|
exportsAll: ExportsAll;
|
|
60
|
-
/** The URL
|
|
59
|
+
/** The URL you provided to Vike when calling `renderPage({ urlOriginal })` in your server middleware.
|
|
60
|
+
*
|
|
61
|
+
* https://vike.dev/renderPage
|
|
62
|
+
*/
|
|
61
63
|
urlOriginal: string;
|
|
62
64
|
/** If an error occurs, whether the error is a `404 Page Not Found`.
|
|
63
65
|
*
|
|
@@ -18,7 +18,6 @@ export * from '../utils/projectInfo.js';
|
|
|
18
18
|
export * from '../utils/hasPropertyGetter.js';
|
|
19
19
|
export * from '../utils/isPromise.js';
|
|
20
20
|
export * from '../utils/checkType.js';
|
|
21
|
-
export * from '../utils/assertDefaultExport.js';
|
|
22
21
|
export * from '../utils/objectEntries.js';
|
|
23
22
|
export * from '../utils/getValuePrintable.js';
|
|
24
23
|
export * from '../utils/escapeRegex.js';
|
package/dist/esm/shared/utils.js
CHANGED
|
@@ -22,7 +22,6 @@ export * from '../utils/projectInfo.js';
|
|
|
22
22
|
export * from '../utils/hasPropertyGetter.js';
|
|
23
23
|
export * from '../utils/isPromise.js';
|
|
24
24
|
export * from '../utils/checkType.js';
|
|
25
|
-
export * from '../utils/assertDefaultExport.js';
|
|
26
25
|
export * from '../utils/objectEntries.js';
|
|
27
26
|
export * from '../utils/getValuePrintable.js';
|
|
28
27
|
export * from '../utils/escapeRegex.js';
|
|
@@ -6,10 +6,11 @@ export type { PageContextClientWithServerRouting } from '../shared/types.js';
|
|
|
6
6
|
export type { PageContextBuiltInServer } from '../shared/types.js';
|
|
7
7
|
export type { PageContextBuiltInClientWithClientRouting } from '../shared/types.js';
|
|
8
8
|
export type { PageContextBuiltInClientWithServerRouting } from '../shared/types.js';
|
|
9
|
-
export type { Config, ConfigMeta as Meta } from '../shared/page-configs/Config.js';
|
|
9
|
+
export type { Config, ConfigMeta as Meta, GuardAsync, GuardSync, OnBeforePrerenderStartAsync, OnBeforePrerenderStartSync, OnBeforeRenderAsync, OnBeforeRenderSync, OnBeforeRouteAsync, OnBeforeRouteSync, OnHydrationEndAsync, OnHydrationEndSync, OnPageTransitionEndAsync, OnPageTransitionEndSync, OnPageTransitionStartAsync, OnPageTransitionStartSync, OnPrerenderStartAsync, OnPrerenderStartSync, OnRenderClientAsync, OnRenderClientSync, OnRenderHtmlAsync, OnRenderHtmlSync, RouteAsync, RouteSync } from '../shared/page-configs/Config.js';
|
|
10
10
|
export type { ConfigEnv } from '../shared/page-configs/PageConfig.js';
|
|
11
11
|
export type { ConfigDefinition, ConfigEffect } from '../node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js';
|
|
12
12
|
export type { ConfigEntries } from '../shared/getPageFiles/getExports.js';
|
|
13
|
+
export type { Url } from '../shared/addUrlComputedProps.js';
|
|
13
14
|
export type { InjectFilterEntry } from '../node/runtime/html/injectAssets/getHtmlTags.js';
|
|
14
15
|
export { defineConfig } from './defineConfig.js';
|
|
15
16
|
import type { ConfigEnv } from '../shared/page-configs/PageConfig.js';
|
|
@@ -2,4 +2,4 @@ export { getFilePathAbsolute };
|
|
|
2
2
|
export { getFilePathRelativeToUserRootDir };
|
|
3
3
|
import type { ResolvedConfig } from 'vite';
|
|
4
4
|
declare function getFilePathAbsolute(filePath: string, config: ResolvedConfig): string;
|
|
5
|
-
declare function getFilePathRelativeToUserRootDir(
|
|
5
|
+
declare function getFilePathRelativeToUserRootDir(filePathAbsoluteFilesystem: string, userRootDir: string, alwaysRelative?: boolean): string;
|
|
@@ -30,26 +30,26 @@ function getFilePathAbsolute(filePath, config) {
|
|
|
30
30
|
filePathUnresolved = path.posix.join(root, filePath);
|
|
31
31
|
assertPathIsFilesystemAbsolute(filePathUnresolved);
|
|
32
32
|
}
|
|
33
|
-
let
|
|
33
|
+
let filePathAbsoluteFilesystem;
|
|
34
34
|
try {
|
|
35
|
-
|
|
35
|
+
filePathAbsoluteFilesystem = require_.resolve(filePathUnresolved, { paths: [config.root] });
|
|
36
36
|
}
|
|
37
37
|
catch (err) {
|
|
38
38
|
console.error(err);
|
|
39
39
|
assert(false);
|
|
40
40
|
}
|
|
41
|
-
|
|
42
|
-
assertPathIsFilesystemAbsolute(
|
|
43
|
-
return
|
|
41
|
+
filePathAbsoluteFilesystem = toPosixPath(filePathAbsoluteFilesystem);
|
|
42
|
+
assertPathIsFilesystemAbsolute(filePathAbsoluteFilesystem);
|
|
43
|
+
return filePathAbsoluteFilesystem;
|
|
44
44
|
}
|
|
45
|
-
function getFilePathRelativeToUserRootDir(
|
|
46
|
-
assertPosixPath(
|
|
45
|
+
function getFilePathRelativeToUserRootDir(filePathAbsoluteFilesystem, userRootDir, alwaysRelative = false) {
|
|
46
|
+
assertPosixPath(filePathAbsoluteFilesystem);
|
|
47
47
|
assertPosixPath(userRootDir);
|
|
48
|
-
let filePathRelativeToUserRootDir = path.posix.relative(userRootDir,
|
|
49
|
-
if (
|
|
48
|
+
let filePathRelativeToUserRootDir = path.posix.relative(userRootDir, filePathAbsoluteFilesystem);
|
|
49
|
+
if (filePathAbsoluteFilesystem.startsWith(userRootDir)) {
|
|
50
50
|
assert(!filePathRelativeToUserRootDir.startsWith('.') && !filePathRelativeToUserRootDir.startsWith('/'),
|
|
51
51
|
// Surprinsingly, this assertion seem to fail sometimes: https://github.com/vikejs/vike/issues/1139
|
|
52
|
-
{ filePathRelativeToUserRootDir,
|
|
52
|
+
{ filePathRelativeToUserRootDir, filePathAbsoluteFilesystem, userRootDir });
|
|
53
53
|
filePathRelativeToUserRootDir = `/${filePathRelativeToUserRootDir}`;
|
|
54
54
|
return filePathRelativeToUserRootDir;
|
|
55
55
|
}
|
|
@@ -58,7 +58,7 @@ function getFilePathRelativeToUserRootDir(filePathAbsolute, userRootDir, alwaysR
|
|
|
58
58
|
return filePathRelativeToUserRootDir;
|
|
59
59
|
}
|
|
60
60
|
else {
|
|
61
|
-
return
|
|
61
|
+
return filePathAbsoluteFilesystem;
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export { getOutDirs };
|
|
2
|
-
export { getOutDirs_prerender };
|
|
3
2
|
export { resolveOutDir };
|
|
4
3
|
import type { UserConfig, ResolvedConfig } from 'vite';
|
|
5
4
|
type OutDirs = {
|
|
@@ -11,6 +10,5 @@ type OutDirs = {
|
|
|
11
10
|
outDirServer: string;
|
|
12
11
|
};
|
|
13
12
|
declare function getOutDirs(config: ResolvedConfig): OutDirs;
|
|
14
|
-
declare function getOutDirs_prerender(config: ResolvedConfig): OutDirs;
|
|
15
13
|
/** Appends `client/` or `server/` to `config.build.outDir` */
|
|
16
14
|
declare function resolveOutDir(config: UserConfig): string;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export { getOutDirs };
|
|
2
|
-
export { getOutDirs_prerender };
|
|
3
2
|
export { resolveOutDir };
|
|
4
3
|
import { viteIsSSR } from './viteIsSSR.js';
|
|
5
4
|
import { assert, assertUsage } from './assert.js';
|
|
@@ -7,21 +6,24 @@ import { pathJoin } from './path-shim.js';
|
|
|
7
6
|
import { assertPosixPath, toPosixPath } from './filesystemPathHandling.js';
|
|
8
7
|
import pc from '@brillout/picocolors';
|
|
9
8
|
function getOutDirs(config) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
9
|
+
let outDirRoot;
|
|
10
|
+
{
|
|
11
|
+
const outDir = getOutDirFromViteResolvedConfig(config);
|
|
12
|
+
if (isOutDirRoot(outDir)) {
|
|
13
|
+
outDirRoot = outDir;
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
assertOutDirResolved(outDir, config);
|
|
17
|
+
assert(outDir.endsWith('/server') || outDir.endsWith('/client'));
|
|
18
|
+
assert('/client'.length === '/server'.length);
|
|
19
|
+
outDirRoot = outDir.slice(0, -1 * '/client'.length);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
20
22
|
return getOutDirsAll(outDirRoot, config.root);
|
|
21
23
|
}
|
|
22
24
|
/** Appends `client/` or `server/` to `config.build.outDir` */
|
|
23
25
|
function resolveOutDir(config) {
|
|
24
|
-
const outDir =
|
|
26
|
+
const outDir = getOutDirFromViteUserConfig(config) || 'dist';
|
|
25
27
|
// outDir may already be resolved when using Telefunc + vike (because both Telefunc and vike use this logic)
|
|
26
28
|
if (!isOutDirRoot(outDir)) {
|
|
27
29
|
assertOutDirResolved(outDir, config);
|
|
@@ -39,6 +41,7 @@ function resolveOutDir(config) {
|
|
|
39
41
|
}
|
|
40
42
|
function determineOutDirs(outDirRoot) {
|
|
41
43
|
assertPosixPath(outDirRoot);
|
|
44
|
+
assert(!outDirRoot.endsWith('/'));
|
|
42
45
|
assert(isOutDirRoot(outDirRoot));
|
|
43
46
|
const outDirClient = pathJoin(outDirRoot, 'client');
|
|
44
47
|
const outDirServer = pathJoin(outDirRoot, 'server');
|
|
@@ -89,18 +92,22 @@ function assertOutDirResolved(outDir, config) {
|
|
|
89
92
|
assertUsage(outDir.endsWith('/client'), wrongUsage);
|
|
90
93
|
}
|
|
91
94
|
}
|
|
92
|
-
function
|
|
95
|
+
function getOutDirFromViteUserConfig(config) {
|
|
93
96
|
let outDir = config.build?.outDir;
|
|
94
97
|
if (outDir === undefined)
|
|
95
98
|
return undefined;
|
|
96
|
-
|
|
97
|
-
outDir = toPosixPath(outDir);
|
|
99
|
+
outDir = normalize(outDir);
|
|
98
100
|
return outDir;
|
|
99
101
|
}
|
|
100
|
-
function
|
|
102
|
+
function getOutDirFromViteResolvedConfig(config) {
|
|
101
103
|
let outDir = config.build.outDir;
|
|
102
|
-
|
|
104
|
+
assert(outDir);
|
|
105
|
+
outDir = normalize(outDir);
|
|
106
|
+
return outDir;
|
|
107
|
+
}
|
|
108
|
+
function normalize(outDir) {
|
|
103
109
|
outDir = toPosixPath(outDir);
|
|
110
|
+
outDir = outDir.replace(/\/+$/, ''); // remove trailing slashes
|
|
104
111
|
return outDir;
|
|
105
112
|
}
|
|
106
113
|
function outDirIsAbsolutePath(outDir) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export function getValuePrintable(value) {
|
|
2
2
|
if ([null, undefined].includes(value))
|
|
3
3
|
return String(value);
|
|
4
|
-
if (['
|
|
4
|
+
if (['boolean', 'number', 'string'].includes(typeof value))
|
|
5
5
|
return JSON.stringify(value);
|
|
6
6
|
return null;
|
|
7
7
|
}
|
|
@@ -3,5 +3,7 @@ export { objectAssign };
|
|
|
3
3
|
// - With type inference
|
|
4
4
|
// - Preserves property descriptors, which we need for preserving the getters added by addUrlComputedProps()
|
|
5
5
|
function objectAssign(obj, objAddendum) {
|
|
6
|
-
|
|
6
|
+
if (objAddendum) {
|
|
7
|
+
Object.defineProperties(obj, Object.getOwnPropertyDescriptors(objAddendum));
|
|
8
|
+
}
|
|
7
9
|
}
|
|
@@ -51,7 +51,7 @@ function parseUrl(url, baseServer) {
|
|
|
51
51
|
const searchAll = {};
|
|
52
52
|
Array.from(new URLSearchParams(searchOriginal || '')).forEach(([key, val]) => {
|
|
53
53
|
search[key] = val;
|
|
54
|
-
searchAll[key] = [...(searchAll[key]
|
|
54
|
+
searchAll[key] = [...(searchAll.hasOwnProperty(key) ? searchAll[key] : []), val];
|
|
55
55
|
});
|
|
56
56
|
// Origin + pathname
|
|
57
57
|
const { origin, pathname: pathnameResolved } = parsePathname(urlWithoutHashNorSearch, baseServer);
|
|
@@ -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.144-commit-68c730d";
|
|
9
9
|
npmPackageName: "vike";
|
|
10
10
|
githubRepository: "https://github.com/vikejs/vike";
|
|
11
11
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { requireResolve };
|
|
2
2
|
import { assert } from './assert.js';
|
|
3
3
|
import { assertIsNotBrowser } from './assertIsNotBrowser.js';
|
|
4
4
|
import { assertIsNotProductionRuntime } from './assertIsNotProductionRuntime.js';
|
|
@@ -10,7 +10,7 @@ const importMetaUrl = import.meta.url;
|
|
|
10
10
|
const require_ = createRequire(importMetaUrl);
|
|
11
11
|
assertIsNotBrowser();
|
|
12
12
|
assertIsNotProductionRuntime();
|
|
13
|
-
function
|
|
13
|
+
function requireResolve(importPath, cwd) {
|
|
14
14
|
assertPosixPath(cwd);
|
|
15
15
|
const clean = addFileExtensionsToRequireResolve();
|
|
16
16
|
importPath = removeFileExtention(importPath);
|
|
@@ -7,7 +7,7 @@ assertIsNotBrowser();
|
|
|
7
7
|
// It would be cleaner to:
|
|
8
8
|
// - Call assertUsageErrorIsObject() right after calling the user's hook
|
|
9
9
|
// - Attach the original error: assertUsageError.originalErrorValue = err
|
|
10
|
-
// - Show the original error in
|
|
10
|
+
// - Show the original error in Vike's error handling
|
|
11
11
|
// - Use assertErrorIsObject() throughout Vike's source code
|
|
12
12
|
function warnIfErrorIsNotObject(err) {
|
|
13
13
|
if (!isObject(err)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vike",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.144-commit-68c730d",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"dev": "tsc --watch",
|
|
6
6
|
"build": "rimraf dist/ && pnpm run build:esm && pnpm run build:cjs",
|
|
@@ -162,8 +162,7 @@
|
|
|
162
162
|
"vike": "./node/cli/bin-entry.js"
|
|
163
163
|
},
|
|
164
164
|
"devDependencies": {
|
|
165
|
-
"@brillout/
|
|
166
|
-
"@brillout/release-me": "^0.1.7",
|
|
165
|
+
"@brillout/release-me": "^0.1.8",
|
|
167
166
|
"@types/estree": "^1.0.0",
|
|
168
167
|
"@types/jest": "^27.4.1",
|
|
169
168
|
"@types/node": "^20.1.0",
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isConfigEnvMatch = void 0;
|
|
4
|
-
function isConfigEnvMatch(configEnv, isForClientSide, isClientRouting) {
|
|
5
|
-
if (configEnv === '_routing-eager' || configEnv === 'config-only')
|
|
6
|
-
return false;
|
|
7
|
-
if (configEnv === (isForClientSide ? 'server-only' : 'client-only'))
|
|
8
|
-
return false;
|
|
9
|
-
if (configEnv === '_routing-lazy' && isForClientSide && !isClientRouting)
|
|
10
|
-
return false;
|
|
11
|
-
return true;
|
|
12
|
-
}
|
|
13
|
-
exports.isConfigEnvMatch = isConfigEnvMatch;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.assertPageConfigGlobal = exports.assertPageConfigs = void 0;
|
|
4
|
-
const utils_js_1 = require("../utils.js");
|
|
5
|
-
function assertPageConfigs(pageConfigs) {
|
|
6
|
-
(0, utils_js_1.assert)(Array.isArray(pageConfigs));
|
|
7
|
-
pageConfigs.forEach((pageConfig) => {
|
|
8
|
-
(0, utils_js_1.assert)((0, utils_js_1.isObject)(pageConfig));
|
|
9
|
-
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(pageConfig, 'pageId', 'string'));
|
|
10
|
-
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(pageConfig, 'routeFilesystem'));
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
exports.assertPageConfigs = assertPageConfigs;
|
|
14
|
-
function assertPageConfigGlobal(pageConfigGlobal) {
|
|
15
|
-
(0, utils_js_1.assert)(pageConfigGlobal);
|
|
16
|
-
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(pageConfigGlobal, 'onBeforeRoute'));
|
|
17
|
-
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(pageConfigGlobal, 'onPrerenderStart'));
|
|
18
|
-
}
|
|
19
|
-
exports.assertPageConfigGlobal = assertPageConfigGlobal;
|