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,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
|
+
}
|
|
@@ -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,
|
|
@@ -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 { projectInfo };
|
|
2
2
|
export { PROJECT_VERSION };
|
|
3
|
-
declare const PROJECT_VERSION: "0.4.171-commit-
|
|
3
|
+
declare const PROJECT_VERSION: "0.4.171-commit-3b2cb88";
|
|
4
4
|
declare const projectInfo: {
|
|
5
5
|
projectName: "Vike";
|
|
6
|
-
projectVersion: "0.4.171-commit-
|
|
6
|
+
projectVersion: "0.4.171-commit-3b2cb88";
|
|
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-3b2cb88",
|
|
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;
|
|
@@ -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;
|
package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getConfigValuesSerialized.d.ts
DELETED
|
@@ -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;
|