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
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { assertV1Design };
|
|
2
2
|
import { PageFile } from '../../shared/getPageFiles.js';
|
|
3
|
-
import type { PageConfigBuildTime
|
|
4
|
-
declare function assertV1Design(isOldDesign: boolean, pageConfigs:
|
|
3
|
+
import type { PageConfigBuildTime } from '../../shared/page-configs/PageConfig.js';
|
|
4
|
+
declare function assertV1Design(isOldDesign: boolean, pageConfigs: PageConfigBuildTime[], pageFilesAll?: PageFile[]): void;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export { assertV1Design };
|
|
2
|
-
import { getConfigValueFilePathToShowToUser } from '../../shared/page-configs/helpers.js';
|
|
3
2
|
import { assert, assertUsage, assertWarning, isNotNullish, unique } from './utils.js';
|
|
4
3
|
function assertV1Design(isOldDesign, pageConfigs, pageFilesAll) {
|
|
5
4
|
const isV1Design = pageConfigs.length > 0;
|
|
@@ -9,10 +8,10 @@ function assertV1Design(isOldDesign, pageConfigs, pageFilesAll) {
|
|
|
9
8
|
assert(pageFilesAll.length > 0);
|
|
10
9
|
const indent = '- ';
|
|
11
10
|
const filesV1 = unique(pageConfigs
|
|
12
|
-
.map((p) => Object.values(p.
|
|
13
|
-
.map((c) =>
|
|
11
|
+
.map((p) => Object.values(p.configValueSources).map((sources) => sources
|
|
12
|
+
.map((c) => c.definedAtFilePath.filePathAbsoluteUserRootDir)
|
|
14
13
|
.filter(isNotNullish)
|
|
15
|
-
.map((filePathToShowToUser) => indent + filePathToShowToUser))
|
|
14
|
+
.map((filePathToShowToUser) => indent + filePathToShowToUser)))
|
|
16
15
|
.flat(2));
|
|
17
16
|
const filesOld = pageFilesAll.map((p) => indent + p.filePath);
|
|
18
17
|
lines.push(...['V1 design files:', ...filesV1, 'Old design files:', ...filesOld]);
|
|
@@ -127,22 +127,24 @@ function assertPageContextUrlComputed(pageContext) {
|
|
|
127
127
|
```js
|
|
128
128
|
const PageContextUrlComputed = getPageContextUrlComputed(pageContext)
|
|
129
129
|
|
|
130
|
-
// ❌ Breaks the property getters of pageContext
|
|
130
|
+
// ❌ Breaks the property descriptors/getters of pageContext defined by getPageContextUrlComputed() such as pageContext.urlPathname
|
|
131
131
|
Object.assign(pageContext, pageContextUrlComputed)
|
|
132
132
|
|
|
133
|
-
// ❌ Also breaks property getters
|
|
133
|
+
// ❌ Also breaks property descriptors/getters
|
|
134
134
|
const pageContext = { ...pageContextUrlComputed }
|
|
135
135
|
|
|
136
|
-
// ✅ Preserves property getters
|
|
136
|
+
// ✅ Preserves property descriptors/getters (see objectAssign() implementation)
|
|
137
137
|
objectAssign(pageContext, pageContextUrlComputed)
|
|
138
138
|
```
|
|
139
139
|
*/
|
|
140
140
|
if ('urlPathname' in pageContext) {
|
|
141
141
|
assert(typeof pageContext.urlPathname === 'string');
|
|
142
142
|
assert(isPropertyGetter(pageContext, 'urlPathname'));
|
|
143
|
-
}
|
|
144
|
-
if ('urlParsed' in pageContext)
|
|
145
143
|
assert(isPropertyGetter(pageContext, 'urlParsed'));
|
|
146
|
-
if ('url' in pageContext)
|
|
147
144
|
assert(isPropertyGetter(pageContext, 'url'));
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
assert(!('urlParsed' in pageContext));
|
|
148
|
+
assert(!('url' in pageContext));
|
|
149
|
+
}
|
|
148
150
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
export { analyzeClientSide };
|
|
2
|
-
import {
|
|
2
|
+
import { getConfigValueRuntime } from '../page-configs/getConfigValue.js';
|
|
3
3
|
import { analyzePageClientSide } from './analyzePageClientSide.js';
|
|
4
4
|
function analyzeClientSide(pageConfig, pageFilesAll, pageId) {
|
|
5
5
|
// V1 design
|
|
6
6
|
if (pageConfig) {
|
|
7
|
-
const isClientRouting =
|
|
8
|
-
const isClientSideRenderable =
|
|
7
|
+
const isClientRouting = getConfigValueRuntime(pageConfig, 'clientRouting', 'boolean')?.value ?? false;
|
|
8
|
+
const isClientSideRenderable = getConfigValueRuntime(pageConfig, 'isClientSideRenderable', 'boolean')?.value ?? false;
|
|
9
9
|
return { isClientSideRenderable, isClientRouting };
|
|
10
10
|
}
|
|
11
11
|
else {
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
export { parseGlobResults };
|
|
2
|
-
|
|
2
|
+
// TODO/v1-release: remove old design code, and remove all assertions.
|
|
3
|
+
import { assert, hasProp, isCallable, isObject, cast, isArray } from '../utils.js';
|
|
3
4
|
import { assertExportValues } from './assert_exports_old_design.js';
|
|
4
5
|
import { getPageFileObject } from './getPageFileObject.js';
|
|
5
6
|
import { fileTypes } from './fileTypes.js';
|
|
6
|
-
import { assertPageConfigGlobalSerialized, assertPageConfigsSerialized } from '../page-configs/serialize/assertPageConfigsSerialized.js';
|
|
7
7
|
import { parsePageConfigs } from '../page-configs/serialize/parsePageConfigs.js';
|
|
8
8
|
function parseGlobResults(pageFilesExports) {
|
|
9
|
-
assert(hasProp(pageFilesExports, 'isGeneratedFile'));
|
|
10
|
-
assert(pageFilesExports.isGeneratedFile !== false, `vike was re-installed(/re-built). Restart your app.`);
|
|
11
|
-
assert(pageFilesExports.isGeneratedFile === true, `\`isGeneratedFile === ${pageFilesExports.isGeneratedFile}\``);
|
|
12
9
|
assert(hasProp(pageFilesExports, 'pageFilesLazy', 'object'));
|
|
13
10
|
assert(hasProp(pageFilesExports, 'pageFilesEager', 'object'));
|
|
14
11
|
assert(hasProp(pageFilesExports, 'pageFilesExportNamesLazy', 'object'));
|
|
@@ -41,8 +38,6 @@ function parseGlobResults(pageFilesExports) {
|
|
|
41
38
|
pageFile.loadExportNames = async () => {
|
|
42
39
|
if (!('exportNames' in pageFile)) {
|
|
43
40
|
const moduleExports = await loadModule();
|
|
44
|
-
// Vite 2 seems to choke following assertion: https://github.com/vikejs/vike/issues/455
|
|
45
|
-
assertUsage('exportNames' in moduleExports, 'You seem to be using Vite 2 but the latest vike versions only work with Vite 3');
|
|
46
41
|
assert(hasProp(moduleExports, 'exportNames', 'string[]'), pageFile.filePath);
|
|
47
42
|
pageFile.exportNames = moduleExports.exportNames;
|
|
48
43
|
}
|
|
@@ -88,3 +83,15 @@ function parseGlobResult(globObject) {
|
|
|
88
83
|
function assertLoadModule(globValue) {
|
|
89
84
|
assert(isCallable(globValue));
|
|
90
85
|
}
|
|
86
|
+
function assertPageConfigsSerialized(pageConfigsSerialized) {
|
|
87
|
+
assert(isArray(pageConfigsSerialized));
|
|
88
|
+
pageConfigsSerialized.forEach((pageConfigSerialized) => {
|
|
89
|
+
assert(isObject(pageConfigSerialized));
|
|
90
|
+
assert(hasProp(pageConfigSerialized, 'pageId', 'string'));
|
|
91
|
+
assert(hasProp(pageConfigSerialized, 'routeFilesystem'));
|
|
92
|
+
assert(hasProp(pageConfigSerialized, 'configValuesSerialized'));
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
function assertPageConfigGlobalSerialized(pageConfigGlobalSerialized) {
|
|
96
|
+
assert(hasProp(pageConfigGlobalSerialized, 'configValuesSerialized'));
|
|
97
|
+
}
|
|
@@ -11,7 +11,7 @@ export type { HooksTimeoutProvidedByUser };
|
|
|
11
11
|
export { getHookTimeoutDefault };
|
|
12
12
|
import type { PageContextExports } from '../getPageFiles.js';
|
|
13
13
|
import type { HookName, HookNamePage, HookNameGlobal } from '../page-configs/Config.js';
|
|
14
|
-
import type {
|
|
14
|
+
import type { PageConfigGlobalRuntime, PageConfigRuntime } from '../page-configs/PageConfig.js';
|
|
15
15
|
type Hook = HookLoc & {
|
|
16
16
|
hookFn: HookFn;
|
|
17
17
|
hookTimeout: HookTimeout;
|
|
@@ -27,7 +27,7 @@ type HookTimeout = {
|
|
|
27
27
|
};
|
|
28
28
|
type HooksTimeoutProvidedByUser = false | Partial<Record<HookName, false | Partial<HookTimeout>>>;
|
|
29
29
|
declare function getHook(pageContext: PageContextExports, hookName: HookName): null | Hook;
|
|
30
|
-
declare function getHookFromPageConfig(pageConfig: PageConfigRuntime
|
|
30
|
+
declare function getHookFromPageConfig(pageConfig: PageConfigRuntime, hookName: HookNamePage): null | Hook;
|
|
31
31
|
declare function getHookFromPageConfigGlobal(pageConfigGlobal: PageConfigGlobalRuntime, hookName: HookNameGlobal): null | Hook;
|
|
32
32
|
declare function assertHook<TPageContext extends PageContextExports, THookName extends PropertyKey & HookName>(pageContext: TPageContext, hookName: THookName): asserts pageContext is TPageContext & {
|
|
33
33
|
exports: Record<THookName, Function | undefined>;
|
|
@@ -8,7 +8,7 @@ export { setIsPrerenderering };
|
|
|
8
8
|
export { getHookTimeoutDefault };
|
|
9
9
|
import { getGlobalObject } from '../../utils/getGlobalObject.js';
|
|
10
10
|
import { getHookFilePathToShowToUser } from '../page-configs/helpers.js';
|
|
11
|
-
import {
|
|
11
|
+
import { getConfigValueRuntime } from '../page-configs/getConfigValue.js';
|
|
12
12
|
import { assert, assertUsage, checkType, isCallable, isObject } from '../utils.js';
|
|
13
13
|
import pc from '@brillout/picocolors';
|
|
14
14
|
const globalObject = getGlobalObject('getHook.ts', {
|
|
@@ -32,8 +32,8 @@ function getHook(pageContext, hookName) {
|
|
|
32
32
|
return { hookFn, hookName, hookFilePath, hookTimeout };
|
|
33
33
|
}
|
|
34
34
|
function getHookFromPageConfig(pageConfig, hookName) {
|
|
35
|
-
const configValue =
|
|
36
|
-
const hooksTimeout =
|
|
35
|
+
const configValue = getConfigValueRuntime(pageConfig, hookName);
|
|
36
|
+
const hooksTimeout = getConfigValueRuntime(pageConfig, 'hooksTimeout')?.value;
|
|
37
37
|
if (!configValue)
|
|
38
38
|
return null;
|
|
39
39
|
const hookFn = configValue.value;
|
|
@@ -16,9 +16,10 @@ export type { ConfigValuesComputed };
|
|
|
16
16
|
export type { DefinedAtData };
|
|
17
17
|
export type { DefinedAtFile };
|
|
18
18
|
export type { DefinedAtFilePath };
|
|
19
|
-
import type {
|
|
19
|
+
import type { ConfigValueSerialized } from './serialize/PageConfigSerialized.js';
|
|
20
20
|
import type { LocationId } from '../../node/plugin/plugins/importUserCode/v1-design/getVikeConfig/filesystemRouting.js';
|
|
21
21
|
import type { FilePath } from './FilePath.js';
|
|
22
|
+
import type { ConfigDefinitions } from '../../node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js';
|
|
22
23
|
type PageConfigBase = {
|
|
23
24
|
pageId: string;
|
|
24
25
|
isErrorPage?: true;
|
|
@@ -26,13 +27,12 @@ type PageConfigBase = {
|
|
|
26
27
|
routeString: string;
|
|
27
28
|
definedBy: string;
|
|
28
29
|
};
|
|
29
|
-
configValues: ConfigValues;
|
|
30
30
|
};
|
|
31
31
|
/** Page config data structure available at runtime */
|
|
32
32
|
type PageConfigRuntime = PageConfigBase & {
|
|
33
|
+
configValues: ConfigValues;
|
|
33
34
|
/** Load config values that are lazily loaded such as config.Page */
|
|
34
35
|
loadConfigValuesAll: () => Promise<{
|
|
35
|
-
configValuesImported: ConfigValueImported[];
|
|
36
36
|
configValuesSerialized: Record<string, ConfigValueSerialized>;
|
|
37
37
|
}>;
|
|
38
38
|
};
|
|
@@ -43,6 +43,7 @@ type PageConfigRuntimeLoaded = PageConfigRuntime & {
|
|
|
43
43
|
};
|
|
44
44
|
/** Page config data structure available at build-time */
|
|
45
45
|
type PageConfigBuildTime = PageConfigBase & {
|
|
46
|
+
configDefinitions: ConfigDefinitions;
|
|
46
47
|
configValueSources: ConfigValueSources;
|
|
47
48
|
configValuesComputed: ConfigValuesComputed;
|
|
48
49
|
};
|
|
@@ -52,6 +53,7 @@ type PageConfigGlobalRuntime = {
|
|
|
52
53
|
};
|
|
53
54
|
type PageConfigGlobalBuildTime = {
|
|
54
55
|
configValueSources: ConfigValueSources;
|
|
56
|
+
configDefinitions: ConfigDefinitions;
|
|
55
57
|
};
|
|
56
58
|
/** In what environment(s) the config value is loaded.
|
|
57
59
|
*
|
|
@@ -65,18 +67,22 @@ type ConfigEnv = {
|
|
|
65
67
|
/** For Vike internal use */
|
|
66
68
|
type ConfigEnvInternal = Omit<ConfigEnv, 'client'> & {
|
|
67
69
|
client?: boolean | 'if-client-routing';
|
|
70
|
+
/** Always load value, not matter what page is loaded. */
|
|
68
71
|
eager?: boolean;
|
|
72
|
+
/** Load value only in production or only in development. */
|
|
73
|
+
production?: boolean;
|
|
69
74
|
};
|
|
70
75
|
type ConfigValueSource = {
|
|
71
76
|
value?: unknown;
|
|
72
77
|
configEnv: ConfigEnvInternal;
|
|
73
78
|
definedAtFilePath: DefinedAtFilePath;
|
|
74
79
|
locationId: LocationId;
|
|
80
|
+
isOverriden: boolean;
|
|
75
81
|
/** Wether the config value is loaded at runtime, for example config.Page or config.onBeforeRender */
|
|
76
82
|
valueIsImportedAtRuntime: boolean;
|
|
77
83
|
/** Whether the config value is a file path, for example config.client */
|
|
78
84
|
valueIsFilePath?: true;
|
|
79
|
-
|
|
85
|
+
valueIsDefinedByPlusFile: boolean;
|
|
80
86
|
};
|
|
81
87
|
type DefinedAtFilePath = DefinedAtFile & FilePath & {
|
|
82
88
|
fileExportName?: string;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
export {
|
|
2
|
-
|
|
1
|
+
export { getConfigValueRuntime };
|
|
2
|
+
export { getConfigValueTyped };
|
|
3
|
+
export type { TypeAsString };
|
|
4
|
+
import { type ResolveTypeAsString } from '../utils.js';
|
|
5
|
+
import type { PageConfigRuntime, ConfigValue } from './PageConfig.js';
|
|
3
6
|
import type { ConfigNameBuiltIn } from './Config.js';
|
|
4
|
-
type PageConfigCommon = PageConfigRuntime | PageConfigBuildTime;
|
|
5
7
|
type ConfigName = ConfigNameBuiltIn;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
value: unknown;
|
|
14
|
-
};
|
|
8
|
+
type TypeAsString = 'string' | 'boolean' | undefined;
|
|
9
|
+
declare function getConfigValueTyped<Type extends TypeAsString = undefined>(configValue: ConfigValue, configName: ConfigName, type?: Type): null | (ConfigValue & {
|
|
10
|
+
value: ResolveTypeAsString<Type>;
|
|
11
|
+
});
|
|
12
|
+
declare function getConfigValueRuntime<Type extends TypeAsString = undefined>(pageConfig: PageConfigRuntime, configName: ConfigName, type?: Type): null | (ConfigValue & {
|
|
13
|
+
value: ResolveTypeAsString<Type>;
|
|
14
|
+
});
|
|
@@ -1,18 +1,24 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { getConfigValueRuntime };
|
|
2
|
+
export { getConfigValueTyped };
|
|
2
3
|
import { assert, assertUsage, getValuePrintable } from '../utils.js';
|
|
3
4
|
import pc from '@brillout/picocolors';
|
|
4
5
|
import { getConfigDefinedAtOptional } from './getConfigDefinedAt.js';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
return null;
|
|
6
|
+
function getConfigValueTyped(configValue, configName, type) {
|
|
7
|
+
/* [NULL_HANDLING] Do we really need this? This doesn't seem to make sense, let's eventually (re)move this.
|
|
8
|
+
// Enable users to suppress global config values by setting the local config value to null
|
|
9
|
+
if (configValue.value === null) return null
|
|
10
|
+
*/
|
|
11
11
|
const { value, definedAtData } = configValue;
|
|
12
12
|
if (type)
|
|
13
13
|
assertConfigValueType(value, type, configName, definedAtData);
|
|
14
14
|
return configValue;
|
|
15
15
|
}
|
|
16
|
+
function getConfigValueRuntime(pageConfig, configName, type) {
|
|
17
|
+
const configValue = pageConfig.configValues[configName];
|
|
18
|
+
if (!configValue)
|
|
19
|
+
return null;
|
|
20
|
+
return getConfigValueTyped(configValue, configName, type);
|
|
21
|
+
}
|
|
16
22
|
function assertConfigValueType(value, type, configName, definedAtData) {
|
|
17
23
|
assert(value !== null);
|
|
18
24
|
const typeActual = typeof value;
|
|
@@ -26,12 +32,3 @@ function assertConfigValueType(value, type, configName, definedAtData) {
|
|
|
26
32
|
const errMsg = `${configDefinedAt} has an invalid ${problem}: it should be a ${pc.cyan(type)} instead`;
|
|
27
33
|
assertUsage(false, errMsg);
|
|
28
34
|
}
|
|
29
|
-
function getConfigValueEntry(pageConfig, configName) {
|
|
30
|
-
const configValue = pageConfig.configValues[configName];
|
|
31
|
-
if (!configValue)
|
|
32
|
-
return null;
|
|
33
|
-
// Enable users to suppress global config values by setting the local config value to null
|
|
34
|
-
if (configValue.value === null)
|
|
35
|
-
return null;
|
|
36
|
-
return configValue;
|
|
37
|
-
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { getConfigValueBuildTime };
|
|
2
|
+
import { type ResolveTypeAsString } from '../utils.js';
|
|
3
|
+
import type { PageConfigBuildTime, ConfigValue } from './PageConfig.js';
|
|
4
|
+
import type { ConfigNameBuiltIn } from './Config.js';
|
|
5
|
+
import { type TypeAsString } from './getConfigValue.js';
|
|
6
|
+
type ConfigName = ConfigNameBuiltIn;
|
|
7
|
+
declare function getConfigValueBuildTime<Type extends TypeAsString = undefined>(pageConfig: PageConfigBuildTime, configName: ConfigName, type?: Type): null | (ConfigValue & {
|
|
8
|
+
value: ResolveTypeAsString<Type>;
|
|
9
|
+
});
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
export { getConfigValueBuildTime };
|
|
2
|
+
import { assert } from '../utils.js';
|
|
3
|
+
import { getConfigValueTyped } from './getConfigValue.js';
|
|
4
|
+
import { assertIsNotProductionRuntime } from '../../utils/assertIsNotProductionRuntime.js';
|
|
5
|
+
assertIsNotProductionRuntime();
|
|
6
|
+
function getConfigValueBuildTime(pageConfig, configName, type) {
|
|
7
|
+
const configValue = getConfigValue(pageConfig, configName);
|
|
8
|
+
if (!configValue)
|
|
9
|
+
return null;
|
|
10
|
+
return getConfigValueTyped(configValue, configName, type);
|
|
11
|
+
}
|
|
12
|
+
function getConfigValue(pageConfig, configName) {
|
|
13
|
+
const { configValueSources, configValuesComputed, configDefinitions } = pageConfig;
|
|
14
|
+
const configValueComputed = configValuesComputed[configName];
|
|
15
|
+
if (configValueComputed) {
|
|
16
|
+
return {
|
|
17
|
+
type: 'computed',
|
|
18
|
+
value: configValueComputed.value,
|
|
19
|
+
definedAtData: null
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
const sources = configValueSources[configName];
|
|
23
|
+
if (!sources)
|
|
24
|
+
return null;
|
|
25
|
+
assert(sources.every((s) => s.configEnv.config === true));
|
|
26
|
+
const configDef = configDefinitions[configName];
|
|
27
|
+
assert(configDef);
|
|
28
|
+
if (!configDef.cumulative) {
|
|
29
|
+
const configValueSource = sources[0];
|
|
30
|
+
assert(configValueSource);
|
|
31
|
+
assert(configValueSource.isOverriden === false);
|
|
32
|
+
assert(sources.slice(1).every((s) => s.isOverriden === true));
|
|
33
|
+
assert('value' in configValueSource);
|
|
34
|
+
return {
|
|
35
|
+
type: 'standard',
|
|
36
|
+
value: configValueSource.value,
|
|
37
|
+
definedAtData: getDefinedAtFile(configValueSource)
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
const { value, definedAtData } = mergeCumulative(sources);
|
|
42
|
+
assert(value.length === definedAtData.length);
|
|
43
|
+
return {
|
|
44
|
+
type: 'cumulative',
|
|
45
|
+
value,
|
|
46
|
+
definedAtData
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
function mergeCumulative(configValueSources) {
|
|
51
|
+
const value = [];
|
|
52
|
+
const definedAtData = [];
|
|
53
|
+
configValueSources.forEach((configValueSource) => {
|
|
54
|
+
assert(configValueSource.isOverriden === false);
|
|
55
|
+
assert(configValueSource.configEnv.config === true);
|
|
56
|
+
assert('value' in configValueSource);
|
|
57
|
+
value.push(configValueSource.value);
|
|
58
|
+
definedAtData.push(getDefinedAtFile(configValueSource));
|
|
59
|
+
});
|
|
60
|
+
return { value, definedAtData };
|
|
61
|
+
}
|
|
62
|
+
function getDefinedAtFile(configValueSource) {
|
|
63
|
+
return {
|
|
64
|
+
filePathToShowToUser: configValueSource.definedAtFilePath.filePathToShowToUser,
|
|
65
|
+
fileExportPathToShowToUser: configValueSource.definedAtFilePath.fileExportPathToShowToUser
|
|
66
|
+
};
|
|
67
|
+
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
export { loadConfigValues };
|
|
2
2
|
import { objectAssign } from '../utils.js';
|
|
3
|
-
import {
|
|
4
|
-
import { parseConfigValuesSerialized } from './serialize/parseConfigValuesSerialized.js';
|
|
3
|
+
import { parseConfigValuesSerialized } from './serialize/parsePageConfigs.js';
|
|
5
4
|
async function loadConfigValues(pageConfig, isDev) {
|
|
6
5
|
if ('isAllLoaded' in pageConfig &&
|
|
7
6
|
// We don't need to cache in dev, since Vite already caches the virtual module
|
|
@@ -9,16 +8,8 @@ async function loadConfigValues(pageConfig, isDev) {
|
|
|
9
8
|
return pageConfig;
|
|
10
9
|
}
|
|
11
10
|
const configValuesLoaded = await pageConfig.loadConfigValuesAll();
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const configValuesAddendum = parseConfigValuesImported(configValuesImported);
|
|
15
|
-
Object.assign(pageConfig.configValues, configValuesAddendum);
|
|
16
|
-
}
|
|
17
|
-
{
|
|
18
|
-
const { configValuesSerialized } = configValuesLoaded;
|
|
19
|
-
const configValuesAddendum = parseConfigValuesSerialized(configValuesSerialized);
|
|
20
|
-
Object.assign(pageConfig.configValues, configValuesAddendum);
|
|
21
|
-
}
|
|
11
|
+
const configValues = parseConfigValuesSerialized(configValuesLoaded.configValuesSerialized);
|
|
12
|
+
Object.assign(pageConfig.configValues, configValues);
|
|
22
13
|
objectAssign(pageConfig, { isAllLoaded: true });
|
|
23
14
|
return pageConfig;
|
|
24
15
|
}
|
|
@@ -1,35 +1,31 @@
|
|
|
1
1
|
export type { PageConfigRuntimeSerialized };
|
|
2
2
|
export type { PageConfigGlobalRuntimeSerialized };
|
|
3
3
|
export type { ConfigValueSerialized };
|
|
4
|
-
export type {
|
|
4
|
+
export type { ValueSerialized };
|
|
5
5
|
import type { ConfigValueStandard, ConfigValueComputed, ConfigValueCumulative, PageConfigRuntime } from '../PageConfig.js';
|
|
6
6
|
/** Page config data structure serialized in virtual files: parsing it results in PageConfigRuntime */
|
|
7
7
|
type PageConfigRuntimeSerialized = Omit<PageConfigRuntime, 'configValues'> & {
|
|
8
8
|
/** Config values that are serializable and loaded eagerly such as config.passToClient */
|
|
9
9
|
configValuesSerialized: Record<string, ConfigValueSerialized>;
|
|
10
|
-
/** Config values imported eagerly such as config.route */
|
|
11
|
-
configValuesImported: ConfigValueImported[];
|
|
12
10
|
};
|
|
13
11
|
type PageConfigGlobalRuntimeSerialized = {
|
|
14
|
-
|
|
12
|
+
configValuesSerialized: Record<string, ConfigValueSerialized>;
|
|
13
|
+
};
|
|
14
|
+
type ValueSerialized = {
|
|
15
|
+
type: 'js-serialized';
|
|
16
|
+
value: unknown;
|
|
17
|
+
} | {
|
|
18
|
+
type: 'plus-file';
|
|
19
|
+
exportValues: Record<string, unknown>;
|
|
20
|
+
} | {
|
|
21
|
+
type: 'pointer-import';
|
|
22
|
+
value: unknown;
|
|
15
23
|
};
|
|
16
24
|
/** Value is serialized */
|
|
17
25
|
type ConfigValueSerialized = (Omit<ConfigValueStandard, 'value'> & {
|
|
18
|
-
valueSerialized:
|
|
26
|
+
valueSerialized: ValueSerialized;
|
|
19
27
|
}) | (Omit<ConfigValueCumulative, 'value'> & {
|
|
20
|
-
valueSerialized:
|
|
28
|
+
valueSerialized: ValueSerialized[];
|
|
21
29
|
}) | (Omit<ConfigValueComputed, 'value'> & {
|
|
22
|
-
valueSerialized:
|
|
23
|
-
});
|
|
24
|
-
/** Value is imported */
|
|
25
|
-
type ConfigValueImported = {
|
|
26
|
-
configName: string;
|
|
27
|
-
importPath: string;
|
|
28
|
-
} & ({
|
|
29
|
-
isValueFile: true;
|
|
30
|
-
exportValues: Record<string, unknown>;
|
|
31
|
-
} | {
|
|
32
|
-
isValueFile: false;
|
|
33
|
-
exportName: string;
|
|
34
|
-
exportValue: unknown;
|
|
30
|
+
valueSerialized: ValueSerialized;
|
|
35
31
|
});
|
|
@@ -1,5 +1 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export { assertPageConfigGlobalSerialized };
|
|
3
|
-
import type { PageConfigGlobalRuntimeSerialized, PageConfigRuntimeSerialized } from './PageConfigSerialized.js';
|
|
4
|
-
declare function assertPageConfigsSerialized(pageConfigsSerialized: unknown): asserts pageConfigsSerialized is PageConfigRuntimeSerialized[];
|
|
5
|
-
declare function assertPageConfigGlobalSerialized(pageConfigGlobalSerialized: unknown): asserts pageConfigGlobalSerialized is PageConfigGlobalRuntimeSerialized;
|
|
1
|
+
export {};
|
|
@@ -1,16 +1 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export { assertPageConfigGlobalSerialized };
|
|
3
|
-
import { assert, isObject, hasProp, isArray } from '../../utils.js';
|
|
4
|
-
function assertPageConfigsSerialized(pageConfigsSerialized) {
|
|
5
|
-
assert(isArray(pageConfigsSerialized));
|
|
6
|
-
pageConfigsSerialized.forEach((pageConfigSerialized) => {
|
|
7
|
-
assert(isObject(pageConfigSerialized));
|
|
8
|
-
assert(hasProp(pageConfigSerialized, 'pageId', 'string'));
|
|
9
|
-
assert(hasProp(pageConfigSerialized, 'routeFilesystem'));
|
|
10
|
-
assert(hasProp(pageConfigSerialized, 'configValuesSerialized'));
|
|
11
|
-
assert(hasProp(pageConfigSerialized, 'configValuesImported'));
|
|
12
|
-
});
|
|
13
|
-
}
|
|
14
|
-
function assertPageConfigGlobalSerialized(pageConfigGlobalSerialized) {
|
|
15
|
-
assert(hasProp(pageConfigGlobalSerialized, 'configValuesImported'));
|
|
16
|
-
}
|
|
1
|
+
export {};
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
export { parsePageConfigs };
|
|
2
|
-
|
|
2
|
+
export { parseConfigValuesSerialized };
|
|
3
|
+
import type { ConfigValues, PageConfigRuntime, PageConfigGlobalRuntime } from '../PageConfig.js';
|
|
3
4
|
import type { PageConfigGlobalRuntimeSerialized, PageConfigRuntimeSerialized } from './PageConfigSerialized.js';
|
|
5
|
+
import type { ConfigValueSerialized } from './PageConfigSerialized.js';
|
|
6
|
+
declare function parseConfigValuesSerialized(configValuesSerialized: Record<string, ConfigValueSerialized>): ConfigValues;
|
|
4
7
|
declare function parsePageConfigs(pageConfigsSerialized: PageConfigRuntimeSerialized[], pageConfigGlobalSerialized: PageConfigGlobalRuntimeSerialized): {
|
|
5
8
|
pageConfigs: PageConfigRuntime[];
|
|
6
9
|
pageConfigGlobal: PageConfigGlobalRuntime;
|
|
@@ -1,21 +1,17 @@
|
|
|
1
1
|
export { parsePageConfigs };
|
|
2
|
-
|
|
2
|
+
export { parseConfigValuesSerialized };
|
|
3
3
|
import { assert, assertUsage, isCallable } from '../../utils.js';
|
|
4
4
|
import { getConfigDefinedAt } from '../getConfigDefinedAt.js';
|
|
5
|
-
import {
|
|
5
|
+
import { parseTransform } from '@brillout/json-serializer/parse';
|
|
6
|
+
import { assertPlusFileExport } from '../assertPlusFileExport.js';
|
|
7
|
+
function parseConfigValuesSerialized(configValuesSerialized) {
|
|
8
|
+
const configValues = parseConfigValuesSerialized_tmp(configValuesSerialized);
|
|
9
|
+
return configValues;
|
|
10
|
+
}
|
|
6
11
|
function parsePageConfigs(pageConfigsSerialized, pageConfigGlobalSerialized) {
|
|
12
|
+
// pageConfigs
|
|
7
13
|
const pageConfigs = pageConfigsSerialized.map((pageConfigSerialized) => {
|
|
8
|
-
const configValues =
|
|
9
|
-
{
|
|
10
|
-
const { configValuesSerialized } = pageConfigSerialized;
|
|
11
|
-
const configValuesAddendum = parseConfigValuesSerialized(configValuesSerialized);
|
|
12
|
-
Object.assign(configValues, configValuesAddendum);
|
|
13
|
-
}
|
|
14
|
-
{
|
|
15
|
-
const { configValuesImported } = pageConfigSerialized;
|
|
16
|
-
const configValuesAddendum = parseConfigValuesImported(configValuesImported);
|
|
17
|
-
Object.assign(configValues, configValuesAddendum);
|
|
18
|
-
}
|
|
14
|
+
const configValues = parseConfigValuesSerialized(pageConfigSerialized.configValuesSerialized);
|
|
19
15
|
const { pageId, isErrorPage, routeFilesystem, loadConfigValuesAll } = pageConfigSerialized;
|
|
20
16
|
assertRouteConfigValue(configValues);
|
|
21
17
|
return {
|
|
@@ -26,10 +22,11 @@ function parsePageConfigs(pageConfigsSerialized, pageConfigGlobalSerialized) {
|
|
|
26
22
|
loadConfigValuesAll
|
|
27
23
|
};
|
|
28
24
|
});
|
|
25
|
+
// pageConfigsGlobal
|
|
29
26
|
const pageConfigGlobal = { configValues: {} };
|
|
30
27
|
{
|
|
31
|
-
const
|
|
32
|
-
Object.assign(pageConfigGlobal.configValues,
|
|
28
|
+
const configValues = parseConfigValuesSerialized(pageConfigGlobalSerialized.configValuesSerialized);
|
|
29
|
+
Object.assign(pageConfigGlobal.configValues, configValues);
|
|
33
30
|
}
|
|
34
31
|
return { pageConfigs, pageConfigGlobal };
|
|
35
32
|
}
|
|
@@ -52,3 +49,100 @@ function assertRouteConfigValue(configValues) {
|
|
|
52
49
|
}
|
|
53
50
|
*/
|
|
54
51
|
}
|
|
52
|
+
function parseConfigValuesSerialized_tmp(configValuesSerialized) {
|
|
53
|
+
const configValues = {};
|
|
54
|
+
Object.entries(configValuesSerialized).forEach(([configName, configValueSeriliazed]) => {
|
|
55
|
+
let configValue;
|
|
56
|
+
if (configValueSeriliazed.type === 'cumulative') {
|
|
57
|
+
const { valueSerialized, ...common } = configValueSeriliazed;
|
|
58
|
+
const value = valueSerialized.map((valueSerializedElement, i) => {
|
|
59
|
+
const { value, sideExports } = parseValueSerialized(valueSerializedElement, configName, () => {
|
|
60
|
+
const definedAtFile = configValueSeriliazed.definedAtData[i];
|
|
61
|
+
assert(definedAtFile);
|
|
62
|
+
return definedAtFile;
|
|
63
|
+
});
|
|
64
|
+
addSideExports(sideExports);
|
|
65
|
+
return value;
|
|
66
|
+
});
|
|
67
|
+
configValue = { value, ...common };
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
const { valueSerialized, ...common } = configValueSeriliazed;
|
|
71
|
+
const { value, sideExports } = parseValueSerialized(valueSerialized, configName, () => {
|
|
72
|
+
assert(configValueSeriliazed.type !== 'computed');
|
|
73
|
+
return configValueSeriliazed.definedAtData;
|
|
74
|
+
});
|
|
75
|
+
addSideExports(sideExports);
|
|
76
|
+
configValue = { value, ...common };
|
|
77
|
+
}
|
|
78
|
+
configValues[configName] = configValue;
|
|
79
|
+
});
|
|
80
|
+
return configValues;
|
|
81
|
+
function addSideExports(sideExports) {
|
|
82
|
+
sideExports.forEach((sideExport) => {
|
|
83
|
+
const { configName, configValue } = sideExport;
|
|
84
|
+
if (!configValues[configName]) {
|
|
85
|
+
configValues[configName] = configValue;
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
// Side-exports have lower precedence.
|
|
89
|
+
// We can't avoid side-export conflicts upstream. (We cannot know about side-exports at build-time.)
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
function parseValueSerialized(valueSerialized, configName, getDefinedAtFile) {
|
|
95
|
+
if (valueSerialized.type === 'js-serialized') {
|
|
96
|
+
let { value } = valueSerialized;
|
|
97
|
+
value = parseTransform(value);
|
|
98
|
+
return { value, sideExports: [] };
|
|
99
|
+
}
|
|
100
|
+
if (valueSerialized.type === 'pointer-import') {
|
|
101
|
+
const { value } = valueSerialized;
|
|
102
|
+
return { value, sideExports: [] };
|
|
103
|
+
}
|
|
104
|
+
if (valueSerialized.type === 'plus-file') {
|
|
105
|
+
const definedAtFile = getDefinedAtFile();
|
|
106
|
+
const { exportValues } = valueSerialized;
|
|
107
|
+
assertPlusFileExport(exportValues, definedAtFile.filePathToShowToUser, configName);
|
|
108
|
+
let value;
|
|
109
|
+
let valueWasFound = false;
|
|
110
|
+
const sideExports = [];
|
|
111
|
+
Object.entries(exportValues).forEach(([exportName, exportValue]) => {
|
|
112
|
+
const isSideExport = exportName !== 'default' && exportName !== configName;
|
|
113
|
+
if (!isSideExport) {
|
|
114
|
+
value = exportValue;
|
|
115
|
+
assert(!valueWasFound);
|
|
116
|
+
valueWasFound = true;
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
sideExports.push({
|
|
120
|
+
configName: exportName,
|
|
121
|
+
configValue: {
|
|
122
|
+
type: 'standard', // We don't support side exports for cumulative values. We could support it but it isn't trivial.
|
|
123
|
+
value: exportValue,
|
|
124
|
+
definedAtData: {
|
|
125
|
+
filePathToShowToUser: definedAtFile.filePathToShowToUser,
|
|
126
|
+
fileExportPathToShowToUser: [exportName]
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
assert(valueWasFound);
|
|
133
|
+
return { value, sideExports };
|
|
134
|
+
}
|
|
135
|
+
assert(false);
|
|
136
|
+
}
|
|
137
|
+
/* [NULL_HANDLING] Do we really need this?
|
|
138
|
+
function assertIsNotNull(configValue: unknown, configName: string, filePathToShowToUser: string) {
|
|
139
|
+
assert(!filePathToShowToUser.includes('+config.'))
|
|
140
|
+
// Re-use this for:
|
|
141
|
+
// - upcoming config.requestPageContextOnNavigation
|
|
142
|
+
// - for cumulative values in the future: we don't need this for now because, currently, cumulative values are never imported.
|
|
143
|
+
assertUsage(
|
|
144
|
+
configValue !== null,
|
|
145
|
+
`Set ${pc.cyan(configName)} to ${pc.cyan('null')} in a +config.js file instead of ${filePathToShowToUser}`
|
|
146
|
+
)
|
|
147
|
+
}
|
|
148
|
+
*/
|
|
@@ -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[];
|