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.
- 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/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 +33 -13
- package/dist/cjs/node/prerender/utils.js +1 -0
- 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/executeOnRenderHtmlHook.js +7 -7
- package/dist/cjs/node/runtime/renderPage/loadUserFilesServerSide.js +4 -5
- package/dist/cjs/node/runtime/renderPage/preparePageContextForUserConsumptionServerSide.js +2 -2
- package/dist/cjs/node/runtime/renderPage/renderPageAlreadyRouted.js +6 -5
- package/dist/cjs/node/shared/assertV1Design.js +3 -4
- package/dist/cjs/shared/{addUrlComputedProps.js → getPageContextUrlComputed.js} +52 -42
- package/dist/cjs/shared/getPageFiles/analyzeClientSide.js +2 -2
- 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 +1 -2
- 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/index.js +2 -2
- package/dist/cjs/shared/route/loadPageRoutes.js +2 -2
- package/dist/cjs/shared/route/resolveRouteFunction.js +2 -2
- package/dist/cjs/shared/utils.js +2 -0
- package/dist/cjs/utils/changeEnumerable.js +9 -0
- package/dist/cjs/utils/hasProp.js +5 -7
- package/dist/cjs/utils/objectAssign.js +1 -1
- package/dist/cjs/utils/objectDefineProperty.js +8 -0
- package/dist/cjs/utils/projectInfo.js +1 -1
- package/dist/esm/client/client-routing-runtime/createPageContext.d.ts +6 -4
- package/dist/esm/client/client-routing-runtime/createPageContext.js +4 -3
- package/dist/esm/client/client-routing-runtime/getPageContextFromHooks.js +14 -10
- package/dist/esm/client/server-routing-runtime/getPageContext.d.ts +4 -4
- package/dist/esm/client/shared/loadUserFilesClientSide.js +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/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 +35 -15
- package/dist/esm/node/prerender/utils.d.ts +1 -0
- package/dist/esm/node/prerender/utils.js +1 -0
- 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/executeOnRenderHtmlHook.js +7 -7
- package/dist/esm/node/runtime/renderPage/loadUserFilesServerSide.d.ts +1 -9
- package/dist/esm/node/runtime/renderPage/loadUserFilesServerSide.js +4 -5
- package/dist/esm/node/runtime/renderPage/preparePageContextForUserConsumptionServerSide.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/preparePageContextForUserConsumptionServerSide.js +2 -2
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.d.ts +27 -50
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.js +6 -5
- package/dist/esm/node/shared/assertV1Design.d.ts +2 -2
- package/dist/esm/node/shared/assertV1Design.js +3 -4
- package/dist/esm/shared/{addUrlComputedProps.d.ts → getPageContextUrlComputed.d.ts} +23 -21
- package/dist/esm/shared/{addUrlComputedProps.js → getPageContextUrlComputed.js} +52 -42
- package/dist/esm/shared/getPageFiles/analyzeClientSide.js +3 -3
- 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.js +1 -2
- 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/index.d.ts +3 -3
- package/dist/esm/shared/route/index.js +2 -2
- package/dist/esm/shared/route/loadPageRoutes.js +3 -3
- package/dist/esm/shared/route/resolveRouteFunction.d.ts +2 -2
- package/dist/esm/shared/route/resolveRouteFunction.js +2 -2
- package/dist/esm/shared/types.d.ts +4 -4
- package/dist/esm/shared/utils.d.ts +2 -0
- package/dist/esm/shared/utils.js +2 -0
- package/dist/esm/types/index.d.ts +1 -1
- package/dist/esm/utils/changeEnumerable.d.ts +2 -0
- package/dist/esm/utils/changeEnumerable.js +5 -0
- package/dist/esm/utils/hasProp.d.ts +4 -13
- package/dist/esm/utils/hasProp.js +5 -7
- package/dist/esm/utils/objectAssign.js +1 -1
- package/dist/esm/utils/objectDefineProperty.d.ts +4 -0
- package/dist/esm/utils/objectDefineProperty.js +4 -0
- 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,5 @@
|
|
|
1
|
+
export { serializeConfigValues };
|
|
2
|
+
import type { ConfigEnvInternal, PageConfigBuildTime, PageConfigGlobalBuildTime } from '../PageConfig.js';
|
|
3
|
+
declare function serializeConfigValues(pageConfig: PageConfigBuildTime | (PageConfigGlobalBuildTime & {
|
|
4
|
+
configValuesComputed?: undefined;
|
|
5
|
+
}), importStatements: string[], isEnvMatch: (configEnv: ConfigEnvInternal) => boolean, tabspace: string): string[];
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
export { serializeConfigValues };
|
|
2
|
+
import { assertIsNotProductionRuntime } from '../../../utils/assertIsNotProductionRuntime.js';
|
|
3
|
+
import { assert, assertUsage, getPropAccessNotation } from '../../../node/plugin/utils.js';
|
|
4
|
+
import { addImportStatement } from '../../../node/plugin/plugins/importUserCode/addImportStatement.js';
|
|
5
|
+
import { parsePointerImportData } from '../../../node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transformFileImports.js';
|
|
6
|
+
import { getConfigValueFilePathToShowToUser } from '../helpers.js';
|
|
7
|
+
import { stringify } from '@brillout/json-serializer/stringify';
|
|
8
|
+
import pc from '@brillout/picocolors';
|
|
9
|
+
const REPLACE_ME_BEFORE = '__VIKE__REPLACE_ME_BEFORE__';
|
|
10
|
+
const REPLACE_ME_AFTER = '__VIKE__REPLACE_ME_AFTER__';
|
|
11
|
+
// 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()
|
|
12
|
+
// - vike/shared/page-configs/serialize/parsePageConfigs.ts
|
|
13
|
+
// - parsePageConfigs() is loaded on both the client- and server-side.
|
|
14
|
+
assertIsNotProductionRuntime();
|
|
15
|
+
function serializeConfigValues(pageConfig, importStatements, isEnvMatch, tabspace) {
|
|
16
|
+
const lines = [];
|
|
17
|
+
tabspace += ' ';
|
|
18
|
+
Object.entries(pageConfig.configValuesComputed ?? {}).forEach(([configName, configValuesComputed]) => {
|
|
19
|
+
if (!isEnvMatch(configValuesComputed.configEnv))
|
|
20
|
+
return;
|
|
21
|
+
// Is there a use case for overriding computed values? If yes, then configValeSources has higher precedence
|
|
22
|
+
if (pageConfig.configValueSources[configName])
|
|
23
|
+
return;
|
|
24
|
+
const valueData = serializeWithJson(configValuesComputed.value, configName, null, importStatements);
|
|
25
|
+
const configValueBase = {
|
|
26
|
+
type: 'computed',
|
|
27
|
+
definedAtData: null
|
|
28
|
+
};
|
|
29
|
+
serializeConfigValue(configValueBase, valueData, configName, lines, tabspace);
|
|
30
|
+
});
|
|
31
|
+
Object.entries(pageConfig.configValueSources).forEach(([configName, sources]) => {
|
|
32
|
+
const configDef = pageConfig.configDefinitions[configName];
|
|
33
|
+
assert(configDef);
|
|
34
|
+
if (!configDef.cumulative) {
|
|
35
|
+
const configValueSource = sources[0];
|
|
36
|
+
assert(configValueSource);
|
|
37
|
+
assert(sources.slice(1).every((s) => s.isOverriden === true));
|
|
38
|
+
if (!isEnvMatch(configValueSource.configEnv))
|
|
39
|
+
return;
|
|
40
|
+
const { valueData, definedAtFile } = serializeConfigValueSource(configValueSource, configName, importStatements);
|
|
41
|
+
const configValueBase = {
|
|
42
|
+
type: 'standard',
|
|
43
|
+
definedAtData: definedAtFile
|
|
44
|
+
};
|
|
45
|
+
serializeConfigValue(configValueBase, valueData, configName, lines, tabspace);
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
const valueDataList = [];
|
|
49
|
+
const definedAtData = [];
|
|
50
|
+
sources
|
|
51
|
+
.filter((s) => !s.isOverriden)
|
|
52
|
+
.forEach((configValueSource) => {
|
|
53
|
+
if (!isEnvMatch(configValueSource.configEnv))
|
|
54
|
+
return;
|
|
55
|
+
const { valueData, definedAtFile } = serializeConfigValueSource(configValueSource, configName, importStatements);
|
|
56
|
+
valueDataList.push(valueData);
|
|
57
|
+
definedAtData.push(definedAtFile);
|
|
58
|
+
});
|
|
59
|
+
if (valueDataList.length === 0)
|
|
60
|
+
return;
|
|
61
|
+
const configValueBase = {
|
|
62
|
+
type: 'cumulative',
|
|
63
|
+
definedAtData
|
|
64
|
+
};
|
|
65
|
+
serializeConfigValue(configValueBase, valueDataList, configName, lines, tabspace);
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
return lines;
|
|
69
|
+
}
|
|
70
|
+
function serializeConfigValueSource(configValueSource, configName, importStatements) {
|
|
71
|
+
assert(configValueSource.isOverriden === false);
|
|
72
|
+
let valueData;
|
|
73
|
+
if ('value' in configValueSource) {
|
|
74
|
+
valueData = serializeWithJson(configValueSource.value, configName, configValueSource.definedAtFilePath, importStatements);
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
valueData = serializeWithImport(configValueSource, importStatements);
|
|
78
|
+
}
|
|
79
|
+
const definedAtFile = {
|
|
80
|
+
filePathToShowToUser: configValueSource.definedAtFilePath.filePathToShowToUser,
|
|
81
|
+
fileExportPathToShowToUser: configValueSource.definedAtFilePath.fileExportPathToShowToUser
|
|
82
|
+
};
|
|
83
|
+
return { valueData, definedAtFile };
|
|
84
|
+
}
|
|
85
|
+
function serializeConfigValue(configValueBase, valueData, configName, lines, tabspace) {
|
|
86
|
+
lineAdd(`[${JSON.stringify(configName)}]: {`);
|
|
87
|
+
{
|
|
88
|
+
tab();
|
|
89
|
+
lineAdd(`type: "${configValueBase.type}",`);
|
|
90
|
+
lineAdd(`definedAtData: ${JSON.stringify(configValueBase.definedAtData)},`);
|
|
91
|
+
lineAdd(`valueSerialized:`);
|
|
92
|
+
if (!Array.isArray(valueData)) {
|
|
93
|
+
serializeValueData(valueData);
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
lineAppend(' [');
|
|
97
|
+
valueData.forEach(serializeValueData);
|
|
98
|
+
lineAppend(` ],`);
|
|
99
|
+
}
|
|
100
|
+
untab();
|
|
101
|
+
}
|
|
102
|
+
lineAdd('},');
|
|
103
|
+
return;
|
|
104
|
+
function serializeValueData(valueData) {
|
|
105
|
+
lineAppend(` {`);
|
|
106
|
+
tab();
|
|
107
|
+
lineAdd(`type: "${valueData.type}",`);
|
|
108
|
+
const valueProp = valueData.type !== 'plus-file' ? 'value' : 'exportValues';
|
|
109
|
+
lineAdd(`${valueProp}: ${valueData.valueAsJsCode},`);
|
|
110
|
+
untab();
|
|
111
|
+
lineAdd(`},`);
|
|
112
|
+
}
|
|
113
|
+
function lineAppend(str) {
|
|
114
|
+
const i = lines.length - 1;
|
|
115
|
+
lines[i] = lines[i] += str;
|
|
116
|
+
}
|
|
117
|
+
function lineAdd(str) {
|
|
118
|
+
lines.push(`${tabspace}${str}`);
|
|
119
|
+
}
|
|
120
|
+
function tab() {
|
|
121
|
+
tabspace += ' ';
|
|
122
|
+
}
|
|
123
|
+
function untab() {
|
|
124
|
+
tabspace = tabspace.slice(2);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
function serializeWithImport(configValueSource, importStatements) {
|
|
128
|
+
assert(!configValueSource.valueIsFilePath);
|
|
129
|
+
const { valueIsImportedAtRuntime, valueIsDefinedByPlusFile, definedAtFilePath } = configValueSource;
|
|
130
|
+
assert(valueIsImportedAtRuntime);
|
|
131
|
+
const { filePathAbsoluteVite, fileExportName } = definedAtFilePath;
|
|
132
|
+
if (valueIsDefinedByPlusFile)
|
|
133
|
+
assert(fileExportName === undefined);
|
|
134
|
+
const { importName } = addImportStatement(importStatements, filePathAbsoluteVite, fileExportName || '*');
|
|
135
|
+
return {
|
|
136
|
+
type: valueIsDefinedByPlusFile ? 'plus-file' : 'pointer-import',
|
|
137
|
+
valueAsJsCode: importName
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
function serializeWithJson(value, configName, definedAtData, importStatements) {
|
|
141
|
+
const valueAsJsCode = valueToJson(value, configName, definedAtData, importStatements);
|
|
142
|
+
return {
|
|
143
|
+
type: 'js-serialized',
|
|
144
|
+
valueAsJsCode
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
function valueToJson(value, configName, definedAtData, importStatements) {
|
|
148
|
+
const valueName = `config${getPropAccessNotation(configName)}`;
|
|
149
|
+
let configValueSerialized;
|
|
150
|
+
try {
|
|
151
|
+
configValueSerialized = stringify(value, {
|
|
152
|
+
valueName,
|
|
153
|
+
forbidReactElements: true,
|
|
154
|
+
replacer(_, value) {
|
|
155
|
+
if (typeof value === 'string') {
|
|
156
|
+
const importData = parsePointerImportData(value);
|
|
157
|
+
if (importData) {
|
|
158
|
+
const { importName } = addImportStatement(importStatements, importData.importPath, importData.exportName);
|
|
159
|
+
const replacement = [REPLACE_ME_BEFORE, importName, REPLACE_ME_AFTER].join('');
|
|
160
|
+
return { replacement };
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
catch (err) {
|
|
167
|
+
logJsonSerializeError(err, configName, definedAtData);
|
|
168
|
+
assert(false);
|
|
169
|
+
}
|
|
170
|
+
configValueSerialized = configValueSerialized.replaceAll(`"${REPLACE_ME_BEFORE}`, '');
|
|
171
|
+
configValueSerialized = configValueSerialized.replaceAll(`${REPLACE_ME_AFTER}"`, '');
|
|
172
|
+
assert(!configValueSerialized.includes(REPLACE_ME_BEFORE));
|
|
173
|
+
assert(!configValueSerialized.includes(REPLACE_ME_AFTER));
|
|
174
|
+
return configValueSerialized;
|
|
175
|
+
}
|
|
176
|
+
function logJsonSerializeError(err, configName, definedAtData) {
|
|
177
|
+
/*
|
|
178
|
+
// import { isJsonSerializerError } from '@brillout/json-serializer/stringify'
|
|
179
|
+
let serializationErrMsg = ''
|
|
180
|
+
if (isJsonSerializerError(err)) {
|
|
181
|
+
serializationErrMsg = err.messageCore
|
|
182
|
+
} else {
|
|
183
|
+
// When a property getter throws an error
|
|
184
|
+
console.error('Serialization error:')
|
|
185
|
+
console.error(err)
|
|
186
|
+
serializationErrMsg = 'see serialization error printed above'
|
|
187
|
+
}
|
|
188
|
+
//*/
|
|
189
|
+
const configValueFilePathToShowToUser = getConfigValueFilePathToShowToUser(definedAtData);
|
|
190
|
+
assert(configValueFilePathToShowToUser);
|
|
191
|
+
assertUsage(false, `${pc.cyan(configName)} defined by ${configValueFilePathToShowToUser} must be defined over a so-called "pointer import", see https://vike.dev/config#pointer-imports`);
|
|
192
|
+
}
|
|
@@ -4,18 +4,18 @@ export type { PageContextFromRoute };
|
|
|
4
4
|
export type { PageRoutes };
|
|
5
5
|
export type { RouteMatches };
|
|
6
6
|
import type { PageFile } from '../getPageFiles.js';
|
|
7
|
-
import {
|
|
7
|
+
import { type PageContextUrlInternal, type PageContextUrlSource } from '../getPageContextUrlComputed.js';
|
|
8
8
|
import type { PageRoutes, RouteType } from './loadPageRoutes.js';
|
|
9
9
|
import type { PageConfigRuntime, PageConfigGlobalRuntime } from '../page-configs/PageConfig.js';
|
|
10
10
|
import type { Hook } from '../hooks/getHook.js';
|
|
11
|
-
type PageContextForRoute =
|
|
11
|
+
type PageContextForRoute = PageContextUrlInternal & {
|
|
12
12
|
_pageFilesAll: PageFile[];
|
|
13
13
|
_pageConfigs: PageConfigRuntime[];
|
|
14
14
|
_allPageIds: string[];
|
|
15
15
|
_pageConfigGlobal: PageConfigGlobalRuntime;
|
|
16
16
|
_pageRoutes: PageRoutes;
|
|
17
17
|
_onBeforeRouteHook: Hook | null;
|
|
18
|
-
} &
|
|
18
|
+
} & PageContextUrlSource;
|
|
19
19
|
type PageContextFromRoute = {
|
|
20
20
|
_pageId: string | null;
|
|
21
21
|
routeParams: Record<string, string>;
|
|
@@ -6,7 +6,7 @@ if (isBrowser()) {
|
|
|
6
6
|
assertClientRouting();
|
|
7
7
|
}
|
|
8
8
|
import { assert, assertUsage, isPlainObject, objectAssign } from './utils.js';
|
|
9
|
-
import {
|
|
9
|
+
import { assertPageContextUrl } from '../getPageContextUrlComputed.js';
|
|
10
10
|
import { resolvePrecendence } from './resolvePrecedence.js';
|
|
11
11
|
import { resolveRouteString } from './resolveRouteString.js';
|
|
12
12
|
import { resolveRouteFunction } from './resolveRouteFunction.js';
|
|
@@ -15,7 +15,7 @@ import { debug } from './debug.js';
|
|
|
15
15
|
import pc from '@brillout/picocolors';
|
|
16
16
|
async function route(pageContextForRoute) {
|
|
17
17
|
debug('Pages routes:', pageContextForRoute._pageRoutes);
|
|
18
|
-
|
|
18
|
+
assertPageContextUrl(pageContextForRoute);
|
|
19
19
|
const pageContextFromRoute = {};
|
|
20
20
|
// onBeforeRoute()
|
|
21
21
|
const pageContextFromOnBeforeRouteHook = await executeOnBeforeRouteHook(pageContextForRoute);
|
|
@@ -3,7 +3,7 @@ import { isErrorPageId } from '../error-page.js';
|
|
|
3
3
|
import { assert, assertUsage, hasProp, slice } from './utils.js';
|
|
4
4
|
import { deduceRouteStringFromFilesystemPath } from './deduceRouteStringFromFilesystemPath.js';
|
|
5
5
|
import { isCallable } from '../utils.js';
|
|
6
|
-
import {
|
|
6
|
+
import { getConfigValueRuntime } from '../page-configs/getConfigValue.js';
|
|
7
7
|
import { getDefinedAtString } from '../page-configs/getConfigDefinedAt.js';
|
|
8
8
|
import { warnDeprecatedAllowKey } from './resolveRouteFunction.js';
|
|
9
9
|
import { getHookFromPageConfigGlobal, getHookTimeoutDefault } from '../hooks/getHook.js';
|
|
@@ -28,7 +28,7 @@ function getPageRoutes(filesystemRoots, pageFilesAll, pageConfigs, allPageIds) {
|
|
|
28
28
|
let pageRoute = null;
|
|
29
29
|
{
|
|
30
30
|
const configName = 'route';
|
|
31
|
-
const configValue =
|
|
31
|
+
const configValue = getConfigValueRuntime(pageConfig, configName);
|
|
32
32
|
if (configValue) {
|
|
33
33
|
const route = configValue.value;
|
|
34
34
|
assert(configValue.definedAtData);
|
|
@@ -44,7 +44,7 @@ function getPageRoutes(filesystemRoots, pageFilesAll, pageConfigs, allPageIds) {
|
|
|
44
44
|
}
|
|
45
45
|
else {
|
|
46
46
|
assert(isCallable(route));
|
|
47
|
-
if (
|
|
47
|
+
if (getConfigValueRuntime(pageConfig, 'iKnowThePerformanceRisksOfAsyncRouteFunctions', 'boolean'))
|
|
48
48
|
warnDeprecatedAllowKey();
|
|
49
49
|
pageRoute = {
|
|
50
50
|
pageId,
|
|
@@ -2,8 +2,8 @@ export { resolveRouteFunction };
|
|
|
2
2
|
export { assertRouteParams };
|
|
3
3
|
export { assertSyncRouting };
|
|
4
4
|
export { warnDeprecatedAllowKey };
|
|
5
|
-
import {
|
|
6
|
-
declare function resolveRouteFunction(routeFunction: Function, pageContext:
|
|
5
|
+
import { PageContextUrlInternal } from '../getPageContextUrlComputed.js';
|
|
6
|
+
declare function resolveRouteFunction(routeFunction: Function, pageContext: PageContextUrlInternal, routeDefinedAtString: string): Promise<null | {
|
|
7
7
|
precedence: number | null;
|
|
8
8
|
routeParams: Record<string, string>;
|
|
9
9
|
}>;
|
|
@@ -2,11 +2,11 @@ export { resolveRouteFunction };
|
|
|
2
2
|
export { assertRouteParams };
|
|
3
3
|
export { assertSyncRouting };
|
|
4
4
|
export { warnDeprecatedAllowKey };
|
|
5
|
-
import {
|
|
5
|
+
import { assertPageContextUrl } from '../getPageContextUrlComputed.js';
|
|
6
6
|
import { assert, assertUsage, assertWarning, hasProp, isPlainObject, isPromise } from './utils.js';
|
|
7
7
|
import pc from '@brillout/picocolors';
|
|
8
8
|
async function resolveRouteFunction(routeFunction, pageContext, routeDefinedAtString) {
|
|
9
|
-
|
|
9
|
+
assertPageContextUrl(pageContext);
|
|
10
10
|
let result = routeFunction(pageContext);
|
|
11
11
|
assertSyncRouting(result, `The Route Function ${routeDefinedAtString}`);
|
|
12
12
|
// TODO/v1-release: make resolveRouteFunction() and route() sync
|
|
@@ -7,7 +7,7 @@ export { PageContextBuiltInServerInternal };
|
|
|
7
7
|
export { PageContextBuiltInServer_deprecated as PageContextBuiltInServer };
|
|
8
8
|
export { PageContextBuiltInClientWithClientRouting_deprecated as PageContextBuiltInClientWithClientRouting };
|
|
9
9
|
export { PageContextBuiltInClientWithServerRouting_deprecated as PageContextBuiltInClientWithServerRouting };
|
|
10
|
-
import type {
|
|
10
|
+
import type { PageContextUrlInternal, PageContextUrlClient, PageContextUrlServer } from './getPageContextUrlComputed.js';
|
|
11
11
|
import type { ConfigEntries, ExportsAll, From, Source, Sources } from './getPageFiles/getExports.js';
|
|
12
12
|
import type { Config } from './page-configs/Config.js';
|
|
13
13
|
import type { PageContextConfig } from './page-configs/Config/PageContextConfig.js';
|
|
@@ -119,7 +119,7 @@ type PageContextBuiltInCommon<Data> = {
|
|
|
119
119
|
/** @deprecated */
|
|
120
120
|
pageExports: Record<string, unknown>;
|
|
121
121
|
};
|
|
122
|
-
type PageContextBuiltInServer<Data> = PageContextBuiltInCommon<Data> &
|
|
122
|
+
type PageContextBuiltInServer<Data> = PageContextBuiltInCommon<Data> & PageContextUrlServer;
|
|
123
123
|
type PageContextBuiltInClientWithClientRouting<Data> = Partial<PageContextBuiltInCommon<Data>> & Pick<PageContextBuiltInCommon<Data>, 'Page' | 'pageExports' | 'config' | 'configEntries' | 'exports' | 'exportsAll' | 'abortReason' | 'data' | 'source' | 'sources' | 'from'> & {
|
|
124
124
|
/** Whether the current page is already rendered to HTML */
|
|
125
125
|
isHydration: boolean;
|
|
@@ -129,7 +129,7 @@ type PageContextBuiltInClientWithClientRouting<Data> = Partial<PageContextBuiltI
|
|
|
129
129
|
* The value is `true` when the user clicks on his browser's backward navigation button, or when invoking `history.back()`.
|
|
130
130
|
*/
|
|
131
131
|
isBackwardNavigation: boolean | null;
|
|
132
|
-
} &
|
|
132
|
+
} & PageContextUrlClient;
|
|
133
133
|
type PageContextBuiltInClientWithServerRouting<Data> = Partial<PageContextBuiltInCommon<Data>> & Pick<PageContextBuiltInCommon<Data>, 'Page' | 'pageExports' | 'exports' | 'abortReason' | 'data'> & {
|
|
134
134
|
/**
|
|
135
135
|
* Whether the current page is already rendered to HTML.
|
|
@@ -145,7 +145,7 @@ type PageContextBuiltInClientWithServerRouting<Data> = Partial<PageContextBuiltI
|
|
|
145
145
|
isBackwardNavigation: null;
|
|
146
146
|
};
|
|
147
147
|
/** For Vike internal use */
|
|
148
|
-
type PageContextBuiltInServerInternal = Omit<PageContextBuiltInCommon<unknown> &
|
|
148
|
+
type PageContextBuiltInServerInternal = Omit<PageContextBuiltInCommon<unknown> & PageContextUrlInternal, 'data'>;
|
|
149
149
|
/** @deprecated
|
|
150
150
|
* Replace:
|
|
151
151
|
* ```
|
|
@@ -21,3 +21,5 @@ export * from '../utils/checkType.js';
|
|
|
21
21
|
export * from '../utils/getValuePrintable.js';
|
|
22
22
|
export * from '../utils/escapeRegex.js';
|
|
23
23
|
export * from '../utils/isArray.js';
|
|
24
|
+
export * from '../utils/changeEnumerable.js';
|
|
25
|
+
export * from '../utils/objectDefineProperty.js';
|
package/dist/esm/shared/utils.js
CHANGED
|
@@ -25,3 +25,5 @@ export * from '../utils/checkType.js';
|
|
|
25
25
|
export * from '../utils/getValuePrintable.js';
|
|
26
26
|
export * from '../utils/escapeRegex.js';
|
|
27
27
|
export * from '../utils/isArray.js';
|
|
28
|
+
export * from '../utils/changeEnumerable.js';
|
|
29
|
+
export * from '../utils/objectDefineProperty.js';
|
|
@@ -10,7 +10,7 @@ export type { Config, ConfigMeta as Meta, DataAsync, DataSync, GuardAsync, Guard
|
|
|
10
10
|
export type { ConfigEnv } from '../shared/page-configs/PageConfig.js';
|
|
11
11
|
export type { ConfigDefinition, ConfigEffect } from '../node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js';
|
|
12
12
|
export type { ConfigEntries } from '../shared/getPageFiles/getExports.js';
|
|
13
|
-
export type { Url } from '../shared/
|
|
13
|
+
export type { Url } from '../shared/getPageContextUrlComputed.js';
|
|
14
14
|
export type { InjectFilterEntry } from '../node/runtime/html/injectAssets/getHtmlTags.js';
|
|
15
15
|
export { defineConfig } from './defineConfig.js';
|
|
16
16
|
import type { ConfigEnv } from '../shared/page-configs/PageConfig.js';
|
|
@@ -1,15 +1,6 @@
|
|
|
1
1
|
export { hasProp };
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
declare function hasProp<ObjectType, PropName extends PropertyKey>(obj: ObjectType, prop: PropName, type
|
|
6
|
-
declare function hasProp<ObjectType, PropName extends PropertyKey>(obj: ObjectType, prop: PropName, type: 'array'): obj is ObjectType & Record<PropName, unknown[]>;
|
|
7
|
-
declare function hasProp<ObjectType, PropName extends PropertyKey>(obj: ObjectType, prop: PropName, type: 'string[]'): obj is ObjectType & Record<PropName, string[]>;
|
|
8
|
-
declare function hasProp<ObjectType, PropName extends PropertyKey>(obj: ObjectType, prop: PropName, type: 'string{}'): obj is ObjectType & Record<PropName, Record<string, string>>;
|
|
9
|
-
declare function hasProp<ObjectType, PropName extends PropertyKey>(obj: ObjectType, prop: PropName, type: 'function'): obj is ObjectType & Record<PropName, (...args: any[]) => unknown>;
|
|
10
|
-
declare function hasProp<ObjectType, PropName extends PropertyKey>(obj: ObjectType, prop: PropName, type: 'undefined'): obj is ObjectType & Record<PropName, undefined>;
|
|
11
|
-
declare function hasProp<ObjectType, PropName extends PropertyKey>(obj: ObjectType, prop: PropName, type: 'null'): obj is ObjectType & Record<PropName, null>;
|
|
12
|
-
declare function hasProp<ObjectType, PropName extends PropertyKey>(obj: ObjectType, prop: PropName, type: 'true'): obj is ObjectType & Record<PropName, true>;
|
|
13
|
-
declare function hasProp<ObjectType, PropName extends PropertyKey>(obj: ObjectType, prop: PropName, type: 'false'): obj is ObjectType & Record<PropName, false>;
|
|
2
|
+
export type { ResolveTypeAsString };
|
|
3
|
+
type TypeAsString = 'object' | 'string{}' | 'string[]' | 'array' | 'function' | 'number' | 'string' | 'boolean' | 'true' | 'false' | 'null' | 'undefined' | undefined;
|
|
4
|
+
type ResolveTypeAsString<Type extends TypeAsString = undefined> = Type extends 'object' ? Record<string, unknown> : Type extends 'string{}' ? Record<string, string> : Type extends 'string[]' ? string[] : Type extends 'array' ? unknown[] : Type extends 'function' ? (...args: any[]) => unknown : Type extends 'number' ? number : Type extends 'string' ? string : Type extends 'boolean' ? boolean : Type extends 'true' ? true : Type extends 'false' ? false : Type extends 'null' ? null : Type extends 'undefined' ? undefined : Type extends undefined ? unknown : never;
|
|
5
|
+
declare function hasProp<ObjectType, PropName extends PropertyKey, Type extends TypeAsString = undefined>(obj: ObjectType, prop: PropName, type?: Type): obj is ObjectType & Record<PropName, ResolveTypeAsString<Type>>;
|
|
14
6
|
declare function hasProp<ObjectType, PropName extends PropertyKey, Enum>(obj: ObjectType, prop: PropName, type: Enum[]): obj is ObjectType & Record<PropName, Enum>;
|
|
15
|
-
declare function hasProp<ObjectType, PropName extends PropertyKey>(obj: ObjectType, prop: PropName): obj is ObjectType & Record<PropName, unknown>;
|
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
export { hasProp };
|
|
2
|
-
// - https://2ality.com/2020/06/type-guards-assertion-functions-typescript.html
|
|
3
|
-
// - https://www.typescriptlang.org/play?#code/GYVwdgxgLglg9mABDAzgFQJ4AcCmdgAUAbgIYA2IOAXIiWBgDSJTbWIDkARnHGTnewCUNUhRzIUibr35gA3AFgAUKEiwEEzLnzFylGnUbNWNdmBABbTjgBOQkXvGpE5q7cUrw0eElRa8hKL6tPRMLLimKFA2MGAA5vaIQU6SUTHxHqreGn6sOskGocYRHOAA1mBwAO5gickSiOWVNZle6r7oeYGOhUbhbGmxcYgAvKVgFdW1wlI8fHSIAN7KiMiExeIjW+OTNeyIgksrq4g2OFAgNkjRlMcAvsdnF1cb+EmOo9v9Hg9KyhAIKK0GhNKajRAAFgATMplCQUChbFACLltIQSEwzJZrHZBIJ-oCZAA6MhwOIEEj4v6eNQ+WgIpEEAFgAAmMHaIImzTAM3hiJsUEkzLZ7SOShOa0QTIQIp8hyelzAx1WUAAFjZqi4cFVEABRGwamwEdgAQQZArpADESDAyEJlHcgA
|
|
4
2
|
import { isCallable } from './isCallable.js';
|
|
5
3
|
import { isObject } from './isObject.js';
|
|
6
4
|
import { isArrayOfStrings } from './isArrayOfStrings.js';
|
|
7
5
|
import { isObjectOfStrings } from './isObjectOfStrings.js';
|
|
8
6
|
import { isArray } from './isArray.js';
|
|
9
|
-
function hasProp(obj, prop, type
|
|
7
|
+
function hasProp(obj, prop, type) {
|
|
10
8
|
if (!isObject(obj))
|
|
11
9
|
return false;
|
|
12
10
|
if (!(prop in obj)) {
|
|
13
11
|
return type === 'undefined';
|
|
14
12
|
}
|
|
15
|
-
if (type ===
|
|
13
|
+
if (type === undefined) {
|
|
16
14
|
return true;
|
|
17
15
|
}
|
|
18
16
|
const propValue = obj[prop];
|
|
17
|
+
if (type === 'undefined') {
|
|
18
|
+
return propValue === undefined;
|
|
19
|
+
}
|
|
19
20
|
if (type === 'array') {
|
|
20
21
|
return isArray(propValue);
|
|
21
22
|
}
|
|
@@ -37,9 +38,6 @@ function hasProp(obj, prop, type = 'unknown') {
|
|
|
37
38
|
if (type === 'null') {
|
|
38
39
|
return propValue === null;
|
|
39
40
|
}
|
|
40
|
-
if (type === 'undefined') {
|
|
41
|
-
return propValue === undefined;
|
|
42
|
-
}
|
|
43
41
|
if (type === 'true') {
|
|
44
42
|
return propValue === true;
|
|
45
43
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { objectAssign };
|
|
2
2
|
// Same as Object.assign() but:
|
|
3
3
|
// - With type inference
|
|
4
|
-
// - Preserves property descriptors, which we need for preserving the getters added by
|
|
4
|
+
// - Preserves property descriptors, which we need for preserving the getters added by getPageContextUrlComputed()
|
|
5
5
|
function objectAssign(obj, objAddendum) {
|
|
6
6
|
if (objAddendum) {
|
|
7
7
|
Object.defineProperties(obj, Object.getOwnPropertyDescriptors(objAddendum));
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** Like Object.defineProperty() but with type inference */
|
|
2
|
+
export declare function objectDefineProperty<Obj extends object, Prop extends PropertyKey, PropertyType>(obj: Obj, prop: Prop, { get, ...args }: {
|
|
3
|
+
get: () => PropertyType;
|
|
4
|
+
} & Omit<PropertyDescriptor, 'set' | 'get'>): asserts obj is Obj & Record<Prop, PropertyType>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { projectInfo };
|
|
2
2
|
export { PROJECT_VERSION };
|
|
3
|
-
declare const PROJECT_VERSION: "0.4.171-commit-
|
|
3
|
+
declare const PROJECT_VERSION: "0.4.171-commit-6e37128";
|
|
4
4
|
declare const projectInfo: {
|
|
5
5
|
projectName: "Vike";
|
|
6
|
-
projectVersion: "0.4.171-commit-
|
|
6
|
+
projectVersion: "0.4.171-commit-6e37128";
|
|
7
7
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vike",
|
|
3
|
-
"version": "0.4.171-commit-
|
|
3
|
+
"version": "0.4.171-commit-6e37128",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"dev": "tsc --watch",
|
|
6
6
|
"build": "rimraf dist/ && pnpm run build:esm && pnpm run build:cjs",
|
|
@@ -212,7 +212,7 @@
|
|
|
212
212
|
"rimraf": "^5.0.5",
|
|
213
213
|
"sirv": "^2.0.4",
|
|
214
214
|
"source-map-support": "^0.5.21",
|
|
215
|
-
"typescript": "^5.
|
|
215
|
+
"typescript": "^5.4.5",
|
|
216
216
|
"vite": "npm:@brillout/vite@5.1.0-commit-3dc7abd"
|
|
217
217
|
},
|
|
218
218
|
"engines": {
|
|
@@ -1,101 +0,0 @@
|
|
|
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.assertConfigValueIsSerializable = exports.getConfigValuesSerialized = void 0;
|
|
7
|
-
const utils_js_1 = require("../../../utils.js");
|
|
8
|
-
const stringify_1 = require("@brillout/json-serializer/stringify");
|
|
9
|
-
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
10
|
-
const helpers_js_1 = require("../../../../../shared/page-configs/helpers.js");
|
|
11
|
-
const serializeConfigValue_js_1 = require("../../../../../shared/page-configs/serialize/serializeConfigValue.js");
|
|
12
|
-
const getConfigValueSourcesNotOverriden_js_1 = require("../../../shared/getConfigValueSourcesNotOverriden.js");
|
|
13
|
-
const transformFileImports_js_1 = require("./getVikeConfig/transformFileImports.js");
|
|
14
|
-
const addImportStatement_js_1 = require("../addImportStatement.js");
|
|
15
|
-
const REPLACE_ME_BEFORE = '__VIKE__REPLACE_ME_BEFORE__';
|
|
16
|
-
const REPLACE_ME_AFTER = '__VIKE__REPLACE_ME_AFTER__';
|
|
17
|
-
function getConfigValuesSerialized(pageConfig, importStatements, isEnvMatch) {
|
|
18
|
-
const lines = [];
|
|
19
|
-
Object.entries(pageConfig.configValuesComputed).forEach(([configName, configValuesComputed]) => {
|
|
20
|
-
const { configEnv } = configValuesComputed;
|
|
21
|
-
if (!isEnvMatch(configEnv))
|
|
22
|
-
return;
|
|
23
|
-
// configValeSources has higher precedence
|
|
24
|
-
if (pageConfig.configValueSources[configName])
|
|
25
|
-
return;
|
|
26
|
-
const configValue = pageConfig.configValues[configName];
|
|
27
|
-
(0, utils_js_1.assert)(configValue);
|
|
28
|
-
const { value, ...common } = configValue;
|
|
29
|
-
(0, utils_js_1.assert)(value === configValuesComputed.value);
|
|
30
|
-
const valueSerialized = getConfigValueSerialized(value, configName, configValue.definedAtData, importStatements);
|
|
31
|
-
const configValueSerialized = { valueSerialized, ...common };
|
|
32
|
-
(0, serializeConfigValue_js_1.serializeConfigValue)(lines, configName, configValueSerialized);
|
|
33
|
-
});
|
|
34
|
-
(0, getConfigValueSourcesNotOverriden_js_1.getConfigValueSourcesNotOverriden)(pageConfig).forEach((configValueSource) => {
|
|
35
|
-
const { configName, configEnv } = configValueSource;
|
|
36
|
-
const configValue = pageConfig.configValues[configName];
|
|
37
|
-
if (!configValue)
|
|
38
|
-
return;
|
|
39
|
-
if (!isEnvMatch(configEnv, configValueSource)) {
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
const { value, ...common } = configValue;
|
|
43
|
-
const valueSerialized = getConfigValueSerialized(value, configName, configValue.definedAtData, importStatements);
|
|
44
|
-
const configValueSerialized = { valueSerialized, ...common };
|
|
45
|
-
(0, serializeConfigValue_js_1.serializeConfigValue)(lines, configName, configValueSerialized);
|
|
46
|
-
});
|
|
47
|
-
const code = lines.join('\n');
|
|
48
|
-
return code;
|
|
49
|
-
}
|
|
50
|
-
exports.getConfigValuesSerialized = getConfigValuesSerialized;
|
|
51
|
-
function assertConfigValueIsSerializable(value, configName, definedAtData) {
|
|
52
|
-
// Contains asserts
|
|
53
|
-
getConfigValueSerialized(value, configName, definedAtData, []);
|
|
54
|
-
}
|
|
55
|
-
exports.assertConfigValueIsSerializable = assertConfigValueIsSerializable;
|
|
56
|
-
function getConfigValueSerialized(value, configName, definedAtData, importStatements) {
|
|
57
|
-
const valueName = `config${(0, utils_js_1.getPropAccessNotation)(configName)}`;
|
|
58
|
-
let configValueSerialized;
|
|
59
|
-
try {
|
|
60
|
-
configValueSerialized = (0, stringify_1.stringify)(value, {
|
|
61
|
-
valueName,
|
|
62
|
-
forbidReactElements: true,
|
|
63
|
-
replacer(_, value) {
|
|
64
|
-
if (typeof value === 'string') {
|
|
65
|
-
const importData = (0, transformFileImports_js_1.parsePointerImportData)(value);
|
|
66
|
-
if (importData) {
|
|
67
|
-
const { importName } = (0, addImportStatement_js_1.addImportStatement)(importStatements, importData.importPath, importData.exportName);
|
|
68
|
-
const replacement = [REPLACE_ME_BEFORE, importName, REPLACE_ME_AFTER].join('');
|
|
69
|
-
return { replacement };
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
catch (err) {
|
|
76
|
-
logJsonSerializeError(err, configName, definedAtData);
|
|
77
|
-
(0, utils_js_1.assert)(false);
|
|
78
|
-
}
|
|
79
|
-
configValueSerialized = configValueSerialized.replaceAll(`"${REPLACE_ME_BEFORE}`, '');
|
|
80
|
-
configValueSerialized = configValueSerialized.replaceAll(`${REPLACE_ME_AFTER}"`, '');
|
|
81
|
-
(0, utils_js_1.assert)(!configValueSerialized.includes(REPLACE_ME_BEFORE));
|
|
82
|
-
(0, utils_js_1.assert)(!configValueSerialized.includes(REPLACE_ME_AFTER));
|
|
83
|
-
return configValueSerialized;
|
|
84
|
-
}
|
|
85
|
-
function logJsonSerializeError(err, configName, definedAtData) {
|
|
86
|
-
/*
|
|
87
|
-
// import { isJsonSerializerError } from '@brillout/json-serializer/stringify'
|
|
88
|
-
let serializationErrMsg = ''
|
|
89
|
-
if (isJsonSerializerError(err)) {
|
|
90
|
-
serializationErrMsg = err.messageCore
|
|
91
|
-
} else {
|
|
92
|
-
// When a property getter throws an error
|
|
93
|
-
console.error('Serialization error:')
|
|
94
|
-
console.error(err)
|
|
95
|
-
serializationErrMsg = 'see serialization error printed above'
|
|
96
|
-
}
|
|
97
|
-
//*/
|
|
98
|
-
const configValueFilePathToShowToUser = (0, helpers_js_1.getConfigValueFilePathToShowToUser)(definedAtData);
|
|
99
|
-
(0, utils_js_1.assert)(configValueFilePathToShowToUser);
|
|
100
|
-
(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`);
|
|
101
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getConfigValueSourcesNotOverriden = void 0;
|
|
4
|
-
const utils_js_1 = require("../../shared/utils.js");
|
|
5
|
-
(0, utils_js_1.assertIsNotBrowser)();
|
|
6
|
-
function getConfigValueSourcesNotOverriden(pageConfig) {
|
|
7
|
-
const configValueSourcesRelevant = Object.entries(pageConfig.configValueSources).map(([configName, sources]) => {
|
|
8
|
-
const configValueSource = sources[0];
|
|
9
|
-
(0, utils_js_1.assert)(configValueSource);
|
|
10
|
-
return { configName, ...configValueSource };
|
|
11
|
-
});
|
|
12
|
-
return configValueSourcesRelevant;
|
|
13
|
-
}
|
|
14
|
-
exports.getConfigValueSourcesNotOverriden = getConfigValueSourcesNotOverriden;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getClientEntry = void 0;
|
|
4
|
-
const getConfigValue_js_1 = require("../../shared/page-configs/getConfigValue.js");
|
|
5
|
-
function getClientEntry(pageConfig) {
|
|
6
|
-
const configName = 'client';
|
|
7
|
-
const configValue = (0, getConfigValue_js_1.getConfigValue)(pageConfig, configName, 'string');
|
|
8
|
-
if (!configValue)
|
|
9
|
-
return null;
|
|
10
|
-
return configValue.value;
|
|
11
|
-
}
|
|
12
|
-
exports.getClientEntry = getClientEntry;
|