vike 0.4.171-commit-f9548df → 0.4.171-commit-3b2cb88
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/node/plugin/plugins/buildConfig.js +3 -4
- package/dist/cjs/node/plugin/plugins/devConfig/determineOptimizeDeps.js +18 -15
- package/dist/cjs/node/plugin/plugins/devConfig/index.js +2 -1
- package/dist/cjs/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.js +0 -1
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +3 -3
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +30 -74
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js +4 -42
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigs.js +9 -49
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/isRuntimeEnvMatch.js +6 -0
- package/dist/cjs/node/prerender/runPrerender.js +3 -2
- package/dist/cjs/node/runtime/html/injectAssets/getHtmlTags.js +3 -3
- package/dist/cjs/node/runtime/html/injectAssets/getViteDevScripts.js +2 -1
- package/dist/cjs/node/runtime/html/injectAssets/mergeScriptTags.js +2 -8
- package/dist/cjs/node/runtime/renderPage/analyzePage.js +9 -7
- package/dist/cjs/node/runtime/renderPage/createHttpResponseObject/getCacheControl.js +1 -1
- package/dist/cjs/node/runtime/renderPage/renderPageAlreadyRouted.js +2 -2
- package/dist/cjs/node/shared/assertV1Design.js +3 -4
- package/dist/cjs/shared/getPageContextUrlComputed.js +8 -6
- package/dist/cjs/shared/getPageFiles/analyzeClientSide.js +2 -2
- package/dist/cjs/shared/getPageFiles/parseGlobResults.js +15 -8
- package/dist/cjs/shared/hooks/getHook.js +2 -2
- package/dist/cjs/shared/page-configs/getConfigValue.js +14 -17
- package/dist/cjs/shared/page-configs/getConfigValueBuildTime.js +70 -0
- package/dist/cjs/shared/page-configs/loadConfigValues.js +3 -12
- package/dist/cjs/shared/page-configs/serialize/assertPageConfigsSerialized.js +0 -18
- package/dist/cjs/shared/page-configs/serialize/parsePageConfigs.js +110 -16
- package/dist/cjs/shared/page-configs/serialize/serializeConfigValues.js +198 -0
- package/dist/cjs/shared/route/loadPageRoutes.js +2 -2
- package/dist/cjs/utils/hasProp.js +5 -7
- package/dist/cjs/utils/projectInfo.js +1 -1
- package/dist/esm/client/client-routing-runtime/createPageContext.d.ts +2 -2
- package/dist/esm/client/client-routing-runtime/getPageContextFromHooks.js +3 -3
- package/dist/esm/client/client-routing-runtime/installClientRouter.js +18 -10
- package/dist/esm/client/server-routing-runtime/getPageContext.d.ts +4 -4
- package/dist/esm/node/plugin/plugins/buildConfig.js +3 -4
- package/dist/esm/node/plugin/plugins/devConfig/determineOptimizeDeps.js +18 -15
- package/dist/esm/node/plugin/plugins/devConfig/index.js +2 -1
- package/dist/esm/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.js +0 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.d.ts +2 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +3 -3
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +30 -74
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js +4 -42
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigs.js +9 -49
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/isRuntimeEnvMatch.d.ts +1 -0
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/isRuntimeEnvMatch.js +6 -0
- package/dist/esm/node/prerender/runPrerender.js +4 -3
- package/dist/esm/node/runtime/html/injectAssets/getHtmlTags.js +3 -3
- package/dist/esm/node/runtime/html/injectAssets/getViteDevScripts.js +3 -2
- package/dist/esm/node/runtime/html/injectAssets/mergeScriptTags.d.ts +1 -1
- package/dist/esm/node/runtime/html/injectAssets/mergeScriptTags.js +2 -8
- package/dist/esm/node/runtime/renderPage/analyzePage.js +9 -7
- package/dist/esm/node/runtime/renderPage/createHttpResponseObject/getCacheControl.js +2 -2
- package/dist/esm/node/runtime/renderPage/loadUserFilesServerSide.d.ts +1 -1
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.d.ts +4 -4
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.js +2 -2
- package/dist/esm/node/shared/assertV1Design.d.ts +2 -2
- package/dist/esm/node/shared/assertV1Design.js +3 -4
- package/dist/esm/shared/getPageContextUrlComputed.js +8 -6
- package/dist/esm/shared/getPageFiles/analyzeClientSide.js +3 -3
- package/dist/esm/shared/getPageFiles/parseGlobResults.js +14 -7
- package/dist/esm/shared/hooks/getHook.d.ts +2 -2
- package/dist/esm/shared/hooks/getHook.js +3 -3
- package/dist/esm/shared/page-configs/PageConfig.d.ts +10 -4
- package/dist/esm/shared/page-configs/getConfigValue.d.ts +12 -12
- package/dist/esm/shared/page-configs/getConfigValue.js +13 -16
- package/dist/esm/shared/page-configs/getConfigValueBuildTime.d.ts +9 -0
- package/dist/esm/shared/page-configs/getConfigValueBuildTime.js +67 -0
- package/dist/esm/shared/page-configs/loadConfigValues.js +3 -12
- package/dist/esm/shared/page-configs/serialize/PageConfigSerialized.d.ts +15 -19
- package/dist/esm/shared/page-configs/serialize/assertPageConfigsSerialized.d.ts +1 -5
- package/dist/esm/shared/page-configs/serialize/assertPageConfigsSerialized.js +1 -16
- package/dist/esm/shared/page-configs/serialize/parsePageConfigs.d.ts +4 -1
- package/dist/esm/shared/page-configs/serialize/parsePageConfigs.js +109 -15
- package/dist/esm/shared/page-configs/serialize/serializeConfigValues.d.ts +5 -0
- package/dist/esm/shared/page-configs/serialize/serializeConfigValues.js +192 -0
- package/dist/esm/shared/route/loadPageRoutes.js +3 -3
- package/dist/esm/utils/hasProp.d.ts +4 -13
- package/dist/esm/utils/hasProp.js +5 -7
- package/dist/esm/utils/projectInfo.d.ts +2 -2
- package/dist/esm/utils/projectInfo.js +1 -1
- package/package.json +2 -2
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getConfigValuesSerialized.js +0 -101
- package/dist/cjs/node/plugin/shared/getConfigValueSourcesNotOverriden.js +0 -14
- package/dist/cjs/node/shared/getClientEntry.js +0 -12
- package/dist/cjs/shared/page-configs/serialize/parseConfigValuesImported.js +0 -85
- package/dist/cjs/shared/page-configs/serialize/parseConfigValuesSerialized.js +0 -24
- package/dist/cjs/shared/page-configs/serialize/serializeConfigValue.js +0 -49
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getConfigValuesSerialized.d.ts +0 -5
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getConfigValuesSerialized.js +0 -95
- package/dist/esm/node/plugin/shared/getConfigValueSourcesNotOverriden.d.ts +0 -5
- package/dist/esm/node/plugin/shared/getConfigValueSourcesNotOverriden.js +0 -11
- package/dist/esm/node/shared/getClientEntry.d.ts +0 -3
- package/dist/esm/node/shared/getClientEntry.js +0 -9
- package/dist/esm/shared/page-configs/serialize/parseConfigValuesImported.d.ts +0 -4
- package/dist/esm/shared/page-configs/serialize/parseConfigValuesImported.js +0 -82
- package/dist/esm/shared/page-configs/serialize/parseConfigValuesSerialized.d.ts +0 -4
- package/dist/esm/shared/page-configs/serialize/parseConfigValuesSerialized.js +0 -21
- package/dist/esm/shared/page-configs/serialize/serializeConfigValue.d.ts +0 -6
- package/dist/esm/shared/page-configs/serialize/serializeConfigValue.js +0 -46
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.serializeConfigValues = void 0;
|
|
7
|
+
const assertIsNotProductionRuntime_js_1 = require("../../../utils/assertIsNotProductionRuntime.js");
|
|
8
|
+
const utils_js_1 = require("../../../node/plugin/utils.js");
|
|
9
|
+
const addImportStatement_js_1 = require("../../../node/plugin/plugins/importUserCode/addImportStatement.js");
|
|
10
|
+
const transformFileImports_js_1 = require("../../../node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transformFileImports.js");
|
|
11
|
+
const helpers_js_1 = require("../helpers.js");
|
|
12
|
+
const stringify_1 = require("@brillout/json-serializer/stringify");
|
|
13
|
+
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
14
|
+
const REPLACE_ME_BEFORE = '__VIKE__REPLACE_ME_BEFORE__';
|
|
15
|
+
const REPLACE_ME_AFTER = '__VIKE__REPLACE_ME_AFTER__';
|
|
16
|
+
// This file is never loaded on the client-side but we save it under the vike/shared/ directory in order to collocate it with parsePageConfigs()
|
|
17
|
+
// - vike/shared/page-configs/serialize/parsePageConfigs.ts
|
|
18
|
+
// - parsePageConfigs() is loaded on both the client- and server-side.
|
|
19
|
+
(0, assertIsNotProductionRuntime_js_1.assertIsNotProductionRuntime)();
|
|
20
|
+
function serializeConfigValues(pageConfig, importStatements, isEnvMatch, tabspace) {
|
|
21
|
+
const lines = [];
|
|
22
|
+
tabspace += ' ';
|
|
23
|
+
Object.entries(pageConfig.configValuesComputed ?? {}).forEach(([configName, configValuesComputed]) => {
|
|
24
|
+
if (!isEnvMatch(configValuesComputed.configEnv))
|
|
25
|
+
return;
|
|
26
|
+
// Is there a use case for overriding computed values? If yes, then configValeSources has higher precedence
|
|
27
|
+
if (pageConfig.configValueSources[configName])
|
|
28
|
+
return;
|
|
29
|
+
const valueData = serializeWithJson(configValuesComputed.value, configName, null, importStatements);
|
|
30
|
+
const configValueBase = {
|
|
31
|
+
type: 'computed',
|
|
32
|
+
definedAtData: null
|
|
33
|
+
};
|
|
34
|
+
serializeConfigValue(configValueBase, valueData, configName, lines, tabspace);
|
|
35
|
+
});
|
|
36
|
+
Object.entries(pageConfig.configValueSources).forEach(([configName, sources]) => {
|
|
37
|
+
const configDef = pageConfig.configDefinitions[configName];
|
|
38
|
+
(0, utils_js_1.assert)(configDef);
|
|
39
|
+
if (!configDef.cumulative) {
|
|
40
|
+
const configValueSource = sources[0];
|
|
41
|
+
(0, utils_js_1.assert)(configValueSource);
|
|
42
|
+
(0, utils_js_1.assert)(sources.slice(1).every((s) => s.isOverriden === true));
|
|
43
|
+
if (!isEnvMatch(configValueSource.configEnv))
|
|
44
|
+
return;
|
|
45
|
+
const { valueData, definedAtFile } = serializeConfigValueSource(configValueSource, configName, importStatements);
|
|
46
|
+
const configValueBase = {
|
|
47
|
+
type: 'standard',
|
|
48
|
+
definedAtData: definedAtFile
|
|
49
|
+
};
|
|
50
|
+
serializeConfigValue(configValueBase, valueData, configName, lines, tabspace);
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
const valueDataList = [];
|
|
54
|
+
const definedAtData = [];
|
|
55
|
+
sources
|
|
56
|
+
.filter((s) => !s.isOverriden)
|
|
57
|
+
.forEach((configValueSource) => {
|
|
58
|
+
if (!isEnvMatch(configValueSource.configEnv))
|
|
59
|
+
return;
|
|
60
|
+
const { valueData, definedAtFile } = serializeConfigValueSource(configValueSource, configName, importStatements);
|
|
61
|
+
valueDataList.push(valueData);
|
|
62
|
+
definedAtData.push(definedAtFile);
|
|
63
|
+
});
|
|
64
|
+
if (valueDataList.length === 0)
|
|
65
|
+
return;
|
|
66
|
+
const configValueBase = {
|
|
67
|
+
type: 'cumulative',
|
|
68
|
+
definedAtData
|
|
69
|
+
};
|
|
70
|
+
serializeConfigValue(configValueBase, valueDataList, configName, lines, tabspace);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
return lines;
|
|
74
|
+
}
|
|
75
|
+
exports.serializeConfigValues = serializeConfigValues;
|
|
76
|
+
function serializeConfigValueSource(configValueSource, configName, importStatements) {
|
|
77
|
+
(0, utils_js_1.assert)(configValueSource.isOverriden === false);
|
|
78
|
+
let valueData;
|
|
79
|
+
if ('value' in configValueSource) {
|
|
80
|
+
valueData = serializeWithJson(configValueSource.value, configName, configValueSource.definedAtFilePath, importStatements);
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
valueData = serializeWithImport(configValueSource, importStatements);
|
|
84
|
+
}
|
|
85
|
+
const definedAtFile = {
|
|
86
|
+
filePathToShowToUser: configValueSource.definedAtFilePath.filePathToShowToUser,
|
|
87
|
+
fileExportPathToShowToUser: configValueSource.definedAtFilePath.fileExportPathToShowToUser
|
|
88
|
+
};
|
|
89
|
+
return { valueData, definedAtFile };
|
|
90
|
+
}
|
|
91
|
+
function serializeConfigValue(configValueBase, valueData, configName, lines, tabspace) {
|
|
92
|
+
lineAdd(`[${JSON.stringify(configName)}]: {`);
|
|
93
|
+
{
|
|
94
|
+
tab();
|
|
95
|
+
lineAdd(`type: "${configValueBase.type}",`);
|
|
96
|
+
lineAdd(`definedAtData: ${JSON.stringify(configValueBase.definedAtData)},`);
|
|
97
|
+
lineAdd(`valueSerialized:`);
|
|
98
|
+
if (!Array.isArray(valueData)) {
|
|
99
|
+
serializeValueData(valueData);
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
lineAppend(' [');
|
|
103
|
+
valueData.forEach(serializeValueData);
|
|
104
|
+
lineAppend(` ],`);
|
|
105
|
+
}
|
|
106
|
+
untab();
|
|
107
|
+
}
|
|
108
|
+
lineAdd('},');
|
|
109
|
+
return;
|
|
110
|
+
function serializeValueData(valueData) {
|
|
111
|
+
lineAppend(` {`);
|
|
112
|
+
tab();
|
|
113
|
+
lineAdd(`type: "${valueData.type}",`);
|
|
114
|
+
const valueProp = valueData.type !== 'plus-file' ? 'value' : 'exportValues';
|
|
115
|
+
lineAdd(`${valueProp}: ${valueData.valueAsJsCode},`);
|
|
116
|
+
untab();
|
|
117
|
+
lineAdd(`},`);
|
|
118
|
+
}
|
|
119
|
+
function lineAppend(str) {
|
|
120
|
+
const i = lines.length - 1;
|
|
121
|
+
lines[i] = lines[i] += str;
|
|
122
|
+
}
|
|
123
|
+
function lineAdd(str) {
|
|
124
|
+
lines.push(`${tabspace}${str}`);
|
|
125
|
+
}
|
|
126
|
+
function tab() {
|
|
127
|
+
tabspace += ' ';
|
|
128
|
+
}
|
|
129
|
+
function untab() {
|
|
130
|
+
tabspace = tabspace.slice(2);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
function serializeWithImport(configValueSource, importStatements) {
|
|
134
|
+
(0, utils_js_1.assert)(!configValueSource.valueIsFilePath);
|
|
135
|
+
const { valueIsImportedAtRuntime, valueIsDefinedByPlusFile, definedAtFilePath } = configValueSource;
|
|
136
|
+
(0, utils_js_1.assert)(valueIsImportedAtRuntime);
|
|
137
|
+
const { filePathAbsoluteVite, fileExportName } = definedAtFilePath;
|
|
138
|
+
if (valueIsDefinedByPlusFile)
|
|
139
|
+
(0, utils_js_1.assert)(fileExportName === undefined);
|
|
140
|
+
const { importName } = (0, addImportStatement_js_1.addImportStatement)(importStatements, filePathAbsoluteVite, fileExportName || '*');
|
|
141
|
+
return {
|
|
142
|
+
type: valueIsDefinedByPlusFile ? 'plus-file' : 'pointer-import',
|
|
143
|
+
valueAsJsCode: importName
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
function serializeWithJson(value, configName, definedAtData, importStatements) {
|
|
147
|
+
const valueAsJsCode = valueToJson(value, configName, definedAtData, importStatements);
|
|
148
|
+
return {
|
|
149
|
+
type: 'js-serialized',
|
|
150
|
+
valueAsJsCode
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
function valueToJson(value, configName, definedAtData, importStatements) {
|
|
154
|
+
const valueName = `config${(0, utils_js_1.getPropAccessNotation)(configName)}`;
|
|
155
|
+
let configValueSerialized;
|
|
156
|
+
try {
|
|
157
|
+
configValueSerialized = (0, stringify_1.stringify)(value, {
|
|
158
|
+
valueName,
|
|
159
|
+
forbidReactElements: true,
|
|
160
|
+
replacer(_, value) {
|
|
161
|
+
if (typeof value === 'string') {
|
|
162
|
+
const importData = (0, transformFileImports_js_1.parsePointerImportData)(value);
|
|
163
|
+
if (importData) {
|
|
164
|
+
const { importName } = (0, addImportStatement_js_1.addImportStatement)(importStatements, importData.importPath, importData.exportName);
|
|
165
|
+
const replacement = [REPLACE_ME_BEFORE, importName, REPLACE_ME_AFTER].join('');
|
|
166
|
+
return { replacement };
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
catch (err) {
|
|
173
|
+
logJsonSerializeError(err, configName, definedAtData);
|
|
174
|
+
(0, utils_js_1.assert)(false);
|
|
175
|
+
}
|
|
176
|
+
configValueSerialized = configValueSerialized.replaceAll(`"${REPLACE_ME_BEFORE}`, '');
|
|
177
|
+
configValueSerialized = configValueSerialized.replaceAll(`${REPLACE_ME_AFTER}"`, '');
|
|
178
|
+
(0, utils_js_1.assert)(!configValueSerialized.includes(REPLACE_ME_BEFORE));
|
|
179
|
+
(0, utils_js_1.assert)(!configValueSerialized.includes(REPLACE_ME_AFTER));
|
|
180
|
+
return configValueSerialized;
|
|
181
|
+
}
|
|
182
|
+
function logJsonSerializeError(err, configName, definedAtData) {
|
|
183
|
+
/*
|
|
184
|
+
// import { isJsonSerializerError } from '@brillout/json-serializer/stringify'
|
|
185
|
+
let serializationErrMsg = ''
|
|
186
|
+
if (isJsonSerializerError(err)) {
|
|
187
|
+
serializationErrMsg = err.messageCore
|
|
188
|
+
} else {
|
|
189
|
+
// When a property getter throws an error
|
|
190
|
+
console.error('Serialization error:')
|
|
191
|
+
console.error(err)
|
|
192
|
+
serializationErrMsg = 'see serialization error printed above'
|
|
193
|
+
}
|
|
194
|
+
//*/
|
|
195
|
+
const configValueFilePathToShowToUser = (0, helpers_js_1.getConfigValueFilePathToShowToUser)(definedAtData);
|
|
196
|
+
(0, utils_js_1.assert)(configValueFilePathToShowToUser);
|
|
197
|
+
(0, utils_js_1.assertUsage)(false, `${picocolors_1.default.cyan(configName)} defined by ${configValueFilePathToShowToUser} must be defined over a so-called "pointer import", see https://vike.dev/config#pointer-imports`);
|
|
198
|
+
}
|
|
@@ -31,7 +31,7 @@ function getPageRoutes(filesystemRoots, pageFilesAll, pageConfigs, allPageIds) {
|
|
|
31
31
|
let pageRoute = null;
|
|
32
32
|
{
|
|
33
33
|
const configName = 'route';
|
|
34
|
-
const configValue = (0, getConfigValue_js_1.
|
|
34
|
+
const configValue = (0, getConfigValue_js_1.getConfigValueRuntime)(pageConfig, configName);
|
|
35
35
|
if (configValue) {
|
|
36
36
|
const route = configValue.value;
|
|
37
37
|
(0, utils_js_1.assert)(configValue.definedAtData);
|
|
@@ -47,7 +47,7 @@ function getPageRoutes(filesystemRoots, pageFilesAll, pageConfigs, allPageIds) {
|
|
|
47
47
|
}
|
|
48
48
|
else {
|
|
49
49
|
(0, utils_js_1.assert)((0, utils_js_2.isCallable)(route));
|
|
50
|
-
if ((0, getConfigValue_js_1.
|
|
50
|
+
if ((0, getConfigValue_js_1.getConfigValueRuntime)(pageConfig, 'iKnowThePerformanceRisksOfAsyncRouteFunctions', 'boolean'))
|
|
51
51
|
(0, resolveRouteFunction_js_1.warnDeprecatedAllowKey)();
|
|
52
52
|
pageRoute = {
|
|
53
53
|
pageId,
|
|
@@ -1,23 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.hasProp = void 0;
|
|
4
|
-
// - https://2ality.com/2020/06/type-guards-assertion-functions-typescript.html
|
|
5
|
-
// - https://www.typescriptlang.org/play?#code/GYVwdgxgLglg9mABDAzgFQJ4AcCmdgAUAbgIYA2IOAXIiWBgDSJTbWIDkARnHGTnewCUNUhRzIUibr35gA3AFgAUKEiwEEzLnzFylGnUbNWNdmBABbTjgBOQkXvGpE5q7cUrw0eElRa8hKL6tPRMLLimKFA2MGAA5vaIQU6SUTHxHqreGn6sOskGocYRHOAA1mBwAO5gickSiOWVNZle6r7oeYGOhUbhbGmxcYgAvKVgFdW1wlI8fHSIAN7KiMiExeIjW+OTNeyIgksrq4g2OFAgNkjRlMcAvsdnF1cb+EmOo9v9Hg9KyhAIKK0GhNKajRAAFgATMplCQUChbFACLltIQSEwzJZrHZBIJ-oCZAA6MhwOIEEj4v6eNQ+WgIpEEAFgAAmMHaIImzTAM3hiJsUEkzLZ7SOShOa0QTIQIp8hyelzAx1WUAAFjZqi4cFVEABRGwamwEdgAQQZArpADESDAyEJlHcgA
|
|
6
4
|
const isCallable_js_1 = require("./isCallable.js");
|
|
7
5
|
const isObject_js_1 = require("./isObject.js");
|
|
8
6
|
const isArrayOfStrings_js_1 = require("./isArrayOfStrings.js");
|
|
9
7
|
const isObjectOfStrings_js_1 = require("./isObjectOfStrings.js");
|
|
10
8
|
const isArray_js_1 = require("./isArray.js");
|
|
11
|
-
function hasProp(obj, prop, type
|
|
9
|
+
function hasProp(obj, prop, type) {
|
|
12
10
|
if (!(0, isObject_js_1.isObject)(obj))
|
|
13
11
|
return false;
|
|
14
12
|
if (!(prop in obj)) {
|
|
15
13
|
return type === 'undefined';
|
|
16
14
|
}
|
|
17
|
-
if (type ===
|
|
15
|
+
if (type === undefined) {
|
|
18
16
|
return true;
|
|
19
17
|
}
|
|
20
18
|
const propValue = obj[prop];
|
|
19
|
+
if (type === 'undefined') {
|
|
20
|
+
return propValue === undefined;
|
|
21
|
+
}
|
|
21
22
|
if (type === 'array') {
|
|
22
23
|
return (0, isArray_js_1.isArray)(propValue);
|
|
23
24
|
}
|
|
@@ -39,9 +40,6 @@ function hasProp(obj, prop, type = 'unknown') {
|
|
|
39
40
|
if (type === 'null') {
|
|
40
41
|
return propValue === null;
|
|
41
42
|
}
|
|
42
|
-
if (type === 'undefined') {
|
|
43
|
-
return propValue === undefined;
|
|
44
|
-
}
|
|
45
43
|
if (type === 'true') {
|
|
46
44
|
return propValue === true;
|
|
47
45
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PROJECT_VERSION = exports.projectInfo = void 0;
|
|
4
|
-
const PROJECT_VERSION = '0.4.171-commit-
|
|
4
|
+
const PROJECT_VERSION = '0.4.171-commit-3b2cb88';
|
|
5
5
|
exports.PROJECT_VERSION = PROJECT_VERSION;
|
|
6
6
|
const projectInfo = {
|
|
7
7
|
projectName: 'Vike',
|
|
@@ -5,8 +5,8 @@ declare function createPageContext(urlOriginal: string): Promise<{
|
|
|
5
5
|
_urlHandler: null;
|
|
6
6
|
_urlRewrite: null;
|
|
7
7
|
_baseServer: string;
|
|
8
|
-
_pageFilesAll: import("../../shared/getPageFiles
|
|
9
|
-
_pageConfigs: import("../../
|
|
8
|
+
_pageFilesAll: import("../../shared/getPageFiles.js").PageFile[];
|
|
9
|
+
_pageConfigs: import("../../__internal/index.js").PageConfig[];
|
|
10
10
|
_pageConfigGlobal: import("../../shared/page-configs/PageConfig.js").PageConfigGlobalRuntime;
|
|
11
11
|
_allPageIds: string[];
|
|
12
12
|
_pageRoutes: import("../../shared/route/loadPageRoutes.js").PageRoutes;
|
|
@@ -10,7 +10,7 @@ import { preparePageContextForUserConsumptionClientSide } from '../shared/prepar
|
|
|
10
10
|
import { removeBuiltInOverrides } from './getPageContext/removeBuiltInOverrides.js';
|
|
11
11
|
import { getPageContextRequestUrl } from '../../shared/getPageContextRequestUrl.js';
|
|
12
12
|
import { getPageConfig } from '../../shared/page-configs/helpers.js';
|
|
13
|
-
import {
|
|
13
|
+
import { getConfigValueRuntime } from '../../shared/page-configs/getConfigValue.js';
|
|
14
14
|
import { assertOnBeforeRenderHookReturn } from '../../shared/assertOnBeforeRenderHookReturn.js';
|
|
15
15
|
import { executeGuardHook } from '../../shared/route/executeGuardHook.js';
|
|
16
16
|
import { AbortRender, isAbortPageContext } from '../../shared/route/abort.js';
|
|
@@ -169,7 +169,7 @@ async function hookServerOnlyExists(hookName, pageContext) {
|
|
|
169
169
|
if (pageContext._pageConfigs.length > 0) {
|
|
170
170
|
// V1
|
|
171
171
|
const pageConfig = getPageConfig(pageContext._pageId, pageContext._pageConfigs);
|
|
172
|
-
const hookEnv =
|
|
172
|
+
const hookEnv = getConfigValueRuntime(pageConfig, `${hookName}Env`)?.value ?? {};
|
|
173
173
|
assert(isObject(hookEnv));
|
|
174
174
|
return !!hookEnv.server && !hookEnv.client;
|
|
175
175
|
}
|
|
@@ -193,7 +193,7 @@ function hookClientOnlyExists(hookName, pageContext) {
|
|
|
193
193
|
if (pageContext._pageConfigs.length > 0) {
|
|
194
194
|
// V1
|
|
195
195
|
const pageConfig = getPageConfig(pageContext._pageId, pageContext._pageConfigs);
|
|
196
|
-
const hookEnv =
|
|
196
|
+
const hookEnv = getConfigValueRuntime(pageConfig, `${hookName}Env`)?.value ?? {};
|
|
197
197
|
assert(isObject(hookEnv));
|
|
198
198
|
return !!hookEnv.client && !hookEnv.server;
|
|
199
199
|
}
|
|
@@ -7,22 +7,30 @@ import { onLinkClick } from './onLinkClick.js';
|
|
|
7
7
|
import { setupNativeScrollRestoration } from './scrollRestoration.js';
|
|
8
8
|
import { autoSaveScrollPosition } from './setScrollPosition.js';
|
|
9
9
|
async function installClientRouter() {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
//
|
|
10
|
+
// Init navigation history and scroll restoration
|
|
11
|
+
initHistoryAndScroll();
|
|
12
|
+
// Render initial page
|
|
13
|
+
const renderPromise = render();
|
|
14
|
+
// Intercept <a> clicks
|
|
15
|
+
onLinkClick();
|
|
16
|
+
// Preserve stack track
|
|
17
|
+
await renderPromise;
|
|
18
|
+
}
|
|
19
|
+
function render() {
|
|
15
20
|
assert(getRenderCount() === 0);
|
|
16
|
-
const
|
|
21
|
+
const renderPromise = renderPageClientSide({
|
|
17
22
|
scrollTarget: 'preserve-scroll',
|
|
18
23
|
isBackwardNavigation: null,
|
|
19
24
|
isClientSideNavigation: false
|
|
20
25
|
});
|
|
21
26
|
assert(getRenderCount() === 1);
|
|
22
|
-
|
|
23
|
-
|
|
27
|
+
return renderPromise;
|
|
28
|
+
}
|
|
29
|
+
function initHistoryAndScroll() {
|
|
30
|
+
setupNativeScrollRestoration();
|
|
31
|
+
initHistoryState();
|
|
32
|
+
autoSaveScrollPosition();
|
|
33
|
+
monkeyPatchHistoryPushState();
|
|
24
34
|
// Handle back-/forward navigation
|
|
25
35
|
onBrowserHistoryNavigation();
|
|
26
|
-
// Only for full stack straces
|
|
27
|
-
await promise;
|
|
28
36
|
}
|
|
@@ -8,8 +8,8 @@ declare function getPageContext(): Promise<{
|
|
|
8
8
|
_hasPageContextFromServer: true;
|
|
9
9
|
_hasPageContextFromClient: false;
|
|
10
10
|
} & {
|
|
11
|
-
_pageFilesAll: import("../../shared/getPageFiles
|
|
12
|
-
_pageConfigs: import("../../
|
|
13
|
-
} & import("../../shared/getPageFiles
|
|
14
|
-
_pageFilesLoaded: import("../../shared/getPageFiles
|
|
11
|
+
_pageFilesAll: import("../../shared/getPageFiles.js").PageFile[];
|
|
12
|
+
_pageConfigs: import("../../__internal/index.js").PageConfig[];
|
|
13
|
+
} & import("../../shared/getPageFiles.js").PageContextExports & {
|
|
14
|
+
_pageFilesLoaded: import("../../shared/getPageFiles.js").PageFile[];
|
|
15
15
|
}>;
|
|
@@ -4,19 +4,18 @@ export { analyzeClientEntries };
|
|
|
4
4
|
export { manifestTempFile };
|
|
5
5
|
import { assert, resolveOutDir, viteIsSSR, addOnBeforeLogHook, removeFileExtention, unique, assertUsage, injectRollupInputs, normalizeRollupInput, getOutDirs, assertNodeEnv_build, assertIsNpmPackageImport } from '../utils.js';
|
|
6
6
|
import { getVikeConfig, isV1Design } from './importUserCode/v1-design/getVikeConfig.js';
|
|
7
|
-
import { getConfigValue } from '../../../shared/page-configs/getConfigValue.js';
|
|
8
7
|
import { findPageFiles } from '../shared/findPageFiles.js';
|
|
9
8
|
import { getConfigVike } from '../../shared/getConfigVike.js';
|
|
10
9
|
import { getVirtualFileIdPageConfigValuesAll } from '../../shared/virtual-files/virtualFilePageConfigValuesAll.js';
|
|
11
10
|
import { extractAssetsAddQuery } from '../../shared/extractAssetsQuery.js';
|
|
12
11
|
import { createRequire } from 'module';
|
|
13
|
-
import { getClientEntry } from '../../shared/getClientEntry.js';
|
|
14
12
|
import fs from 'fs/promises';
|
|
15
13
|
import path from 'path';
|
|
16
14
|
import { fixServerAssets, fixServerAssets_isEnabled } from './buildConfig/fixServerAssets.js';
|
|
17
15
|
import { set_constant_ASSETS_MAP } from './importBuild/index.js';
|
|
18
16
|
import { prependEntriesDir } from '../../shared/prependEntriesDir.js';
|
|
19
17
|
import { getFilePathResolved } from '../shared/getFilePath.js';
|
|
18
|
+
import { getConfigValueBuildTime } from '../../../shared/page-configs/getConfigValueBuildTime.js';
|
|
20
19
|
// @ts-ignore Shimmed by dist-cjs-fixup.js for CJS build.
|
|
21
20
|
const importMetaUrl = import.meta.url;
|
|
22
21
|
const require_ = createRequire(importMetaUrl);
|
|
@@ -152,7 +151,7 @@ function analyzeClientEntries(pageConfigs, config) {
|
|
|
152
151
|
let clientEntries = {};
|
|
153
152
|
let clientEntryList = [];
|
|
154
153
|
pageConfigs.forEach((pageConfig) => {
|
|
155
|
-
const configValue =
|
|
154
|
+
const configValue = getConfigValueBuildTime(pageConfig, 'clientRouting', 'boolean');
|
|
156
155
|
if (configValue?.value) {
|
|
157
156
|
hasClientRouting = true;
|
|
158
157
|
}
|
|
@@ -165,7 +164,7 @@ function analyzeClientEntries(pageConfigs, config) {
|
|
|
165
164
|
clientEntries[entryName] = entryTarget;
|
|
166
165
|
}
|
|
167
166
|
{
|
|
168
|
-
const clientEntry =
|
|
167
|
+
const clientEntry = getConfigValueBuildTime(pageConfig, 'client', 'string')?.value ?? null;
|
|
169
168
|
if (clientEntry) {
|
|
170
169
|
clientEntryList.push(clientEntry);
|
|
171
170
|
}
|
|
@@ -2,7 +2,6 @@ export { determineOptimizeDeps };
|
|
|
2
2
|
import { findPageFiles } from '../../shared/findPageFiles.js';
|
|
3
3
|
import { assert, assertIsNpmPackageImport, createDebugger, isArray, unique } from '../../utils.js';
|
|
4
4
|
import { getVikeConfig } from '../importUserCode/v1-design/getVikeConfig.js';
|
|
5
|
-
import { getConfigValueSourcesNotOverriden } from '../../shared/getConfigValueSourcesNotOverriden.js';
|
|
6
5
|
import { analyzeClientEntries } from '../buildConfig.js';
|
|
7
6
|
import { virtualFileIdImportUserCodeClientCR, virtualFileIdImportUserCodeClientSR } from '../../../shared/virtual-files/virtualFileImportUserCode.js';
|
|
8
7
|
import { getFilePathResolved } from '../../shared/getFilePath.js';
|
|
@@ -45,20 +44,24 @@ async function getPageDeps(config, pageConfigs, isDev) {
|
|
|
45
44
|
// V1 design
|
|
46
45
|
{
|
|
47
46
|
pageConfigs.forEach((pageConfig) => {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
47
|
+
Object.values(pageConfig.configValueSources).forEach((sources) => {
|
|
48
|
+
sources
|
|
49
|
+
.filter((c) => !c.isOverriden)
|
|
50
|
+
.forEach((configValueSource) => {
|
|
51
|
+
if (!configValueSource.valueIsImportedAtRuntime)
|
|
52
|
+
return;
|
|
53
|
+
const { definedAtFilePath, configEnv } = configValueSource;
|
|
54
|
+
if (!configEnv.client)
|
|
55
|
+
return;
|
|
56
|
+
if (definedAtFilePath.filePathAbsoluteUserRootDir !== null) {
|
|
57
|
+
// Vite expects entries to be filesystem absolute paths (surprisingly so).
|
|
58
|
+
addEntry(definedAtFilePath.filePathAbsoluteFilesystem);
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
// Adding definedAtFilePath.filePathAbsoluteFilesystem doesn't work for npm packages, I guess because of Vite's config.server.fs.allow
|
|
62
|
+
addInclude(definedAtFilePath.importPathAbsolute);
|
|
63
|
+
}
|
|
64
|
+
});
|
|
62
65
|
});
|
|
63
66
|
});
|
|
64
67
|
}
|
|
@@ -73,7 +73,8 @@ function devConfig() {
|
|
|
73
73
|
configureServer: {
|
|
74
74
|
order: 'post',
|
|
75
75
|
handler(server) {
|
|
76
|
-
|
|
76
|
+
const hasHonoViteDevServer = !!config.plugins.find((p) => p.name === '@hono/vite-dev-server');
|
|
77
|
+
if (config.server.middlewareMode || hasHonoViteDevServer)
|
|
77
78
|
return;
|
|
78
79
|
return () => {
|
|
79
80
|
addSsrMiddleware(server.middlewares);
|
|
@@ -63,7 +63,6 @@ export const pageFilesExportNamesLazy = {};
|
|
|
63
63
|
export const pageFilesExportNamesEager = {};
|
|
64
64
|
export const pageFilesList = [];
|
|
65
65
|
export const neverLoaded = {};
|
|
66
|
-
export const isGeneratedFile = true;
|
|
67
66
|
|
|
68
67
|
${await getVirtualFilePageConfigs(isForClientSide, isDev, id, isClientRouting, config)}
|
|
69
68
|
|
|
@@ -56,7 +56,8 @@ type ConfigDefinitionInternal = Omit<ConfigDefinition, 'env'> & {
|
|
|
56
56
|
_userEffectDefinedAtFilePath?: DefinedAtFilePath;
|
|
57
57
|
env: ConfigEnvInternal;
|
|
58
58
|
};
|
|
59
|
-
type ConfigDefinitions = Record<string,
|
|
59
|
+
type ConfigDefinitions = Record<string, // configName
|
|
60
|
+
ConfigDefinitionInternal>;
|
|
60
61
|
type ConfigDefinitionsBuiltIn = Record<ConfigNameBuiltIn, ConfigDefinitionInternal>;
|
|
61
62
|
declare const configDefinitionsBuiltIn: ConfigDefinitionsBuiltIn;
|
|
62
63
|
type ConfigNameGlobal = 'onPrerenderStart' | 'onBeforeRoute' | 'prerender' | 'disableAutoFullBuild' | 'includeAssetsImportedByServer' | 'baseAssets' | 'baseServer' | 'redirects' | 'trailingSlash' | 'disableUrlNormalization';
|
|
@@ -21,7 +21,7 @@ const configDefinitionsBuiltIn = {
|
|
|
21
21
|
env: { server: true }
|
|
22
22
|
},
|
|
23
23
|
onBeforePrerenderStart: {
|
|
24
|
-
env: { server: true }
|
|
24
|
+
env: { server: true, production: true }
|
|
25
25
|
},
|
|
26
26
|
Page: {
|
|
27
27
|
env: { server: true, client: true }
|
|
@@ -47,7 +47,7 @@ const configDefinitionsBuiltIn = {
|
|
|
47
47
|
},
|
|
48
48
|
client: {
|
|
49
49
|
// The value of the client config is merely the file path to the client entry file, which is only needed on the sever-side
|
|
50
|
-
env: { server: true },
|
|
50
|
+
env: { server: true, config: true },
|
|
51
51
|
_valueIsFilePath: true
|
|
52
52
|
},
|
|
53
53
|
clientRouting: {
|
|
@@ -95,7 +95,7 @@ const configDefinitionsBuiltIn = {
|
|
|
95
95
|
};
|
|
96
96
|
const configDefinitionsBuiltInGlobal = {
|
|
97
97
|
onPrerenderStart: {
|
|
98
|
-
env: { server: true }
|
|
98
|
+
env: { server: true, production: true }
|
|
99
99
|
},
|
|
100
100
|
onBeforeRoute: {
|
|
101
101
|
env: { server: true, client: 'if-client-routing', eager: true }
|