vike 0.4.171-commit-75e1588 → 0.4.171-commit-6e37128

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.
Files changed (116) hide show
  1. package/dist/cjs/node/plugin/plugins/buildConfig.js +3 -4
  2. package/dist/cjs/node/plugin/plugins/devConfig/determineOptimizeDeps.js +18 -15
  3. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +3 -3
  4. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +30 -74
  5. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js +4 -42
  6. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigs.js +9 -49
  7. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/isRuntimeEnvMatch.js +6 -0
  8. package/dist/cjs/node/prerender/runPrerender.js +33 -13
  9. package/dist/cjs/node/prerender/utils.js +1 -0
  10. package/dist/cjs/node/runtime/renderPage/analyzePage.js +9 -7
  11. package/dist/cjs/node/runtime/renderPage/createHttpResponseObject/getCacheControl.js +1 -1
  12. package/dist/cjs/node/runtime/renderPage/executeOnRenderHtmlHook.js +7 -7
  13. package/dist/cjs/node/runtime/renderPage/loadUserFilesServerSide.js +4 -5
  14. package/dist/cjs/node/runtime/renderPage/preparePageContextForUserConsumptionServerSide.js +2 -2
  15. package/dist/cjs/node/runtime/renderPage/renderPageAlreadyRouted.js +6 -5
  16. package/dist/cjs/node/shared/assertV1Design.js +3 -4
  17. package/dist/cjs/shared/{addUrlComputedProps.js → getPageContextUrlComputed.js} +52 -42
  18. package/dist/cjs/shared/getPageFiles/analyzeClientSide.js +2 -2
  19. package/dist/cjs/shared/hooks/getHook.js +2 -2
  20. package/dist/cjs/shared/page-configs/getConfigValue.js +14 -17
  21. package/dist/cjs/shared/page-configs/getConfigValueBuildTime.js +70 -0
  22. package/dist/cjs/shared/page-configs/loadConfigValues.js +3 -12
  23. package/dist/cjs/shared/page-configs/serialize/assertPageConfigsSerialized.js +1 -2
  24. package/dist/cjs/shared/page-configs/serialize/parsePageConfigs.js +110 -16
  25. package/dist/cjs/shared/page-configs/serialize/serializeConfigValues.js +198 -0
  26. package/dist/cjs/shared/route/index.js +2 -2
  27. package/dist/cjs/shared/route/loadPageRoutes.js +2 -2
  28. package/dist/cjs/shared/route/resolveRouteFunction.js +2 -2
  29. package/dist/cjs/shared/utils.js +2 -0
  30. package/dist/cjs/utils/changeEnumerable.js +9 -0
  31. package/dist/cjs/utils/hasProp.js +5 -7
  32. package/dist/cjs/utils/objectAssign.js +1 -1
  33. package/dist/cjs/utils/objectDefineProperty.js +8 -0
  34. package/dist/cjs/utils/projectInfo.js +1 -1
  35. package/dist/esm/client/client-routing-runtime/createPageContext.d.ts +6 -4
  36. package/dist/esm/client/client-routing-runtime/createPageContext.js +4 -3
  37. package/dist/esm/client/client-routing-runtime/getPageContextFromHooks.js +14 -10
  38. package/dist/esm/client/server-routing-runtime/getPageContext.d.ts +4 -4
  39. package/dist/esm/client/shared/loadUserFilesClientSide.js +4 -4
  40. package/dist/esm/node/plugin/plugins/buildConfig.js +3 -4
  41. package/dist/esm/node/plugin/plugins/devConfig/determineOptimizeDeps.js +18 -15
  42. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.d.ts +2 -1
  43. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +3 -3
  44. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +30 -74
  45. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js +4 -42
  46. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigs.js +9 -49
  47. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/isRuntimeEnvMatch.d.ts +1 -0
  48. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/isRuntimeEnvMatch.js +6 -0
  49. package/dist/esm/node/prerender/runPrerender.js +35 -15
  50. package/dist/esm/node/prerender/utils.d.ts +1 -0
  51. package/dist/esm/node/prerender/utils.js +1 -0
  52. package/dist/esm/node/runtime/renderPage/analyzePage.js +9 -7
  53. package/dist/esm/node/runtime/renderPage/createHttpResponseObject/getCacheControl.js +2 -2
  54. package/dist/esm/node/runtime/renderPage/executeOnRenderHtmlHook.js +7 -7
  55. package/dist/esm/node/runtime/renderPage/loadUserFilesServerSide.d.ts +1 -9
  56. package/dist/esm/node/runtime/renderPage/loadUserFilesServerSide.js +4 -5
  57. package/dist/esm/node/runtime/renderPage/preparePageContextForUserConsumptionServerSide.d.ts +2 -2
  58. package/dist/esm/node/runtime/renderPage/preparePageContextForUserConsumptionServerSide.js +2 -2
  59. package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.d.ts +27 -50
  60. package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.js +6 -5
  61. package/dist/esm/node/shared/assertV1Design.d.ts +2 -2
  62. package/dist/esm/node/shared/assertV1Design.js +3 -4
  63. package/dist/esm/shared/{addUrlComputedProps.d.ts → getPageContextUrlComputed.d.ts} +23 -21
  64. package/dist/esm/shared/{addUrlComputedProps.js → getPageContextUrlComputed.js} +52 -42
  65. package/dist/esm/shared/getPageFiles/analyzeClientSide.js +3 -3
  66. package/dist/esm/shared/hooks/getHook.d.ts +2 -2
  67. package/dist/esm/shared/hooks/getHook.js +3 -3
  68. package/dist/esm/shared/page-configs/PageConfig.d.ts +10 -4
  69. package/dist/esm/shared/page-configs/getConfigValue.d.ts +12 -12
  70. package/dist/esm/shared/page-configs/getConfigValue.js +13 -16
  71. package/dist/esm/shared/page-configs/getConfigValueBuildTime.d.ts +9 -0
  72. package/dist/esm/shared/page-configs/getConfigValueBuildTime.js +67 -0
  73. package/dist/esm/shared/page-configs/loadConfigValues.js +3 -12
  74. package/dist/esm/shared/page-configs/serialize/PageConfigSerialized.d.ts +15 -19
  75. package/dist/esm/shared/page-configs/serialize/assertPageConfigsSerialized.js +1 -2
  76. package/dist/esm/shared/page-configs/serialize/parsePageConfigs.d.ts +4 -1
  77. package/dist/esm/shared/page-configs/serialize/parsePageConfigs.js +109 -15
  78. package/dist/esm/shared/page-configs/serialize/serializeConfigValues.d.ts +5 -0
  79. package/dist/esm/shared/page-configs/serialize/serializeConfigValues.js +192 -0
  80. package/dist/esm/shared/route/index.d.ts +3 -3
  81. package/dist/esm/shared/route/index.js +2 -2
  82. package/dist/esm/shared/route/loadPageRoutes.js +3 -3
  83. package/dist/esm/shared/route/resolveRouteFunction.d.ts +2 -2
  84. package/dist/esm/shared/route/resolveRouteFunction.js +2 -2
  85. package/dist/esm/shared/types.d.ts +4 -4
  86. package/dist/esm/shared/utils.d.ts +2 -0
  87. package/dist/esm/shared/utils.js +2 -0
  88. package/dist/esm/types/index.d.ts +1 -1
  89. package/dist/esm/utils/changeEnumerable.d.ts +2 -0
  90. package/dist/esm/utils/changeEnumerable.js +5 -0
  91. package/dist/esm/utils/hasProp.d.ts +4 -13
  92. package/dist/esm/utils/hasProp.js +5 -7
  93. package/dist/esm/utils/objectAssign.js +1 -1
  94. package/dist/esm/utils/objectDefineProperty.d.ts +4 -0
  95. package/dist/esm/utils/objectDefineProperty.js +4 -0
  96. package/dist/esm/utils/projectInfo.d.ts +2 -2
  97. package/dist/esm/utils/projectInfo.js +1 -1
  98. package/package.json +2 -2
  99. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getConfigValuesSerialized.js +0 -101
  100. package/dist/cjs/node/plugin/shared/getConfigValueSourcesNotOverriden.js +0 -14
  101. package/dist/cjs/node/shared/getClientEntry.js +0 -12
  102. package/dist/cjs/shared/page-configs/serialize/parseConfigValuesImported.js +0 -85
  103. package/dist/cjs/shared/page-configs/serialize/parseConfigValuesSerialized.js +0 -24
  104. package/dist/cjs/shared/page-configs/serialize/serializeConfigValue.js +0 -49
  105. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getConfigValuesSerialized.d.ts +0 -5
  106. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getConfigValuesSerialized.js +0 -95
  107. package/dist/esm/node/plugin/shared/getConfigValueSourcesNotOverriden.d.ts +0 -5
  108. package/dist/esm/node/plugin/shared/getConfigValueSourcesNotOverriden.js +0 -11
  109. package/dist/esm/node/shared/getClientEntry.d.ts +0 -3
  110. package/dist/esm/node/shared/getClientEntry.js +0 -9
  111. package/dist/esm/shared/page-configs/serialize/parseConfigValuesImported.d.ts +0 -4
  112. package/dist/esm/shared/page-configs/serialize/parseConfigValuesImported.js +0 -82
  113. package/dist/esm/shared/page-configs/serialize/parseConfigValuesSerialized.d.ts +0 -4
  114. package/dist/esm/shared/page-configs/serialize/parseConfigValuesSerialized.js +0 -21
  115. package/dist/esm/shared/page-configs/serialize/serializeConfigValue.d.ts +0 -6
  116. package/dist/esm/shared/page-configs/serialize/serializeConfigValue.js +0 -46
@@ -1,85 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parseConfigValuesImported = void 0;
4
- const utils_js_1 = require("../../utils.js");
5
- const assertPlusFileExport_js_1 = require("../assertPlusFileExport.js");
6
- function parseConfigValuesImported(configValuesImported) {
7
- const configValuesUnmerged = {};
8
- configValuesImported
9
- .filter((c) => c.configName !== 'client')
10
- .forEach((configValueLoaded) => {
11
- if (configValueLoaded.isValueFile) {
12
- const { exportValues, importPath, configName } = configValueLoaded;
13
- (0, assertPlusFileExport_js_1.assertPlusFileExport)(exportValues, importPath, configName);
14
- Object.entries(exportValues).forEach(([exportName, exportValue]) => {
15
- const isSideExport = exportName !== 'default'; // .md files may have "side-exports" such as `export { frontmatter }`
16
- const configName = isSideExport ? exportName : configValueLoaded.configName;
17
- configValuesUnmerged[configName] ?? (configValuesUnmerged[configName] = []);
18
- configValuesUnmerged[configName].push({
19
- value: exportValue,
20
- importPath,
21
- exportName,
22
- isSideExport
23
- });
24
- });
25
- }
26
- else {
27
- const { configName, importPath, exportValue, exportName } = configValueLoaded;
28
- configValuesUnmerged[configName] ?? (configValuesUnmerged[configName] = []);
29
- configValuesUnmerged[configName].push({
30
- value: exportValue,
31
- importPath,
32
- exportName,
33
- isSideExport: false
34
- });
35
- }
36
- });
37
- const configValues = {};
38
- Object.entries(configValuesUnmerged).forEach(([configName, values]) => {
39
- const valuesWithoutSideExports = values.filter((v) => !v.isSideExport);
40
- const isCumulative = valuesWithoutSideExports.length > 1;
41
- const noSideExports = valuesWithoutSideExports.length === values.length;
42
- if (isCumulative) {
43
- // Vike currently doesn't support side exports for cumulative configs
44
- (0, utils_js_1.assert)(noSideExports);
45
- // TODO: implement
46
- (0, utils_js_1.assert)(false);
47
- }
48
- else {
49
- const val = valuesWithoutSideExports[0] ??
50
- // We can't avoid side-export conflicts upstream. (We cannot know about side-exports at build-time.)
51
- // Side-exports have lower precedence.
52
- values[0];
53
- (0, utils_js_1.assert)(val);
54
- const { value, importPath, exportName } = val;
55
- configValues[configName] = {
56
- type: 'standard',
57
- value,
58
- definedAtData: {
59
- // importPath cannot be relative to the current file, since the current file is a virtual file
60
- filePathToShowToUser: importPath,
61
- fileExportPathToShowToUser: [configName, 'default'].includes(exportName)
62
- ? []
63
- : [
64
- // Side-export
65
- exportName
66
- ]
67
- }
68
- };
69
- assertIsNotNull(value, configName, importPath);
70
- }
71
- });
72
- return configValues;
73
- }
74
- exports.parseConfigValuesImported = parseConfigValuesImported;
75
- function assertIsNotNull(configValue, configName, importPath) {
76
- (0, utils_js_1.assert)(!importPath.includes('+config.'));
77
- /* Re-use this for:
78
- * - upcoming config.requestPageContextOnNavigation
79
- * - for cumulative values in the future: we don't need this for now because, currently, cumulative values are never imported.
80
- assertUsage(
81
- configValue !== null,
82
- `Set ${pc.cyan(configName)} to ${pc.cyan('null')} in a +config.js file instead of ${importPath}`
83
- )
84
- */
85
- }
@@ -1,24 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parseConfigValuesSerialized = void 0;
4
- const utils_js_1 = require("../../utils.js");
5
- const parse_1 = require("@brillout/json-serializer/parse");
6
- function parseConfigValuesSerialized(configValuesSerialized) {
7
- const configValues = {};
8
- Object.entries(configValuesSerialized).forEach(([configName, configValueSeriliazed]) => {
9
- (0, utils_js_1.assert)(!configValues[configName]);
10
- const { valueSerialized, ...common } = configValueSeriliazed;
11
- const value = (0, parse_1.parseTransform)(valueSerialized);
12
- let configValue;
13
- if (common.type === 'cumulative') {
14
- (0, utils_js_1.assert)((0, utils_js_1.isArray)(value));
15
- configValue = { value, ...common };
16
- }
17
- else {
18
- configValue = { value, ...common };
19
- }
20
- configValues[configName] = configValue;
21
- });
22
- return configValues;
23
- }
24
- exports.parseConfigValuesSerialized = parseConfigValuesSerialized;
@@ -1,49 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.serializeConfigValueImported = exports.serializeConfigValue = void 0;
4
- // This file is never loaded on the client-side but we save it under the vike/shared/ directory in order to collocate it with:
5
- // - vike/shared/page-configs/serialize/parsePageConfigs.ts
6
- // - vike/shared/page-configs/serialize/parseConfigValuesImported.ts
7
- // Both parsePageConfigs() parseConfigValuesImported() and are loaded on the client-side and server-side
8
- const assertIsNotProductionRuntime_js_1 = require("../../../utils/assertIsNotProductionRuntime.js");
9
- (0, assertIsNotProductionRuntime_js_1.assertIsNotProductionRuntime)();
10
- const utils_js_1 = require("../../utils.js");
11
- const addImportStatement_js_1 = require("../../../node/plugin/plugins/importUserCode/addImportStatement.js");
12
- function serializeConfigValue(lines, configName, configValueSerialized) {
13
- let whitespace = ' ';
14
- lines.push(`${whitespace}['${configName}']: {`);
15
- whitespace += ' ';
16
- Object.entries(configValueSerialized).forEach(([key, val]) => {
17
- const valSerialized = key === 'valueSerialized' ? val : JSON.stringify(val);
18
- lines.push(`${whitespace} ${key}: ${valSerialized},`);
19
- });
20
- whitespace = whitespace.slice(2);
21
- lines.push(`${whitespace}},`);
22
- }
23
- exports.serializeConfigValue = serializeConfigValue;
24
- function serializeConfigValueImported(configValueSource, configName, whitespace, importStatements) {
25
- (0, utils_js_1.assert)(!configValueSource.valueIsFilePath);
26
- (0, utils_js_1.assert)(whitespace.replaceAll(' ', '').length === 0);
27
- const { valueIsImportedAtRuntime, valueIsDefinedByValueFile, definedAtFilePath } = configValueSource;
28
- (0, utils_js_1.assert)(valueIsImportedAtRuntime);
29
- const { filePathAbsoluteVite, fileExportName } = definedAtFilePath;
30
- if (valueIsDefinedByValueFile)
31
- (0, utils_js_1.assert)(fileExportName === undefined);
32
- const { importName } = (0, addImportStatement_js_1.addImportStatement)(importStatements, filePathAbsoluteVite, fileExportName || '*');
33
- const lines = [];
34
- lines.push(` {`);
35
- lines.push(` configName: '${configName}',`);
36
- lines.push(` importPath: '${filePathAbsoluteVite}',`);
37
- lines.push(` isValueFile: ${JSON.stringify(valueIsDefinedByValueFile)},`);
38
- if (valueIsDefinedByValueFile) {
39
- lines.push(` exportValues: ${importName},`);
40
- }
41
- else {
42
- lines.push(` exportValue: ${importName},`);
43
- (0, utils_js_1.assert)(fileExportName);
44
- lines.push(` exportName: ${JSON.stringify(fileExportName)},`);
45
- }
46
- lines.push(` },`);
47
- return lines;
48
- }
49
- exports.serializeConfigValueImported = serializeConfigValueImported;
@@ -1,5 +0,0 @@
1
- export { getConfigValuesSerialized };
2
- export { assertConfigValueIsSerializable };
3
- import type { ConfigEnvInternal, ConfigValueSource, DefinedAtData, PageConfigBuildTime } from '../../../../../shared/page-configs/PageConfig.js';
4
- declare function getConfigValuesSerialized(pageConfig: PageConfigBuildTime, importStatements: string[], isEnvMatch: (configEnv: ConfigEnvInternal, configValueSource?: ConfigValueSource) => boolean): string;
5
- declare function assertConfigValueIsSerializable(value: unknown, configName: string, definedAtData: DefinedAtData): void;
@@ -1,95 +0,0 @@
1
- export { getConfigValuesSerialized };
2
- export { assertConfigValueIsSerializable };
3
- import { assert, assertUsage, getPropAccessNotation } from '../../../utils.js';
4
- import { stringify } from '@brillout/json-serializer/stringify';
5
- import pc from '@brillout/picocolors';
6
- import { getConfigValueFilePathToShowToUser } from '../../../../../shared/page-configs/helpers.js';
7
- import { serializeConfigValue } from '../../../../../shared/page-configs/serialize/serializeConfigValue.js';
8
- import { getConfigValueSourcesNotOverriden } from '../../../shared/getConfigValueSourcesNotOverriden.js';
9
- import { parsePointerImportData } from './getVikeConfig/transformFileImports.js';
10
- import { addImportStatement } from '../addImportStatement.js';
11
- const REPLACE_ME_BEFORE = '__VIKE__REPLACE_ME_BEFORE__';
12
- const REPLACE_ME_AFTER = '__VIKE__REPLACE_ME_AFTER__';
13
- function getConfigValuesSerialized(pageConfig, importStatements, isEnvMatch) {
14
- const lines = [];
15
- Object.entries(pageConfig.configValuesComputed).forEach(([configName, configValuesComputed]) => {
16
- const { configEnv } = configValuesComputed;
17
- if (!isEnvMatch(configEnv))
18
- return;
19
- // configValeSources has higher precedence
20
- if (pageConfig.configValueSources[configName])
21
- return;
22
- const configValue = pageConfig.configValues[configName];
23
- assert(configValue);
24
- const { value, ...common } = configValue;
25
- assert(value === configValuesComputed.value);
26
- const valueSerialized = getConfigValueSerialized(value, configName, configValue.definedAtData, importStatements);
27
- const configValueSerialized = { valueSerialized, ...common };
28
- serializeConfigValue(lines, configName, configValueSerialized);
29
- });
30
- getConfigValueSourcesNotOverriden(pageConfig).forEach((configValueSource) => {
31
- const { configName, configEnv } = configValueSource;
32
- const configValue = pageConfig.configValues[configName];
33
- if (!configValue)
34
- return;
35
- if (!isEnvMatch(configEnv, configValueSource)) {
36
- return;
37
- }
38
- const { value, ...common } = configValue;
39
- const valueSerialized = getConfigValueSerialized(value, configName, configValue.definedAtData, importStatements);
40
- const configValueSerialized = { valueSerialized, ...common };
41
- serializeConfigValue(lines, configName, configValueSerialized);
42
- });
43
- const code = lines.join('\n');
44
- return code;
45
- }
46
- function assertConfigValueIsSerializable(value, configName, definedAtData) {
47
- // Contains asserts
48
- getConfigValueSerialized(value, configName, definedAtData, []);
49
- }
50
- function getConfigValueSerialized(value, configName, definedAtData, importStatements) {
51
- const valueName = `config${getPropAccessNotation(configName)}`;
52
- let configValueSerialized;
53
- try {
54
- configValueSerialized = stringify(value, {
55
- valueName,
56
- forbidReactElements: true,
57
- replacer(_, value) {
58
- if (typeof value === 'string') {
59
- const importData = parsePointerImportData(value);
60
- if (importData) {
61
- const { importName } = addImportStatement(importStatements, importData.importPath, importData.exportName);
62
- const replacement = [REPLACE_ME_BEFORE, importName, REPLACE_ME_AFTER].join('');
63
- return { replacement };
64
- }
65
- }
66
- }
67
- });
68
- }
69
- catch (err) {
70
- logJsonSerializeError(err, configName, definedAtData);
71
- assert(false);
72
- }
73
- configValueSerialized = configValueSerialized.replaceAll(`"${REPLACE_ME_BEFORE}`, '');
74
- configValueSerialized = configValueSerialized.replaceAll(`${REPLACE_ME_AFTER}"`, '');
75
- assert(!configValueSerialized.includes(REPLACE_ME_BEFORE));
76
- assert(!configValueSerialized.includes(REPLACE_ME_AFTER));
77
- return configValueSerialized;
78
- }
79
- function logJsonSerializeError(err, configName, definedAtData) {
80
- /*
81
- // import { isJsonSerializerError } from '@brillout/json-serializer/stringify'
82
- let serializationErrMsg = ''
83
- if (isJsonSerializerError(err)) {
84
- serializationErrMsg = err.messageCore
85
- } else {
86
- // When a property getter throws an error
87
- console.error('Serialization error:')
88
- console.error(err)
89
- serializationErrMsg = 'see serialization error printed above'
90
- }
91
- //*/
92
- const configValueFilePathToShowToUser = getConfigValueFilePathToShowToUser(definedAtData);
93
- assert(configValueFilePathToShowToUser);
94
- assertUsage(false, `${pc.cyan(configName)} defined by ${configValueFilePathToShowToUser} must be defined over a so-called "pointer import", see https://vike.dev/config#pointer-imports`);
95
- }
@@ -1,5 +0,0 @@
1
- export { getConfigValueSourcesNotOverriden };
2
- import type { ConfigValueSource, PageConfigBuildTime } from '../../../shared/page-configs/PageConfig.js';
3
- declare function getConfigValueSourcesNotOverriden(pageConfig: PageConfigBuildTime): (ConfigValueSource & {
4
- configName: string;
5
- })[];
@@ -1,11 +0,0 @@
1
- export { getConfigValueSourcesNotOverriden };
2
- import { assert, assertIsNotBrowser } from '../../shared/utils.js';
3
- assertIsNotBrowser();
4
- function getConfigValueSourcesNotOverriden(pageConfig) {
5
- const configValueSourcesRelevant = Object.entries(pageConfig.configValueSources).map(([configName, sources]) => {
6
- const configValueSource = sources[0];
7
- assert(configValueSource);
8
- return { configName, ...configValueSource };
9
- });
10
- return configValueSourcesRelevant;
11
- }
@@ -1,3 +0,0 @@
1
- export { getClientEntry };
2
- import type { PageConfigRuntime, PageConfigBuildTime } from '../../shared/page-configs/PageConfig.js';
3
- declare function getClientEntry(pageConfig: PageConfigRuntime | PageConfigBuildTime): null | string;
@@ -1,9 +0,0 @@
1
- export { getClientEntry };
2
- import { getConfigValue } from '../../shared/page-configs/getConfigValue.js';
3
- function getClientEntry(pageConfig) {
4
- const configName = 'client';
5
- const configValue = getConfigValue(pageConfig, configName, 'string');
6
- if (!configValue)
7
- return null;
8
- return configValue.value;
9
- }
@@ -1,4 +0,0 @@
1
- export { parseConfigValuesImported };
2
- import type { ConfigValues } from '../PageConfig.js';
3
- import type { ConfigValueImported } from './PageConfigSerialized.js';
4
- declare function parseConfigValuesImported(configValuesImported: ConfigValueImported[]): ConfigValues;
@@ -1,82 +0,0 @@
1
- export { parseConfigValuesImported };
2
- import { assert } from '../../utils.js';
3
- import { assertPlusFileExport } from '../assertPlusFileExport.js';
4
- function parseConfigValuesImported(configValuesImported) {
5
- const configValuesUnmerged = {};
6
- configValuesImported
7
- .filter((c) => c.configName !== 'client')
8
- .forEach((configValueLoaded) => {
9
- if (configValueLoaded.isValueFile) {
10
- const { exportValues, importPath, configName } = configValueLoaded;
11
- assertPlusFileExport(exportValues, importPath, configName);
12
- Object.entries(exportValues).forEach(([exportName, exportValue]) => {
13
- const isSideExport = exportName !== 'default'; // .md files may have "side-exports" such as `export { frontmatter }`
14
- const configName = isSideExport ? exportName : configValueLoaded.configName;
15
- configValuesUnmerged[configName] ?? (configValuesUnmerged[configName] = []);
16
- configValuesUnmerged[configName].push({
17
- value: exportValue,
18
- importPath,
19
- exportName,
20
- isSideExport
21
- });
22
- });
23
- }
24
- else {
25
- const { configName, importPath, exportValue, exportName } = configValueLoaded;
26
- configValuesUnmerged[configName] ?? (configValuesUnmerged[configName] = []);
27
- configValuesUnmerged[configName].push({
28
- value: exportValue,
29
- importPath,
30
- exportName,
31
- isSideExport: false
32
- });
33
- }
34
- });
35
- const configValues = {};
36
- Object.entries(configValuesUnmerged).forEach(([configName, values]) => {
37
- const valuesWithoutSideExports = values.filter((v) => !v.isSideExport);
38
- const isCumulative = valuesWithoutSideExports.length > 1;
39
- const noSideExports = valuesWithoutSideExports.length === values.length;
40
- if (isCumulative) {
41
- // Vike currently doesn't support side exports for cumulative configs
42
- assert(noSideExports);
43
- // TODO: implement
44
- assert(false);
45
- }
46
- else {
47
- const val = valuesWithoutSideExports[0] ??
48
- // We can't avoid side-export conflicts upstream. (We cannot know about side-exports at build-time.)
49
- // Side-exports have lower precedence.
50
- values[0];
51
- assert(val);
52
- const { value, importPath, exportName } = val;
53
- configValues[configName] = {
54
- type: 'standard',
55
- value,
56
- definedAtData: {
57
- // importPath cannot be relative to the current file, since the current file is a virtual file
58
- filePathToShowToUser: importPath,
59
- fileExportPathToShowToUser: [configName, 'default'].includes(exportName)
60
- ? []
61
- : [
62
- // Side-export
63
- exportName
64
- ]
65
- }
66
- };
67
- assertIsNotNull(value, configName, importPath);
68
- }
69
- });
70
- return configValues;
71
- }
72
- function assertIsNotNull(configValue, configName, importPath) {
73
- assert(!importPath.includes('+config.'));
74
- /* Re-use this for:
75
- * - upcoming config.requestPageContextOnNavigation
76
- * - for cumulative values in the future: we don't need this for now because, currently, cumulative values are never imported.
77
- assertUsage(
78
- configValue !== null,
79
- `Set ${pc.cyan(configName)} to ${pc.cyan('null')} in a +config.js file instead of ${importPath}`
80
- )
81
- */
82
- }
@@ -1,4 +0,0 @@
1
- export { parseConfigValuesSerialized };
2
- import type { ConfigValues } from '../PageConfig.js';
3
- import type { ConfigValueSerialized } from './PageConfigSerialized.js';
4
- declare function parseConfigValuesSerialized(configValuesSerialized: Record<string, ConfigValueSerialized>): ConfigValues;
@@ -1,21 +0,0 @@
1
- export { parseConfigValuesSerialized };
2
- import { assert, isArray } from '../../utils.js';
3
- import { parseTransform } from '@brillout/json-serializer/parse';
4
- function parseConfigValuesSerialized(configValuesSerialized) {
5
- const configValues = {};
6
- Object.entries(configValuesSerialized).forEach(([configName, configValueSeriliazed]) => {
7
- assert(!configValues[configName]);
8
- const { valueSerialized, ...common } = configValueSeriliazed;
9
- const value = parseTransform(valueSerialized);
10
- let configValue;
11
- if (common.type === 'cumulative') {
12
- assert(isArray(value));
13
- configValue = { value, ...common };
14
- }
15
- else {
16
- configValue = { value, ...common };
17
- }
18
- configValues[configName] = configValue;
19
- });
20
- return configValues;
21
- }
@@ -1,6 +0,0 @@
1
- export { serializeConfigValue };
2
- export { serializeConfigValueImported };
3
- import { ConfigValueSource } from '../PageConfig.js';
4
- import { ConfigValueSerialized } from './PageConfigSerialized.js';
5
- declare function serializeConfigValue(lines: string[], configName: string, configValueSerialized: ConfigValueSerialized): void;
6
- declare function serializeConfigValueImported(configValueSource: ConfigValueSource, configName: string, whitespace: string, importStatements: string[]): string[];
@@ -1,46 +0,0 @@
1
- export { serializeConfigValue };
2
- export { serializeConfigValueImported };
3
- // This file is never loaded on the client-side but we save it under the vike/shared/ directory in order to collocate it with:
4
- // - vike/shared/page-configs/serialize/parsePageConfigs.ts
5
- // - vike/shared/page-configs/serialize/parseConfigValuesImported.ts
6
- // Both parsePageConfigs() parseConfigValuesImported() and are loaded on the client-side and server-side
7
- import { assertIsNotProductionRuntime } from '../../../utils/assertIsNotProductionRuntime.js';
8
- assertIsNotProductionRuntime();
9
- import { assert } from '../../utils.js';
10
- import { addImportStatement } from '../../../node/plugin/plugins/importUserCode/addImportStatement.js';
11
- function serializeConfigValue(lines, configName, configValueSerialized) {
12
- let whitespace = ' ';
13
- lines.push(`${whitespace}['${configName}']: {`);
14
- whitespace += ' ';
15
- Object.entries(configValueSerialized).forEach(([key, val]) => {
16
- const valSerialized = key === 'valueSerialized' ? val : JSON.stringify(val);
17
- lines.push(`${whitespace} ${key}: ${valSerialized},`);
18
- });
19
- whitespace = whitespace.slice(2);
20
- lines.push(`${whitespace}},`);
21
- }
22
- function serializeConfigValueImported(configValueSource, configName, whitespace, importStatements) {
23
- assert(!configValueSource.valueIsFilePath);
24
- assert(whitespace.replaceAll(' ', '').length === 0);
25
- const { valueIsImportedAtRuntime, valueIsDefinedByValueFile, definedAtFilePath } = configValueSource;
26
- assert(valueIsImportedAtRuntime);
27
- const { filePathAbsoluteVite, fileExportName } = definedAtFilePath;
28
- if (valueIsDefinedByValueFile)
29
- assert(fileExportName === undefined);
30
- const { importName } = addImportStatement(importStatements, filePathAbsoluteVite, fileExportName || '*');
31
- const lines = [];
32
- lines.push(` {`);
33
- lines.push(` configName: '${configName}',`);
34
- lines.push(` importPath: '${filePathAbsoluteVite}',`);
35
- lines.push(` isValueFile: ${JSON.stringify(valueIsDefinedByValueFile)},`);
36
- if (valueIsDefinedByValueFile) {
37
- lines.push(` exportValues: ${importName},`);
38
- }
39
- else {
40
- lines.push(` exportValue: ${importName},`);
41
- assert(fileExportName);
42
- lines.push(` exportName: ${JSON.stringify(fileExportName)},`);
43
- }
44
- lines.push(` },`);
45
- return lines;
46
- }