vike 0.4.144-commit-6aef8a6 → 0.4.144-commit-7f5e99a
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/__internal/index.js +6 -2
- package/dist/cjs/node/plugin/plugins/buildConfig.js +2 -2
- package/dist/cjs/node/plugin/plugins/commonConfig.js +0 -3
- package/dist/cjs/node/plugin/plugins/devConfig/determineOptimizeDeps.js +5 -5
- package/dist/cjs/node/plugin/plugins/devConfig/index.js +1 -0
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +4 -3
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +29 -42
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js +2 -2
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigs.js +14 -5
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/helpers.js +1 -14
- package/dist/cjs/node/plugin/plugins/previewConfig.js +11 -2
- package/dist/cjs/node/prerender/runPrerender.js +16 -17
- package/dist/cjs/node/prerender/utils.js +1 -1
- package/dist/cjs/node/runtime/html/serializePageContextClientSide.js +20 -6
- package/dist/cjs/node/runtime/renderPage/renderPageAlreadyRouted.js +2 -2
- package/dist/cjs/node/runtime/renderPage.js +2 -2
- package/dist/cjs/node/runtime/utils.js +1 -1
- package/dist/cjs/node/shared/getClientEntryFilePath.js +2 -2
- package/dist/cjs/shared/addUrlComputedProps.js +24 -12
- package/dist/cjs/shared/getPageFiles/analyzeClientSide.js +4 -6
- package/dist/cjs/shared/getPageFiles/getExports.js +3 -3
- package/dist/cjs/shared/hooks/getHook.js +1 -1
- package/dist/cjs/shared/page-configs/helpers/getConfigDefinedAtString.js +43 -0
- package/dist/cjs/shared/page-configs/helpers/getConfigValue.js +44 -0
- package/dist/cjs/shared/page-configs/helpers.js +33 -0
- package/dist/cjs/shared/page-configs/serialize/parseConfigValuesImported.js +6 -8
- package/dist/cjs/shared/page-configs/serialize/parsePageConfigs.js +2 -2
- package/dist/cjs/shared/page-configs/serialize/serializeConfigValue.js +2 -2
- package/dist/cjs/shared/route/executeOnBeforeRouteHook.js +11 -13
- package/dist/cjs/shared/route/index.js +3 -3
- package/dist/cjs/shared/route/loadPageRoutes.js +11 -10
- package/dist/cjs/shared/route/resolveRouteFunction.js +1 -1
- package/dist/cjs/shared/utils.js +1 -1
- package/dist/cjs/utils/{hasPropertyGetter.js → isPropertyGetter.js} +3 -3
- package/dist/cjs/utils/projectInfo.js +1 -1
- package/dist/esm/__internal/index.d.ts +6 -3
- package/dist/esm/__internal/index.js +8 -3
- package/dist/esm/client/client-routing-runtime/createPageContext.d.ts +2 -3
- package/dist/esm/client/client-routing-runtime/createPageContext.js +3 -3
- package/dist/esm/client/client-routing-runtime/entry.js +2 -2
- package/dist/esm/client/client-routing-runtime/getPageContext.d.ts +0 -1
- package/dist/esm/client/client-routing-runtime/getPageContext.js +4 -7
- package/dist/esm/client/client-routing-runtime/getPageId.d.ts +1 -1
- package/dist/esm/client/client-routing-runtime/getPageId.js +4 -7
- package/dist/esm/client/client-routing-runtime/history.d.ts +3 -1
- package/dist/esm/client/client-routing-runtime/history.js +26 -8
- package/dist/esm/client/client-routing-runtime/installClientRouter.d.ts +21 -0
- package/dist/esm/client/client-routing-runtime/{useClientRouter.js → installClientRouter.js} +248 -242
- package/dist/esm/client/client-routing-runtime/isClientSideRoutable.d.ts +8 -0
- package/dist/esm/client/client-routing-runtime/isClientSideRoutable.js +15 -0
- package/dist/esm/client/client-routing-runtime/navigate.d.ts +0 -2
- package/dist/esm/client/client-routing-runtime/navigate.js +10 -8
- package/dist/esm/client/client-routing-runtime/prefetch.js +12 -5
- package/dist/esm/client/client-routing-runtime/skipLink.d.ts +0 -1
- package/dist/esm/client/client-routing-runtime/skipLink.js +1 -2
- package/dist/esm/client/shared/executeOnRenderClientHook.js +6 -5
- package/dist/esm/client/shared/getPageContextProxyForUser.js +13 -7
- package/dist/esm/node/plugin/plugins/buildConfig.js +1 -1
- package/dist/esm/node/plugin/plugins/commonConfig.js +0 -3
- package/dist/esm/node/plugin/plugins/devConfig/determineOptimizeDeps.js +5 -5
- package/dist/esm/node/plugin/plugins/devConfig/index.js +1 -0
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.d.ts +2 -2
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +4 -3
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +29 -42
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigs.js +15 -6
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/helpers.js +1 -14
- package/dist/esm/node/plugin/plugins/previewConfig.js +11 -2
- package/dist/esm/node/prerender/runPrerender.js +11 -12
- package/dist/esm/node/prerender/utils.d.ts +1 -1
- package/dist/esm/node/prerender/utils.js +1 -1
- package/dist/esm/node/runtime/html/serializePageContextClientSide.js +21 -7
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.js +1 -1
- package/dist/esm/node/runtime/renderPage.js +2 -2
- package/dist/esm/node/runtime/utils.d.ts +1 -1
- package/dist/esm/node/runtime/utils.js +1 -1
- package/dist/esm/node/shared/getClientEntryFilePath.js +1 -1
- package/dist/esm/shared/addUrlComputedProps.d.ts +1 -0
- package/dist/esm/shared/addUrlComputedProps.js +25 -13
- package/dist/esm/shared/getPageFiles/analyzeClientSide.js +2 -4
- package/dist/esm/shared/getPageFiles/getExports.js +2 -2
- package/dist/esm/shared/hooks/getHook.js +1 -1
- package/dist/esm/shared/page-configs/PageConfig.d.ts +4 -12
- package/dist/esm/shared/page-configs/helpers/getConfigDefinedAtString.d.ts +7 -0
- package/dist/esm/shared/page-configs/helpers/getConfigDefinedAtString.js +37 -0
- package/dist/esm/shared/page-configs/helpers/getConfigValue.d.ts +14 -0
- package/dist/esm/shared/page-configs/helpers/getConfigValue.js +38 -0
- package/dist/esm/shared/page-configs/helpers.d.ts +13 -0
- package/dist/esm/shared/page-configs/helpers.js +27 -0
- package/dist/esm/shared/page-configs/serialize/parseConfigValuesImported.js +6 -8
- package/dist/esm/shared/page-configs/serialize/parsePageConfigs.js +2 -2
- package/dist/esm/shared/page-configs/serialize/serializeConfigValue.js +2 -2
- package/dist/esm/shared/route/executeOnBeforeRouteHook.d.ts +1 -1
- package/dist/esm/shared/route/executeOnBeforeRouteHook.js +11 -13
- package/dist/esm/shared/route/index.d.ts +11 -9
- package/dist/esm/shared/route/index.js +3 -3
- package/dist/esm/shared/route/loadPageRoutes.js +7 -6
- package/dist/esm/shared/route/resolveRouteFunction.js +1 -1
- package/dist/esm/shared/utils.d.ts +1 -1
- package/dist/esm/shared/utils.js +1 -1
- package/dist/esm/utils/isPropertyGetter.d.ts +1 -0
- package/dist/esm/utils/{hasPropertyGetter.js → isPropertyGetter.js} +1 -1
- package/dist/esm/utils/projectInfo.d.ts +1 -1
- package/dist/esm/utils/projectInfo.js +1 -1
- package/package.json +2 -2
- package/dist/cjs/shared/page-configs/utils.js +0 -96
- package/dist/esm/client/client-routing-runtime/skipLink/isClientSideRoutable.d.ts +0 -2
- package/dist/esm/client/client-routing-runtime/skipLink/isClientSideRoutable.js +0 -15
- package/dist/esm/client/client-routing-runtime/useClientRouter.d.ts +0 -6
- package/dist/esm/shared/page-configs/utils.d.ts +0 -35
- package/dist/esm/shared/page-configs/utils.js +0 -90
- package/dist/esm/utils/hasPropertyGetter.d.ts +0 -1
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// Internal functions of vike needed by other plugins are exported via this file
|
|
3
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
3
|
exports.getPagesAndRoutes = exports.route = void 0;
|
|
5
4
|
const index_js_1 = require("../shared/route/index.js");
|
|
6
|
-
Object.defineProperty(exports, "route", { enumerable: true, get: function () { return index_js_1.route; } });
|
|
7
5
|
const globalContext_js_1 = require("../node/runtime/globalContext.js");
|
|
8
6
|
const nodeEnv_js_1 = require("../utils/nodeEnv.js");
|
|
9
7
|
const assert_js_1 = require("../utils/assert.js");
|
|
@@ -29,3 +27,9 @@ async function getPagesAndRoutes() {
|
|
|
29
27
|
};
|
|
30
28
|
}
|
|
31
29
|
exports.getPagesAndRoutes = getPagesAndRoutes;
|
|
30
|
+
async function route(pageContext) {
|
|
31
|
+
const pageContextFromRoute = await (0, index_js_1.route)(pageContext);
|
|
32
|
+
// Old interface
|
|
33
|
+
return { pageContextAddendum: pageContextFromRoute };
|
|
34
|
+
}
|
|
35
|
+
exports.route = route;
|
|
@@ -7,7 +7,7 @@ exports.analyzeClientEntries = exports.assertRollupInput = exports.buildConfig =
|
|
|
7
7
|
const utils_js_1 = require("../utils.js");
|
|
8
8
|
const virtualFileImportUserCode_js_1 = require("../../shared/virtual-files/virtualFileImportUserCode.js");
|
|
9
9
|
const getVikeConfig_js_1 = require("./importUserCode/v1-design/getVikeConfig.js");
|
|
10
|
-
const
|
|
10
|
+
const helpers_js_1 = require("../../../shared/page-configs/helpers.js");
|
|
11
11
|
const findPageFiles_js_1 = require("../shared/findPageFiles.js");
|
|
12
12
|
const getConfigVike_js_1 = require("../../shared/getConfigVike.js");
|
|
13
13
|
const virtualFilePageConfigValuesAll_js_1 = require("../../shared/virtual-files/virtualFilePageConfigValuesAll.js");
|
|
@@ -112,7 +112,7 @@ function analyzeClientEntries(pageConfigs, config) {
|
|
|
112
112
|
let clientEntries = {};
|
|
113
113
|
let clientFilePaths = [];
|
|
114
114
|
pageConfigs.forEach((pageConfig) => {
|
|
115
|
-
const configValue = (0,
|
|
115
|
+
const configValue = (0, helpers_js_1.getConfigValue)(pageConfig, 'clientRouting', 'boolean');
|
|
116
116
|
if (configValue?.value) {
|
|
117
117
|
hasClientRouting = true;
|
|
118
118
|
}
|
|
@@ -37,18 +37,18 @@ async function getPageDeps(config, pageConfigs, isDev) {
|
|
|
37
37
|
configValueSourcesRelevant.forEach((configValueSource) => {
|
|
38
38
|
if (!configValueSource.valueIsImportedAtRuntime)
|
|
39
39
|
return;
|
|
40
|
-
const {
|
|
40
|
+
const { definedAt, configEnv } = configValueSource;
|
|
41
41
|
if (configEnv !== 'client-only' && configEnv !== 'server-and-client')
|
|
42
42
|
return;
|
|
43
|
-
if (
|
|
44
|
-
const { filePathAbsoluteFilesystem } =
|
|
43
|
+
if (definedAt.filePathRelativeToUserRootDir !== null) {
|
|
44
|
+
const { filePathAbsoluteFilesystem } = definedAt;
|
|
45
45
|
(0, utils_js_1.assert)(filePathAbsoluteFilesystem);
|
|
46
46
|
// Surprisingly Vite expects entries to be absolute paths
|
|
47
47
|
entries.push(filePathAbsoluteFilesystem);
|
|
48
48
|
}
|
|
49
49
|
else {
|
|
50
|
-
// Adding
|
|
51
|
-
const { importPathAbsolute } =
|
|
50
|
+
// Adding definedAt.filePathAbsoluteFilesystem doesn't work for npm packages, I guess because of Vite's config.server.fs.allow
|
|
51
|
+
const { importPathAbsolute } = definedAt;
|
|
52
52
|
(0, utils_js_1.assert)(importPathAbsolute);
|
|
53
53
|
// We need to differentiate between npm package imports and path aliases.
|
|
54
54
|
// There are path aliases that cannot be distinguished from npm package names.
|
|
@@ -49,16 +49,17 @@ const configDefinitionsBuiltIn = {
|
|
|
49
49
|
_valueIsFilePath: true
|
|
50
50
|
},
|
|
51
51
|
clientRouting: {
|
|
52
|
-
|
|
52
|
+
// We could make it 'server-only' (we don't yet because of some legacy V0.4 design code)
|
|
53
|
+
env: 'server-and-client'
|
|
53
54
|
},
|
|
54
55
|
prerender: {
|
|
55
56
|
env: 'server-only'
|
|
56
57
|
},
|
|
57
58
|
hydrationCanBeAborted: {
|
|
58
|
-
env: 'client-only'
|
|
59
|
+
env: 'client-only'
|
|
59
60
|
},
|
|
60
61
|
prefetchStaticAssets: {
|
|
61
|
-
env: 'client-only'
|
|
62
|
+
env: 'client-only'
|
|
62
63
|
},
|
|
63
64
|
extends: {
|
|
64
65
|
env: 'config-only'
|
|
@@ -16,7 +16,7 @@ const globalContext_js_1 = require("../../../../runtime/globalContext.js");
|
|
|
16
16
|
const loggerNotProd_js_1 = require("../../../shared/loggerNotProd.js");
|
|
17
17
|
const removeSuperfluousViteLog_js_1 = require("../../../shared/loggerVite/removeSuperfluousViteLog.js");
|
|
18
18
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
19
|
-
const
|
|
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
22
|
(0, utils_js_1.assertIsNotProductionRuntime)();
|
|
@@ -334,7 +334,7 @@ function getGlobalConfigs(interfaceFilesByLocationId, userRootDir) {
|
|
|
334
334
|
(0, utils_js_1.assert)('value' in configValueSource);
|
|
335
335
|
if (configName === 'prerender' && typeof configValueSource.value === 'boolean')
|
|
336
336
|
return;
|
|
337
|
-
const { filePathToShowToUser } = configValueSource.
|
|
337
|
+
const { filePathToShowToUser } = configValueSource.definedAt;
|
|
338
338
|
(0, utils_js_1.assertWarning)(false, `Being able to define config ${picocolors_1.default.cyan(configName)} in ${filePathToShowToUser} is experimental and will likely be removed. Define the config ${picocolors_1.default.cyan(configName)} in Vike's Vite plugin options instead.`, { onlyOnce: true });
|
|
339
339
|
globalVikeConfig[configName] = configValueSource.value;
|
|
340
340
|
}
|
|
@@ -416,9 +416,14 @@ function makeOrderDeterministic(interfaceFile1, interfaceFile2) {
|
|
|
416
416
|
}
|
|
417
417
|
function warnOverridenConfigValues(interfaceFileWinner, interfaceFilesOverriden, configName, configDef, userRootDir) {
|
|
418
418
|
interfaceFilesOverriden.forEach((interfaceFileLoser) => {
|
|
419
|
+
const configValueSourceLoser_ = getConfigValueSource(configName, interfaceFileLoser, configDef, userRootDir);
|
|
419
420
|
const configValueSourceWinner = getConfigValueSource(configName, interfaceFileWinner, configDef, userRootDir);
|
|
420
|
-
|
|
421
|
-
(0,
|
|
421
|
+
// prettier-ignore
|
|
422
|
+
const configLoser_DefinedAt = (0, helpers_js_1.getConfigDefinedAtString)('Config', configName, configValueSourceLoser_);
|
|
423
|
+
// prettier-ignore
|
|
424
|
+
const configWinnerDefinedAt = (0, helpers_js_1.getConfigDefinedAtString)('config', configName, configValueSourceWinner);
|
|
425
|
+
const errMsg = `${configLoser_DefinedAt} is overriden by another ${configWinnerDefinedAt}, remove one of the two`;
|
|
426
|
+
(0, utils_js_1.assertWarning)(false, errMsg, { onlyOnce: false });
|
|
422
427
|
});
|
|
423
428
|
}
|
|
424
429
|
function isInterfaceFileUserLand(interfaceFile) {
|
|
@@ -433,20 +438,20 @@ function getConfigValueSource(configName, interfaceFile, configDef, userRootDir)
|
|
|
433
438
|
fileExportPathToShowToUser: ['default', configName]
|
|
434
439
|
};
|
|
435
440
|
if (configDef._valueIsFilePath) {
|
|
436
|
-
let
|
|
441
|
+
let definedAt;
|
|
437
442
|
let valueFilePath;
|
|
438
443
|
if (interfaceFile.isConfigFile) {
|
|
439
444
|
const { configValue } = conf;
|
|
440
445
|
const import_ = resolveImport(configValue, interfaceFile.filePath, userRootDir, configEnv, configName);
|
|
441
|
-
const configDefinedAt =
|
|
446
|
+
const configDefinedAt = (0, helpers_js_1.getConfigDefinedAtString)('Config', configName, { definedAt: definedAtConfigFile });
|
|
442
447
|
(0, utils_js_1.assertUsage)(import_, `${configDefinedAt} should be an import`);
|
|
443
448
|
valueFilePath = import_.filePathAbsoluteVite;
|
|
444
|
-
|
|
449
|
+
definedAt = import_;
|
|
445
450
|
}
|
|
446
451
|
else {
|
|
447
452
|
(0, utils_js_1.assert)(interfaceFile.isValueFile);
|
|
448
453
|
valueFilePath = interfaceFile.filePath.filePathAbsoluteVite;
|
|
449
|
-
|
|
454
|
+
definedAt = {
|
|
450
455
|
...interfaceFile.filePath,
|
|
451
456
|
fileExportPathToShowToUser: []
|
|
452
457
|
};
|
|
@@ -456,7 +461,7 @@ function getConfigValueSource(configName, interfaceFile, configDef, userRootDir)
|
|
|
456
461
|
valueIsFilePath: true,
|
|
457
462
|
configEnv,
|
|
458
463
|
valueIsImportedAtRuntime: true,
|
|
459
|
-
|
|
464
|
+
definedAt
|
|
460
465
|
};
|
|
461
466
|
return configValueSource;
|
|
462
467
|
}
|
|
@@ -468,7 +473,7 @@ function getConfigValueSource(configName, interfaceFile, configDef, userRootDir)
|
|
|
468
473
|
const configValueSource = {
|
|
469
474
|
configEnv,
|
|
470
475
|
valueIsImportedAtRuntime: true,
|
|
471
|
-
|
|
476
|
+
definedAt: import_
|
|
472
477
|
};
|
|
473
478
|
return configValueSource;
|
|
474
479
|
}
|
|
@@ -477,7 +482,7 @@ function getConfigValueSource(configName, interfaceFile, configDef, userRootDir)
|
|
|
477
482
|
value: configValue,
|
|
478
483
|
configEnv,
|
|
479
484
|
valueIsImportedAtRuntime: false,
|
|
480
|
-
|
|
485
|
+
definedAt: definedAtConfigFile
|
|
481
486
|
};
|
|
482
487
|
return configValueSource;
|
|
483
488
|
}
|
|
@@ -487,7 +492,7 @@ function getConfigValueSource(configName, interfaceFile, configDef, userRootDir)
|
|
|
487
492
|
const configValueSource = {
|
|
488
493
|
configEnv,
|
|
489
494
|
valueIsImportedAtRuntime: !valueAlreadyLoaded,
|
|
490
|
-
|
|
495
|
+
definedAt: {
|
|
491
496
|
...interfaceFile.filePath,
|
|
492
497
|
fileExportPathToShowToUser: configName === interfaceFile.configName
|
|
493
498
|
? []
|
|
@@ -620,9 +625,7 @@ function getConfigDefinitions(interfaceFilesRelevant) {
|
|
|
620
625
|
if (!configMeta)
|
|
621
626
|
return;
|
|
622
627
|
const meta = configMeta.configValue;
|
|
623
|
-
assertMetaValue(meta,
|
|
624
|
-
// TODO: Maybe we should use the getConfigDefinedAtString() helper?
|
|
625
|
-
`Config ${picocolors_1.default.cyan('meta')} defined at ${interfaceFile.filePath.filePathToShowToUser}`);
|
|
628
|
+
assertMetaValue(meta, `Config ${picocolors_1.default.cyan('meta')} defined at ${interfaceFile.filePath.filePathToShowToUser}`);
|
|
626
629
|
// Set configDef._userEffectDefinedAt
|
|
627
630
|
Object.entries(meta).forEach(([configName, configDef]) => {
|
|
628
631
|
if (!configDef.effect)
|
|
@@ -710,7 +713,7 @@ function applyEffectsAll(configValueSources, configDefinitionsRelevant) {
|
|
|
710
713
|
// Call effect
|
|
711
714
|
const configModFromEffect = configDef.effect({
|
|
712
715
|
configValue: source.value,
|
|
713
|
-
configDefinedAt:
|
|
716
|
+
configDefinedAt: (0, helpers_js_1.getConfigDefinedAtString)('Config', configName, source)
|
|
714
717
|
});
|
|
715
718
|
if (!configModFromEffect)
|
|
716
719
|
return;
|
|
@@ -724,8 +727,8 @@ function applyEffect(configModFromEffect, configValueSources, configDefEffect) {
|
|
|
724
727
|
if (configName === 'meta') {
|
|
725
728
|
let configDefinedAtString;
|
|
726
729
|
if (configDefEffect._userEffectDefinedAt) {
|
|
727
|
-
configDefinedAtString =
|
|
728
|
-
|
|
730
|
+
configDefinedAtString = (0, helpers_js_1.getConfigDefinedAtString)('Config', configName, {
|
|
731
|
+
definedAt: configDefEffect._userEffectDefinedAt
|
|
729
732
|
});
|
|
730
733
|
}
|
|
731
734
|
else {
|
|
@@ -749,7 +752,7 @@ function applyEffect(configModFromEffect, configValueSources, configDefEffect) {
|
|
|
749
752
|
else {
|
|
750
753
|
(0, utils_js_1.assertUsage)(false, notSupported);
|
|
751
754
|
// If we do end implementing being able to set the value of a config:
|
|
752
|
-
// - For setting
|
|
755
|
+
// - For setting definedAt: we could take the definedAt of the effect config while appending '(effect)' to definedAt.fileExportPathToShowToUser
|
|
753
756
|
}
|
|
754
757
|
});
|
|
755
758
|
}
|
|
@@ -879,8 +882,6 @@ async function loadExtendsConfigs(configFileExports, configFilePath, userRootDir
|
|
|
879
882
|
const extendsConfigFiles = [];
|
|
880
883
|
extendsImportData.map((importData) => {
|
|
881
884
|
const { importPath: importPath } = importData;
|
|
882
|
-
// TODO
|
|
883
|
-
// - validate extends configs
|
|
884
885
|
const filePathAbsoluteFilesystem = resolveImportPath(importData, configFilePath);
|
|
885
886
|
assertImportPath(filePathAbsoluteFilesystem, importData, configFilePath);
|
|
886
887
|
assertExtendsImportPath(importPath, filePathAbsoluteFilesystem, configFilePath);
|
|
@@ -1024,10 +1025,10 @@ function getFilesystemRoutingRootEffect(configFilesystemRoutingRoot, configName)
|
|
|
1024
1025
|
// Eagerly loaded since it's config-only
|
|
1025
1026
|
(0, utils_js_1.assert)('value' in configFilesystemRoutingRoot);
|
|
1026
1027
|
const { value } = configFilesystemRoutingRoot;
|
|
1027
|
-
const configDefinedAt =
|
|
1028
|
+
const configDefinedAt = (0, helpers_js_1.getConfigDefinedAtString)('Config', configName, configFilesystemRoutingRoot);
|
|
1028
1029
|
(0, utils_js_1.assertUsage)(typeof value === 'string', `${configDefinedAt} should be a string`);
|
|
1029
1030
|
(0, utils_js_1.assertUsage)(value.startsWith('/'), `${configDefinedAt} is ${picocolors_1.default.cyan(value)} but it should start with a leading slash ${picocolors_1.default.cyan('/')}`);
|
|
1030
|
-
const { filePathRelativeToUserRootDir } = configFilesystemRoutingRoot.
|
|
1031
|
+
const { filePathRelativeToUserRootDir } = configFilesystemRoutingRoot.definedAt;
|
|
1031
1032
|
(0, utils_js_1.assert)(filePathRelativeToUserRootDir);
|
|
1032
1033
|
const before = (0, filesystemRouting_js_1.getFilesystemRouteString)((0, filesystemRouting_js_1.getLocationId)(filePathRelativeToUserRootDir));
|
|
1033
1034
|
const after = value;
|
|
@@ -1092,7 +1093,6 @@ function getConfigValues(configValueSources, configValuesComputed, configDefinit
|
|
|
1092
1093
|
configValues[configName] = {
|
|
1093
1094
|
value,
|
|
1094
1095
|
definedAt: {
|
|
1095
|
-
isCumulative: true,
|
|
1096
1096
|
files: sources.map((source) => getDefinedAtFile(source))
|
|
1097
1097
|
}
|
|
1098
1098
|
};
|
|
@@ -1102,21 +1102,19 @@ function getConfigValues(configValueSources, configValuesComputed, configDefinit
|
|
|
1102
1102
|
}
|
|
1103
1103
|
function getDefinedAtFile(configValueSource) {
|
|
1104
1104
|
return {
|
|
1105
|
-
filePathToShowToUser: configValueSource.
|
|
1106
|
-
fileExportPathToShowToUser: configValueSource.
|
|
1105
|
+
filePathToShowToUser: configValueSource.definedAt.filePathToShowToUser,
|
|
1106
|
+
fileExportPathToShowToUser: configValueSource.definedAt.fileExportPathToShowToUser
|
|
1107
1107
|
};
|
|
1108
1108
|
}
|
|
1109
1109
|
function getDefinedAt(configValueSource) {
|
|
1110
|
-
return
|
|
1111
|
-
file: getDefinedAtFile(configValueSource)
|
|
1112
|
-
};
|
|
1110
|
+
return getDefinedAtFile(configValueSource);
|
|
1113
1111
|
}
|
|
1114
1112
|
function mergeCumulative(configName, configValueSources) {
|
|
1115
1113
|
const valuesArr = [];
|
|
1116
1114
|
const valuesSet = [];
|
|
1117
1115
|
let configValueSourcePrevious = null;
|
|
1118
1116
|
configValueSources.forEach((configValueSource) => {
|
|
1119
|
-
const configDefinedAt =
|
|
1117
|
+
const configDefinedAt = (0, helpers_js_1.getConfigDefinedAtString)('Config', configName, configValueSource);
|
|
1120
1118
|
const configNameColored = picocolors_1.default.cyan(configName);
|
|
1121
1119
|
// We could, in principle, also support cumulative values to be defined in +${configName}.js but it ins't completely trivial to implement
|
|
1122
1120
|
(0, utils_js_1.assertUsage)('value' in configValueSource, `${configDefinedAt} is only allowed to be defined in a +config.h.js file. (Because the values of ${configNameColored} are cumulative.)`);
|
|
@@ -1134,7 +1132,7 @@ function mergeCumulative(configName, configValueSources) {
|
|
|
1134
1132
|
if (vals2.length === 0)
|
|
1135
1133
|
return;
|
|
1136
1134
|
(0, utils_js_1.assert)(configValueSourcePrevious);
|
|
1137
|
-
const configPreviousDefinedAt =
|
|
1135
|
+
const configPreviousDefinedAt = (0, helpers_js_1.getConfigDefinedAtString)('Config', configName, configValueSourcePrevious);
|
|
1138
1136
|
(0, utils_js_1.assertUsage)(false, `${configDefinedAt} sets ${t1} but another ${configPreviousDefinedAt} sets ${t2} which is forbidden: the values must be all arrays or all sets (you cannot mix).`);
|
|
1139
1137
|
};
|
|
1140
1138
|
const { value } = configValueSource;
|
|
@@ -1165,14 +1163,3 @@ function mergeCumulative(configName, configValueSources) {
|
|
|
1165
1163
|
}
|
|
1166
1164
|
(0, utils_js_1.assert)(false);
|
|
1167
1165
|
}
|
|
1168
|
-
// TODO: rename and/or refactor
|
|
1169
|
-
function getConfigSourceDefinedAtString(configName, { definedAtInfo }, sentenceBegin = true) {
|
|
1170
|
-
return (0, utils_js_2.getConfigDefinedAtString)(configName, {
|
|
1171
|
-
definedAt: {
|
|
1172
|
-
file: {
|
|
1173
|
-
filePathToShowToUser: definedAtInfo.filePathToShowToUser,
|
|
1174
|
-
fileExportPathToShowToUser: definedAtInfo.fileExportPathToShowToUser
|
|
1175
|
-
}
|
|
1176
|
-
}
|
|
1177
|
-
}, sentenceBegin);
|
|
1178
|
-
}
|
package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js
CHANGED
|
@@ -6,7 +6,7 @@ const virtualFilePageConfigValuesAll_js_1 = require("../../../../shared/virtual-
|
|
|
6
6
|
const getVikeConfig_js_1 = require("./getVikeConfig.js");
|
|
7
7
|
const extractAssetsQuery_js_1 = require("../../../../shared/extractAssetsQuery.js");
|
|
8
8
|
const debug_js_1 = require("./debug.js");
|
|
9
|
-
const
|
|
9
|
+
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");
|
|
@@ -29,7 +29,7 @@ async function getVirtualFilePageConfigValuesAll(id, userRootDir, outDirRoot, is
|
|
|
29
29
|
}
|
|
30
30
|
exports.getVirtualFilePageConfigValuesAll = getVirtualFilePageConfigValuesAll;
|
|
31
31
|
function getLoadConfigValuesAll(pageConfig, isForClientSide, pageId, includeAssetsImportedByServer, isDev) {
|
|
32
|
-
const configValue = (0,
|
|
32
|
+
const configValue = (0, helpers_js_1.getConfigValue)(pageConfig, 'clientRouting', 'boolean');
|
|
33
33
|
const isClientRouting = configValue?.value ?? false;
|
|
34
34
|
const lines = [];
|
|
35
35
|
const importStatements = [];
|
|
@@ -12,7 +12,7 @@ const helpers_js_1 = require("./helpers.js");
|
|
|
12
12
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
13
13
|
const getVikeConfig_js_1 = require("./getVikeConfig.js");
|
|
14
14
|
const isRuntimeEnvMatch_js_1 = require("./isRuntimeEnvMatch.js");
|
|
15
|
-
const
|
|
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
17
|
async function getVirtualFilePageConfigs(userRootDir, outDirRoot, isForClientSide, isDev, id, configVike, isClientRouting) {
|
|
18
18
|
const { pageConfigs, pageConfigGlobal } = await (0, getVikeConfig_js_1.getVikeConfig)(userRootDir, outDirRoot, isDev, configVike.extensions, true);
|
|
@@ -110,15 +110,24 @@ function getConfigValueSerialized(value, configName, definedAt) {
|
|
|
110
110
|
const valueName = `config${(0, utils_js_1.getPropAccessNotation)(configName)}`;
|
|
111
111
|
let configValueSerialized;
|
|
112
112
|
try {
|
|
113
|
-
configValueSerialized = (0, stringify_1.stringify)(value, { valueName });
|
|
113
|
+
configValueSerialized = (0, stringify_1.stringify)(value, { valueName, forbidReactElements: true });
|
|
114
114
|
}
|
|
115
115
|
catch (err) {
|
|
116
|
-
|
|
117
|
-
|
|
116
|
+
let serializationErrMsg = '';
|
|
117
|
+
if ((0, stringify_1.isJsonSerializerError)(err)) {
|
|
118
|
+
serializationErrMsg = err.messageCore;
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
// When a property getter throws an error
|
|
122
|
+
console.error('Serialization error:');
|
|
123
|
+
console.error(err);
|
|
124
|
+
serializationErrMsg = 'see serialization error printed above';
|
|
125
|
+
}
|
|
126
|
+
const configValueFilePathToShowToUser = (0, helpers_js_2.getConfigValueFilePathToShowToUser)({ definedAt });
|
|
118
127
|
(0, utils_js_1.assert)(configValueFilePathToShowToUser);
|
|
119
128
|
(0, utils_js_1.assertUsage)(false, [
|
|
120
129
|
`The value of the config ${picocolors_1.default.cyan(configName)} cannot be defined inside the file ${configValueFilePathToShowToUser}:`,
|
|
121
|
-
`its value must be defined in an another file and then imported by ${configValueFilePathToShowToUser}. (Because
|
|
130
|
+
`its value must be defined in an another file and then imported by ${configValueFilePathToShowToUser}. (Because its value isn't serializable: ${serializationErrMsg}.)`,
|
|
122
131
|
`Only serializable config values can be defined inside +config.h.js files, see https://vike.dev/header-file.`
|
|
123
132
|
].join(' '));
|
|
124
133
|
}
|
|
@@ -7,20 +7,7 @@ function getConfigEnv(configValueSources, configName) {
|
|
|
7
7
|
const configValueSource = getConfigValueSource(configValueSources, configName);
|
|
8
8
|
if (!configValueSource)
|
|
9
9
|
return null;
|
|
10
|
-
|
|
11
|
-
return configValueSource.configEnv;
|
|
12
|
-
}
|
|
13
|
-
else {
|
|
14
|
-
// In case of effect/computed config values, there isn't any configValueSource
|
|
15
|
-
// TODO: make it work for custom config definitions
|
|
16
|
-
// - Ideally set configValueSource also for effect/computed config values?
|
|
17
|
-
(0, utils_js_1.assert)(false, 'TODO');
|
|
18
|
-
/*
|
|
19
|
-
const configDef = configDefinitionsBuiltIn[configName as keyof typeof configDefinitionsBuiltIn]
|
|
20
|
-
if (!configDef) return null
|
|
21
|
-
return configDef.env
|
|
22
|
-
*/
|
|
23
|
-
}
|
|
10
|
+
return configValueSource.configEnv;
|
|
24
11
|
}
|
|
25
12
|
exports.getConfigEnv = getConfigEnv;
|
|
26
13
|
function isConfigSet(configValueSources, configName) {
|
|
@@ -18,6 +18,7 @@ function previewConfig() {
|
|
|
18
18
|
apply: 'serve',
|
|
19
19
|
config(config) {
|
|
20
20
|
return {
|
|
21
|
+
appType: 'custom',
|
|
21
22
|
build: {
|
|
22
23
|
outDir: (0, utils_js_1.resolveOutDir)(config)
|
|
23
24
|
}
|
|
@@ -28,12 +29,20 @@ function previewConfig() {
|
|
|
28
29
|
configVike = await (0, getConfigVike_js_1.getConfigVike)(config);
|
|
29
30
|
},
|
|
30
31
|
configurePreviewServer(server) {
|
|
32
|
+
/* - Couldn't make `appType: 'mpa'` work as of npm:@brillout/vite@5.0.0-beta.14.0426910c
|
|
33
|
+
- This ugly hack to set appType for preview won't be need once https://github.com/vitejs/vite/pull/14855 is merged.
|
|
34
|
+
config.appType = 'mpa'
|
|
35
|
+
*/
|
|
31
36
|
(0, utils_js_1.markEnvAsPreview)();
|
|
32
37
|
return () => {
|
|
33
38
|
assertDist();
|
|
34
|
-
|
|
35
|
-
|
|
39
|
+
/* We don't use this condition (we wrongfully always use the SSR middleware) because of the regression introduced by https://github.com/vitejs/vite/pull/14756 which stops servering .html files when `appType: 'custom'`.
|
|
40
|
+
if (!configVike.prerender || configVike.prerender.partial) {
|
|
41
|
+
addSsrMiddleware(server.middlewares)
|
|
36
42
|
}
|
|
43
|
+
/*/
|
|
44
|
+
(0, addSsrMiddleware_js_1.addSsrMiddleware)(server.middlewares);
|
|
45
|
+
//*/
|
|
37
46
|
addStatic404Middleware(server.middlewares);
|
|
38
47
|
};
|
|
39
48
|
}
|
|
@@ -41,7 +41,7 @@ const getConfigVike_js_1 = require("../shared/getConfigVike.js");
|
|
|
41
41
|
const getPageFiles_js_1 = require("../../shared/getPageFiles.js");
|
|
42
42
|
const getPageContextRequestUrl_js_1 = require("../../shared/getPageContextRequestUrl.js");
|
|
43
43
|
const resolveRouteString_js_1 = require("../../shared/route/resolveRouteString.js");
|
|
44
|
-
const
|
|
44
|
+
const helpers_js_1 = require("../../shared/page-configs/helpers.js");
|
|
45
45
|
const loadConfigValues_js_1 = require("../../shared/page-configs/loadConfigValues.js");
|
|
46
46
|
const error_page_js_1 = require("../../shared/error-page.js");
|
|
47
47
|
const addUrlComputedProps_js_1 = require("../../shared/addUrlComputedProps.js");
|
|
@@ -113,9 +113,9 @@ async function runPrerender(options, manuallyTriggered) {
|
|
|
113
113
|
async function collectDoNoPrerenderList(renderContext, doNotPrerenderList, concurrencyLimit) {
|
|
114
114
|
renderContext.pageConfigs.forEach((pageConfig) => {
|
|
115
115
|
const configName = 'prerender';
|
|
116
|
-
const configValue = (0,
|
|
116
|
+
const configValue = (0, helpers_js_1.getConfigValue)(pageConfig, configName, 'boolean');
|
|
117
117
|
if (configValue?.value === false) {
|
|
118
|
-
const configValueFilePathToShowToUser = (0,
|
|
118
|
+
const configValueFilePathToShowToUser = (0, helpers_js_1.getConfigValueFilePathToShowToUser)(configValue);
|
|
119
119
|
(0, utils_js_1.assert)(configValueFilePathToShowToUser);
|
|
120
120
|
doNotPrerenderList.push({
|
|
121
121
|
pageId: pageConfig.pageId,
|
|
@@ -173,11 +173,11 @@ async function callOnBeforePrerenderStartHooks(prerenderContext, renderContext,
|
|
|
173
173
|
await Promise.all(renderContext.pageConfigs.map((pageConfig) => concurrencyLimit(async () => {
|
|
174
174
|
const hookName = 'onBeforePrerenderStart';
|
|
175
175
|
const pageConfigLoaded = await (0, loadConfigValues_js_1.loadConfigValues)(pageConfig, false);
|
|
176
|
-
const configValue = (0,
|
|
176
|
+
const configValue = (0, helpers_js_1.getConfigValue)(pageConfigLoaded, hookName);
|
|
177
177
|
if (!configValue)
|
|
178
178
|
return;
|
|
179
179
|
const hookFn = configValue.value;
|
|
180
|
-
const hookFilePath = (0,
|
|
180
|
+
const hookFilePath = (0, helpers_js_1.getHookFilePathToShowToUser)(configValue);
|
|
181
181
|
(0, utils_js_1.assert)(hookFilePath);
|
|
182
182
|
(0, getHook_js_1.assertHookFn)(hookFn, { hookName, hookFilePath });
|
|
183
183
|
onBeforePrerenderStartHooks.push({
|
|
@@ -313,8 +313,8 @@ async function callOnPrerenderStartHook(prerenderContext, renderContext) {
|
|
|
313
313
|
const configValue = pageConfigGlobal.configValues.onPrerenderStart;
|
|
314
314
|
if (configValue?.value) {
|
|
315
315
|
const { value: hookFn } = configValue;
|
|
316
|
-
// config.onPrerenderStart isn't a computed nor a cumulative config =>
|
|
317
|
-
const hookFilePath = (0,
|
|
316
|
+
// config.onPrerenderStart isn't a computed nor a cumulative config => definedAt should always be defined
|
|
317
|
+
const hookFilePath = (0, helpers_js_1.getHookFilePathToShowToUser)(configValue);
|
|
318
318
|
(0, utils_js_1.assert)(hookFilePath);
|
|
319
319
|
onPrerenderStartHook = {
|
|
320
320
|
hookFn,
|
|
@@ -371,7 +371,7 @@ async function callOnPrerenderStartHook(prerenderContext, renderContext) {
|
|
|
371
371
|
enumerable: false,
|
|
372
372
|
configurable: true
|
|
373
373
|
});
|
|
374
|
-
(0, utils_js_1.assert)((0, utils_js_1.
|
|
374
|
+
(0, utils_js_1.assert)((0, utils_js_1.isPropertyGetter)(pageContext, 'url'));
|
|
375
375
|
(0, utils_js_1.assert)(pageContext.urlOriginal);
|
|
376
376
|
pageContext._urlOriginalBeforeHook = pageContext.urlOriginal;
|
|
377
377
|
});
|
|
@@ -410,7 +410,7 @@ async function callOnPrerenderStartHook(prerenderContext, renderContext) {
|
|
|
410
410
|
prerenderContext.pageContexts = result.prerenderContext.pageContexts;
|
|
411
411
|
prerenderContext.pageContexts.forEach((pageContext) => {
|
|
412
412
|
// TODO/v1-release: remove
|
|
413
|
-
if (!(0, utils_js_1.
|
|
413
|
+
if (pageContext.url && !(0, utils_js_1.isPropertyGetter)(pageContext, 'url')) {
|
|
414
414
|
(0, utils_js_1.assertWarning)(false, msgPrefix +
|
|
415
415
|
' provided pageContext.url but it should provide pageContext.urlOriginal instead, see https://vike.dev/migration/0.4.23', { onlyOnce: true });
|
|
416
416
|
pageContext.urlOriginal = pageContext.url;
|
|
@@ -435,10 +435,9 @@ async function routeAndPrerender(prerenderContext, htmlFiles, prerenderPageIds,
|
|
|
435
435
|
await Promise.all(prerenderContext.pageContexts.map((pageContext) => concurrencyLimit(async () => {
|
|
436
436
|
const { urlOriginal } = pageContext;
|
|
437
437
|
(0, utils_js_1.assert)(urlOriginal);
|
|
438
|
-
const
|
|
439
|
-
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(
|
|
440
|
-
|
|
441
|
-
if (routeResult.pageContextAddendum._pageId === null) {
|
|
438
|
+
const pageContextFromRoute = await (0, index_js_1.route)(pageContext);
|
|
439
|
+
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(pageContextFromRoute, '_pageId', 'null') || (0, utils_js_1.hasProp)(pageContextFromRoute, '_pageId', 'string'));
|
|
440
|
+
if (pageContextFromRoute._pageId === null) {
|
|
442
441
|
let hookName;
|
|
443
442
|
let hookFilePath;
|
|
444
443
|
if (pageContext._providedByHook) {
|
|
@@ -455,13 +454,13 @@ async function routeAndPrerender(prerenderContext, htmlFiles, prerenderPageIds,
|
|
|
455
454
|
}
|
|
456
455
|
else {
|
|
457
456
|
// `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.
|
|
458
|
-
(0, utils_js_1.assert)(
|
|
457
|
+
(0, utils_js_1.assert)(pageContextFromRoute._routingProvidedByOnBeforeRouteHook);
|
|
459
458
|
// Abort since the URL doesn't correspond to any page
|
|
460
459
|
return;
|
|
461
460
|
}
|
|
462
461
|
}
|
|
463
|
-
(0, utils_js_1.assert)(
|
|
464
|
-
(0, utils_js_1.objectAssign)(pageContext,
|
|
462
|
+
(0, utils_js_1.assert)(pageContextFromRoute._pageId);
|
|
463
|
+
(0, utils_js_1.objectAssign)(pageContext, pageContextFromRoute);
|
|
465
464
|
const { _pageId: pageId } = pageContext;
|
|
466
465
|
(0, utils_js_1.objectAssign)(pageContext, await (0, loadPageFilesServerSide_js_1.loadPageFilesServerSide)(pageContext));
|
|
467
466
|
let usesClientRouter;
|
|
@@ -469,7 +468,7 @@ async function routeAndPrerender(prerenderContext, htmlFiles, prerenderPageIds,
|
|
|
469
468
|
if (pageContext._pageConfigs.length > 0) {
|
|
470
469
|
const pageConfig = pageContext._pageConfigs.find((p) => p.pageId === pageId);
|
|
471
470
|
(0, utils_js_1.assert)(pageConfig);
|
|
472
|
-
usesClientRouter = (0,
|
|
471
|
+
usesClientRouter = (0, helpers_js_1.getConfigValue)(pageConfig, 'clientRouting', 'boolean')?.value ?? false;
|
|
473
472
|
}
|
|
474
473
|
else {
|
|
475
474
|
usesClientRouter = globalContext.pluginManifest.usesClientRouter;
|
|
@@ -23,7 +23,7 @@ __exportStar(require("../../utils/objectAssign.js"), exports);
|
|
|
23
23
|
__exportStar(require("../../utils/isObjectWithKeys.js"), exports);
|
|
24
24
|
__exportStar(require("../../utils/isCallable.js"), exports);
|
|
25
25
|
__exportStar(require("../../utils/getOutDirs.js"), exports);
|
|
26
|
-
__exportStar(require("../../utils/
|
|
26
|
+
__exportStar(require("../../utils/isPropertyGetter.js"), exports);
|
|
27
27
|
__exportStar(require("../../utils/filesystemPathHandling.js"), exports);
|
|
28
28
|
__exportStar(require("../../utils/urlToFile.js"), exports);
|
|
29
29
|
__exportStar(require("../../shared/hooks/executeHook.js"), exports);
|
|
@@ -50,19 +50,33 @@ function serializePageContextClientSide(pageContext) {
|
|
|
50
50
|
catch (err) {
|
|
51
51
|
hasWarned = true;
|
|
52
52
|
propsNonSerializable.push(prop);
|
|
53
|
-
|
|
54
|
-
(0, utils_js_1.assertWarning)(false, [
|
|
53
|
+
let msg = [
|
|
55
54
|
`${varName} cannot be serialized and, therefore, cannot be passed to the client.`,
|
|
56
|
-
`Make sure that ${varName} is serializable, or remove ${h(propName)} from ${h('passToClient')}
|
|
57
|
-
|
|
58
|
-
|
|
55
|
+
`Make sure that ${varName} is serializable, or remove ${h(propName)} from ${h('passToClient')}.`
|
|
56
|
+
].join(' ');
|
|
57
|
+
if ((0, stringify_1.isJsonSerializerError)(err)) {
|
|
58
|
+
msg = `${msg} Serialization error: ${err.messageCore}.`;
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
// When a property getter throws an error
|
|
62
|
+
console.warn('Serialization error:');
|
|
63
|
+
console.warn(err);
|
|
64
|
+
msg = `${msg} The serialization failed because of the error printed above.`;
|
|
65
|
+
}
|
|
66
|
+
// We warn (instead of throwing an error) since Vike's client runtime throws an error (with `assertUsage()`) if the user's client code tries to access the property that cannot be serialized
|
|
67
|
+
(0, utils_js_1.assertWarning)(false, msg, { onlyOnce: false });
|
|
59
68
|
}
|
|
60
69
|
});
|
|
61
70
|
(0, utils_js_1.assert)(hasWarned);
|
|
62
71
|
propsNonSerializable.forEach((prop) => {
|
|
63
72
|
pageContextClient[prop] = notSerializable_js_1.notSerializable;
|
|
64
73
|
});
|
|
65
|
-
|
|
74
|
+
try {
|
|
75
|
+
pageContextSerialized = serialize(pageContextClient);
|
|
76
|
+
}
|
|
77
|
+
catch (err) {
|
|
78
|
+
(0, utils_js_1.assert)(false);
|
|
79
|
+
}
|
|
66
80
|
}
|
|
67
81
|
return pageContextSerialized;
|
|
68
82
|
}
|
|
@@ -21,7 +21,7 @@ const preparePageContextForUserConsumptionServerSide_js_1 = require("./preparePa
|
|
|
21
21
|
const executeGuardHook_js_1 = require("../../../shared/route/executeGuardHook.js");
|
|
22
22
|
const loadPageRoutes_js_1 = require("../../../shared/route/loadPageRoutes.js");
|
|
23
23
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
24
|
-
const
|
|
24
|
+
const helpers_js_1 = require("../../../shared/page-configs/helpers.js");
|
|
25
25
|
async function renderPageAlreadyRouted(pageContext) {
|
|
26
26
|
// pageContext._pageId can either be the:
|
|
27
27
|
// - ID of the page matching the routing, or the
|
|
@@ -173,7 +173,7 @@ function assertNonMixedDesign(pageFilesAll, pageConfigs) {
|
|
|
173
173
|
const indent = '- ';
|
|
174
174
|
const v1Files = (0, utils_js_1.unique)(pageConfigs
|
|
175
175
|
.map((p) => Object.values(p.configValues)
|
|
176
|
-
.map(
|
|
176
|
+
.map(helpers_js_1.getConfigValueFilePathToShowToUser)
|
|
177
177
|
.filter(utils_js_1.isNotNullish)
|
|
178
178
|
.map((filePathToShowToUser) => indent + filePathToShowToUser))
|
|
179
179
|
.flat(2));
|
|
@@ -246,8 +246,8 @@ async function renderPageNominal(pageContext) {
|
|
|
246
246
|
}
|
|
247
247
|
// Route
|
|
248
248
|
{
|
|
249
|
-
const
|
|
250
|
-
(0, utils_js_1.objectAssign)(pageContext,
|
|
249
|
+
const pageContextFromRoute = await (0, index_js_1.route)(pageContext);
|
|
250
|
+
(0, utils_js_1.objectAssign)(pageContext, pageContextFromRoute);
|
|
251
251
|
(0, utils_js_1.objectAssign)(pageContext, { is404: pageContext._pageId ? null : true });
|
|
252
252
|
if (pageContext._pageId === null) {
|
|
253
253
|
const errorPageId = (0, error_page_js_1.getErrorPageId)(pageContext._pageFilesAll, pageContext._pageConfigs);
|
|
@@ -44,7 +44,7 @@ __exportStar(require("../../utils/capitalizeFirstLetter.js"), exports);
|
|
|
44
44
|
__exportStar(require("../../utils/debugGlob.js"), exports);
|
|
45
45
|
__exportStar(require("../../utils/isEquivalentError.js"), exports);
|
|
46
46
|
__exportStar(require("../../utils/styleFileRE.js"), exports);
|
|
47
|
-
__exportStar(require("../../utils/
|
|
47
|
+
__exportStar(require("../../utils/isPropertyGetter.js"), exports);
|
|
48
48
|
__exportStar(require("../../utils/debug.js"), exports);
|
|
49
49
|
__exportStar(require("../../utils/urlToFile.js"), exports);
|
|
50
50
|
__exportStar(require("../../utils/getGlobalObject.js"), exports);
|