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
|
@@ -6,12 +6,16 @@ const analyzePageClientSide_js_1 = require("../../../shared/getPageFiles/analyze
|
|
|
6
6
|
const virtualFilePageConfigValuesAll_js_1 = require("../../shared/virtual-files/virtualFilePageConfigValuesAll.js");
|
|
7
7
|
const analyzeClientSide_js_1 = require("../../../shared/getPageFiles/analyzeClientSide.js");
|
|
8
8
|
const globalContext_js_1 = require("../globalContext.js");
|
|
9
|
-
const
|
|
9
|
+
const getConfigValue_js_1 = require("../../../shared/page-configs/getConfigValue.js");
|
|
10
10
|
function analyzePage(pageFilesAll, pageConfig, pageId) {
|
|
11
11
|
if (pageConfig) {
|
|
12
12
|
const { isClientSideRenderable, isClientRouting } = (0, analyzeClientSide_js_1.analyzeClientSide)(pageConfig, pageFilesAll, pageId);
|
|
13
|
-
const
|
|
14
|
-
const
|
|
13
|
+
const clientEntries = [];
|
|
14
|
+
const clientFilePath = (0, getConfigValue_js_1.getConfigValueRuntime)(pageConfig, 'client', 'string')?.value ?? null;
|
|
15
|
+
if (clientFilePath)
|
|
16
|
+
clientEntries.push(clientFilePath);
|
|
17
|
+
if (isClientSideRenderable)
|
|
18
|
+
clientEntries.push((0, determineClientEntry_js_1.getVikeClientEntry)(isClientRouting));
|
|
15
19
|
const clientDependencies = [];
|
|
16
20
|
clientDependencies.push({
|
|
17
21
|
id: (0, virtualFilePageConfigValuesAll_js_1.getVirtualFileIdPageConfigValuesAll)(pageConfig.pageId, true),
|
|
@@ -43,15 +47,13 @@ function analyzePage(pageFilesAll, pageConfig, pageId) {
|
|
|
43
47
|
}
|
|
44
48
|
})
|
|
45
49
|
*/
|
|
46
|
-
|
|
47
|
-
if (clientEntry) {
|
|
50
|
+
clientEntries.forEach((clientEntry) => {
|
|
48
51
|
clientDependencies.push({
|
|
49
52
|
id: clientEntry,
|
|
50
53
|
onlyAssets: false,
|
|
51
54
|
eagerlyImported: false
|
|
52
55
|
});
|
|
53
|
-
|
|
54
|
-
}
|
|
56
|
+
});
|
|
55
57
|
return {
|
|
56
58
|
isHtmlOnly: !isClientSideRenderable,
|
|
57
59
|
isClientRouting,
|
|
@@ -9,7 +9,7 @@ function getCacheControl(pageId, pageConfigs) {
|
|
|
9
9
|
if (pageConfigs.length === 0)
|
|
10
10
|
return defaultValue;
|
|
11
11
|
const pageConfig = (0, helpers_js_1.getPageConfig)(pageId, pageConfigs);
|
|
12
|
-
const configValue = (0, getConfigValue_js_1.
|
|
12
|
+
const configValue = (0, getConfigValue_js_1.getConfigValueRuntime)(pageConfig, 'cacheControl', 'string');
|
|
13
13
|
const value = configValue?.value;
|
|
14
14
|
if (value)
|
|
15
15
|
return value;
|
|
@@ -22,7 +22,6 @@ const executeGuardHook_js_1 = require("../../../shared/route/executeGuardHook.js
|
|
|
22
22
|
const loadPageRoutes_js_1 = require("../../../shared/route/loadPageRoutes.js");
|
|
23
23
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
24
24
|
const isServerSideError_js_1 = require("../../../shared/misc/isServerSideError.js");
|
|
25
|
-
const assertV1Design_js_1 = require("../../shared/assertV1Design.js");
|
|
26
25
|
async function renderPageAlreadyRouted(pageContext) {
|
|
27
26
|
// pageContext._pageId can either be the:
|
|
28
27
|
// - ID of the page matching the routing, or the
|
|
@@ -176,7 +175,8 @@ async function getRenderContext() {
|
|
|
176
175
|
const globalContext = (0, globalContext_js_1.getGlobalContext)();
|
|
177
176
|
const { pageFilesAll, allPageIds, pageConfigs, pageConfigGlobal } = await (0, getPageFiles_js_1.getPageFilesAll)(false, globalContext.isProduction);
|
|
178
177
|
const { pageRoutes, onBeforeRouteHook } = await (0, loadPageRoutes_js_1.loadPageRoutes)(pageFilesAll, pageConfigs, pageConfigGlobal, allPageIds);
|
|
179
|
-
|
|
178
|
+
// We assume assertV1Design() was already called at build-time
|
|
179
|
+
(0, utils_js_1.assert)(pageFilesAll.length === 0 || pageConfigs.length === 0);
|
|
180
180
|
const renderContext = {
|
|
181
181
|
pageFilesAll: pageFilesAll,
|
|
182
182
|
pageConfigs,
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.assertV1Design = void 0;
|
|
4
|
-
const helpers_js_1 = require("../../shared/page-configs/helpers.js");
|
|
5
4
|
const utils_js_1 = require("./utils.js");
|
|
6
5
|
function assertV1Design(isOldDesign, pageConfigs, pageFilesAll) {
|
|
7
6
|
const isV1Design = pageConfigs.length > 0;
|
|
@@ -11,10 +10,10 @@ function assertV1Design(isOldDesign, pageConfigs, pageFilesAll) {
|
|
|
11
10
|
(0, utils_js_1.assert)(pageFilesAll.length > 0);
|
|
12
11
|
const indent = '- ';
|
|
13
12
|
const filesV1 = (0, utils_js_1.unique)(pageConfigs
|
|
14
|
-
.map((p) => Object.values(p.
|
|
15
|
-
.map((c) =>
|
|
13
|
+
.map((p) => Object.values(p.configValueSources).map((sources) => sources
|
|
14
|
+
.map((c) => c.definedAtFilePath.filePathAbsoluteUserRootDir)
|
|
16
15
|
.filter(utils_js_1.isNotNullish)
|
|
17
|
-
.map((filePathToShowToUser) => indent + filePathToShowToUser))
|
|
16
|
+
.map((filePathToShowToUser) => indent + filePathToShowToUser)))
|
|
18
17
|
.flat(2));
|
|
19
18
|
const filesOld = pageFilesAll.map((p) => indent + p.filePath);
|
|
20
19
|
lines.push(...['V1 design files:', ...filesV1, 'Old design files:', ...filesOld]);
|
|
@@ -130,22 +130,24 @@ function assertPageContextUrlComputed(pageContext) {
|
|
|
130
130
|
```js
|
|
131
131
|
const PageContextUrlComputed = getPageContextUrlComputed(pageContext)
|
|
132
132
|
|
|
133
|
-
// ❌ Breaks the property getters of pageContext
|
|
133
|
+
// ❌ Breaks the property descriptors/getters of pageContext defined by getPageContextUrlComputed() such as pageContext.urlPathname
|
|
134
134
|
Object.assign(pageContext, pageContextUrlComputed)
|
|
135
135
|
|
|
136
|
-
// ❌ Also breaks property getters
|
|
136
|
+
// ❌ Also breaks property descriptors/getters
|
|
137
137
|
const pageContext = { ...pageContextUrlComputed }
|
|
138
138
|
|
|
139
|
-
// ✅ Preserves property getters
|
|
139
|
+
// ✅ Preserves property descriptors/getters (see objectAssign() implementation)
|
|
140
140
|
objectAssign(pageContext, pageContextUrlComputed)
|
|
141
141
|
```
|
|
142
142
|
*/
|
|
143
143
|
if ('urlPathname' in pageContext) {
|
|
144
144
|
(0, utils_js_1.assert)(typeof pageContext.urlPathname === 'string');
|
|
145
145
|
(0, utils_js_1.assert)((0, utils_js_1.isPropertyGetter)(pageContext, 'urlPathname'));
|
|
146
|
-
}
|
|
147
|
-
if ('urlParsed' in pageContext)
|
|
148
146
|
(0, utils_js_1.assert)((0, utils_js_1.isPropertyGetter)(pageContext, 'urlParsed'));
|
|
149
|
-
if ('url' in pageContext)
|
|
150
147
|
(0, utils_js_1.assert)((0, utils_js_1.isPropertyGetter)(pageContext, 'url'));
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
(0, utils_js_1.assert)(!('urlParsed' in pageContext));
|
|
151
|
+
(0, utils_js_1.assert)(!('url' in pageContext));
|
|
152
|
+
}
|
|
151
153
|
}
|
|
@@ -6,8 +6,8 @@ const analyzePageClientSide_js_1 = require("./analyzePageClientSide.js");
|
|
|
6
6
|
function analyzeClientSide(pageConfig, pageFilesAll, pageId) {
|
|
7
7
|
// V1 design
|
|
8
8
|
if (pageConfig) {
|
|
9
|
-
const isClientRouting = (0, getConfigValue_js_1.
|
|
10
|
-
const isClientSideRenderable = (0, getConfigValue_js_1.
|
|
9
|
+
const isClientRouting = (0, getConfigValue_js_1.getConfigValueRuntime)(pageConfig, 'clientRouting', 'boolean')?.value ?? false;
|
|
10
|
+
const isClientSideRenderable = (0, getConfigValue_js_1.getConfigValueRuntime)(pageConfig, 'isClientSideRenderable', 'boolean')?.value ?? false;
|
|
11
11
|
return { isClientSideRenderable, isClientRouting };
|
|
12
12
|
}
|
|
13
13
|
else {
|
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.parseGlobResults = void 0;
|
|
4
|
+
// TODO/v1-release: remove old design code, and remove all assertions.
|
|
4
5
|
const utils_js_1 = require("../utils.js");
|
|
5
6
|
const assert_exports_old_design_js_1 = require("./assert_exports_old_design.js");
|
|
6
7
|
const getPageFileObject_js_1 = require("./getPageFileObject.js");
|
|
7
8
|
const fileTypes_js_1 = require("./fileTypes.js");
|
|
8
|
-
const assertPageConfigsSerialized_js_1 = require("../page-configs/serialize/assertPageConfigsSerialized.js");
|
|
9
9
|
const parsePageConfigs_js_1 = require("../page-configs/serialize/parsePageConfigs.js");
|
|
10
10
|
function parseGlobResults(pageFilesExports) {
|
|
11
|
-
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(pageFilesExports, 'isGeneratedFile'));
|
|
12
|
-
(0, utils_js_1.assert)(pageFilesExports.isGeneratedFile !== false, `vike was re-installed(/re-built). Restart your app.`);
|
|
13
|
-
(0, utils_js_1.assert)(pageFilesExports.isGeneratedFile === true, `\`isGeneratedFile === ${pageFilesExports.isGeneratedFile}\``);
|
|
14
11
|
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(pageFilesExports, 'pageFilesLazy', 'object'));
|
|
15
12
|
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(pageFilesExports, 'pageFilesEager', 'object'));
|
|
16
13
|
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(pageFilesExports, 'pageFilesExportNamesLazy', 'object'));
|
|
@@ -21,8 +18,8 @@ function parseGlobResults(pageFilesExports) {
|
|
|
21
18
|
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(pageFilesExports, 'pageConfigsSerialized'));
|
|
22
19
|
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(pageFilesExports, 'pageConfigGlobalSerialized'));
|
|
23
20
|
const { pageConfigsSerialized, pageConfigGlobalSerialized } = pageFilesExports;
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
assertPageConfigsSerialized(pageConfigsSerialized);
|
|
22
|
+
assertPageConfigGlobalSerialized(pageConfigGlobalSerialized);
|
|
26
23
|
const { pageConfigs, pageConfigGlobal } = (0, parsePageConfigs_js_1.parsePageConfigs)(pageConfigsSerialized, pageConfigGlobalSerialized);
|
|
27
24
|
const pageFilesMap = {};
|
|
28
25
|
parseGlobResult(pageFilesExports.pageFilesLazy).forEach(({ filePath, pageFile, globValue }) => {
|
|
@@ -43,8 +40,6 @@ function parseGlobResults(pageFilesExports) {
|
|
|
43
40
|
pageFile.loadExportNames = async () => {
|
|
44
41
|
if (!('exportNames' in pageFile)) {
|
|
45
42
|
const moduleExports = await loadModule();
|
|
46
|
-
// Vite 2 seems to choke following assertion: https://github.com/vikejs/vike/issues/455
|
|
47
|
-
(0, utils_js_1.assertUsage)('exportNames' in moduleExports, 'You seem to be using Vite 2 but the latest vike versions only work with Vite 3');
|
|
48
43
|
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(moduleExports, 'exportNames', 'string[]'), pageFile.filePath);
|
|
49
44
|
pageFile.exportNames = moduleExports.exportNames;
|
|
50
45
|
}
|
|
@@ -91,3 +86,15 @@ function parseGlobResult(globObject) {
|
|
|
91
86
|
function assertLoadModule(globValue) {
|
|
92
87
|
(0, utils_js_1.assert)((0, utils_js_1.isCallable)(globValue));
|
|
93
88
|
}
|
|
89
|
+
function assertPageConfigsSerialized(pageConfigsSerialized) {
|
|
90
|
+
(0, utils_js_1.assert)((0, utils_js_1.isArray)(pageConfigsSerialized));
|
|
91
|
+
pageConfigsSerialized.forEach((pageConfigSerialized) => {
|
|
92
|
+
(0, utils_js_1.assert)((0, utils_js_1.isObject)(pageConfigSerialized));
|
|
93
|
+
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(pageConfigSerialized, 'pageId', 'string'));
|
|
94
|
+
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(pageConfigSerialized, 'routeFilesystem'));
|
|
95
|
+
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(pageConfigSerialized, 'configValuesSerialized'));
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
function assertPageConfigGlobalSerialized(pageConfigGlobalSerialized) {
|
|
99
|
+
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(pageConfigGlobalSerialized, 'configValuesSerialized'));
|
|
100
|
+
}
|
|
@@ -31,8 +31,8 @@ function getHook(pageContext, hookName) {
|
|
|
31
31
|
}
|
|
32
32
|
exports.getHook = getHook;
|
|
33
33
|
function getHookFromPageConfig(pageConfig, hookName) {
|
|
34
|
-
const configValue = (0, getConfigValue_js_1.
|
|
35
|
-
const hooksTimeout = (0, getConfigValue_js_1.
|
|
34
|
+
const configValue = (0, getConfigValue_js_1.getConfigValueRuntime)(pageConfig, hookName);
|
|
35
|
+
const hooksTimeout = (0, getConfigValue_js_1.getConfigValueRuntime)(pageConfig, 'hooksTimeout')?.value;
|
|
36
36
|
if (!configValue)
|
|
37
37
|
return null;
|
|
38
38
|
const hookFn = configValue.value;
|
|
@@ -3,22 +3,28 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.getConfigValueTyped = exports.getConfigValueRuntime = void 0;
|
|
7
7
|
const utils_js_1 = require("../utils.js");
|
|
8
8
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
9
9
|
const getConfigDefinedAt_js_1 = require("./getConfigDefinedAt.js");
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
return null;
|
|
10
|
+
function getConfigValueTyped(configValue, configName, type) {
|
|
11
|
+
/* [NULL_HANDLING] Do we really need this? This doesn't seem to make sense, let's eventually (re)move this.
|
|
12
|
+
// Enable users to suppress global config values by setting the local config value to null
|
|
13
|
+
if (configValue.value === null) return null
|
|
14
|
+
*/
|
|
16
15
|
const { value, definedAtData } = configValue;
|
|
17
16
|
if (type)
|
|
18
17
|
assertConfigValueType(value, type, configName, definedAtData);
|
|
19
18
|
return configValue;
|
|
20
19
|
}
|
|
21
|
-
exports.
|
|
20
|
+
exports.getConfigValueTyped = getConfigValueTyped;
|
|
21
|
+
function getConfigValueRuntime(pageConfig, configName, type) {
|
|
22
|
+
const configValue = pageConfig.configValues[configName];
|
|
23
|
+
if (!configValue)
|
|
24
|
+
return null;
|
|
25
|
+
return getConfigValueTyped(configValue, configName, type);
|
|
26
|
+
}
|
|
27
|
+
exports.getConfigValueRuntime = getConfigValueRuntime;
|
|
22
28
|
function assertConfigValueType(value, type, configName, definedAtData) {
|
|
23
29
|
(0, utils_js_1.assert)(value !== null);
|
|
24
30
|
const typeActual = typeof value;
|
|
@@ -32,12 +38,3 @@ function assertConfigValueType(value, type, configName, definedAtData) {
|
|
|
32
38
|
const errMsg = `${configDefinedAt} has an invalid ${problem}: it should be a ${picocolors_1.default.cyan(type)} instead`;
|
|
33
39
|
(0, utils_js_1.assertUsage)(false, errMsg);
|
|
34
40
|
}
|
|
35
|
-
function getConfigValueEntry(pageConfig, configName) {
|
|
36
|
-
const configValue = pageConfig.configValues[configName];
|
|
37
|
-
if (!configValue)
|
|
38
|
-
return null;
|
|
39
|
-
// Enable users to suppress global config values by setting the local config value to null
|
|
40
|
-
if (configValue.value === null)
|
|
41
|
-
return null;
|
|
42
|
-
return configValue;
|
|
43
|
-
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getConfigValueBuildTime = void 0;
|
|
4
|
+
const utils_js_1 = require("../utils.js");
|
|
5
|
+
const getConfigValue_js_1 = require("./getConfigValue.js");
|
|
6
|
+
const assertIsNotProductionRuntime_js_1 = require("../../utils/assertIsNotProductionRuntime.js");
|
|
7
|
+
(0, assertIsNotProductionRuntime_js_1.assertIsNotProductionRuntime)();
|
|
8
|
+
function getConfigValueBuildTime(pageConfig, configName, type) {
|
|
9
|
+
const configValue = getConfigValue(pageConfig, configName);
|
|
10
|
+
if (!configValue)
|
|
11
|
+
return null;
|
|
12
|
+
return (0, getConfigValue_js_1.getConfigValueTyped)(configValue, configName, type);
|
|
13
|
+
}
|
|
14
|
+
exports.getConfigValueBuildTime = getConfigValueBuildTime;
|
|
15
|
+
function getConfigValue(pageConfig, configName) {
|
|
16
|
+
const { configValueSources, configValuesComputed, configDefinitions } = pageConfig;
|
|
17
|
+
const configValueComputed = configValuesComputed[configName];
|
|
18
|
+
if (configValueComputed) {
|
|
19
|
+
return {
|
|
20
|
+
type: 'computed',
|
|
21
|
+
value: configValueComputed.value,
|
|
22
|
+
definedAtData: null
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
const sources = configValueSources[configName];
|
|
26
|
+
if (!sources)
|
|
27
|
+
return null;
|
|
28
|
+
(0, utils_js_1.assert)(sources.every((s) => s.configEnv.config === true));
|
|
29
|
+
const configDef = configDefinitions[configName];
|
|
30
|
+
(0, utils_js_1.assert)(configDef);
|
|
31
|
+
if (!configDef.cumulative) {
|
|
32
|
+
const configValueSource = sources[0];
|
|
33
|
+
(0, utils_js_1.assert)(configValueSource);
|
|
34
|
+
(0, utils_js_1.assert)(configValueSource.isOverriden === false);
|
|
35
|
+
(0, utils_js_1.assert)(sources.slice(1).every((s) => s.isOverriden === true));
|
|
36
|
+
(0, utils_js_1.assert)('value' in configValueSource);
|
|
37
|
+
return {
|
|
38
|
+
type: 'standard',
|
|
39
|
+
value: configValueSource.value,
|
|
40
|
+
definedAtData: getDefinedAtFile(configValueSource)
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
const { value, definedAtData } = mergeCumulative(sources);
|
|
45
|
+
(0, utils_js_1.assert)(value.length === definedAtData.length);
|
|
46
|
+
return {
|
|
47
|
+
type: 'cumulative',
|
|
48
|
+
value,
|
|
49
|
+
definedAtData
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
function mergeCumulative(configValueSources) {
|
|
54
|
+
const value = [];
|
|
55
|
+
const definedAtData = [];
|
|
56
|
+
configValueSources.forEach((configValueSource) => {
|
|
57
|
+
(0, utils_js_1.assert)(configValueSource.isOverriden === false);
|
|
58
|
+
(0, utils_js_1.assert)(configValueSource.configEnv.config === true);
|
|
59
|
+
(0, utils_js_1.assert)('value' in configValueSource);
|
|
60
|
+
value.push(configValueSource.value);
|
|
61
|
+
definedAtData.push(getDefinedAtFile(configValueSource));
|
|
62
|
+
});
|
|
63
|
+
return { value, definedAtData };
|
|
64
|
+
}
|
|
65
|
+
function getDefinedAtFile(configValueSource) {
|
|
66
|
+
return {
|
|
67
|
+
filePathToShowToUser: configValueSource.definedAtFilePath.filePathToShowToUser,
|
|
68
|
+
fileExportPathToShowToUser: configValueSource.definedAtFilePath.fileExportPathToShowToUser
|
|
69
|
+
};
|
|
70
|
+
}
|
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.loadConfigValues = void 0;
|
|
4
4
|
const utils_js_1 = require("../utils.js");
|
|
5
|
-
const
|
|
6
|
-
const parseConfigValuesSerialized_js_1 = require("./serialize/parseConfigValuesSerialized.js");
|
|
5
|
+
const parsePageConfigs_js_1 = require("./serialize/parsePageConfigs.js");
|
|
7
6
|
async function loadConfigValues(pageConfig, isDev) {
|
|
8
7
|
if ('isAllLoaded' in pageConfig &&
|
|
9
8
|
// We don't need to cache in dev, since Vite already caches the virtual module
|
|
@@ -11,16 +10,8 @@ async function loadConfigValues(pageConfig, isDev) {
|
|
|
11
10
|
return pageConfig;
|
|
12
11
|
}
|
|
13
12
|
const configValuesLoaded = await pageConfig.loadConfigValuesAll();
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const configValuesAddendum = (0, parseConfigValuesImported_js_1.parseConfigValuesImported)(configValuesImported);
|
|
17
|
-
Object.assign(pageConfig.configValues, configValuesAddendum);
|
|
18
|
-
}
|
|
19
|
-
{
|
|
20
|
-
const { configValuesSerialized } = configValuesLoaded;
|
|
21
|
-
const configValuesAddendum = (0, parseConfigValuesSerialized_js_1.parseConfigValuesSerialized)(configValuesSerialized);
|
|
22
|
-
Object.assign(pageConfig.configValues, configValuesAddendum);
|
|
23
|
-
}
|
|
13
|
+
const configValues = (0, parsePageConfigs_js_1.parseConfigValuesSerialized)(configValuesLoaded.configValuesSerialized);
|
|
14
|
+
Object.assign(pageConfig.configValues, configValues);
|
|
24
15
|
(0, utils_js_1.objectAssign)(pageConfig, { isAllLoaded: true });
|
|
25
16
|
return pageConfig;
|
|
26
17
|
}
|
|
@@ -1,19 +1 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.assertPageConfigGlobalSerialized = exports.assertPageConfigsSerialized = void 0;
|
|
4
|
-
const utils_js_1 = require("../../utils.js");
|
|
5
|
-
function assertPageConfigsSerialized(pageConfigsSerialized) {
|
|
6
|
-
(0, utils_js_1.assert)((0, utils_js_1.isArray)(pageConfigsSerialized));
|
|
7
|
-
pageConfigsSerialized.forEach((pageConfigSerialized) => {
|
|
8
|
-
(0, utils_js_1.assert)((0, utils_js_1.isObject)(pageConfigSerialized));
|
|
9
|
-
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(pageConfigSerialized, 'pageId', 'string'));
|
|
10
|
-
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(pageConfigSerialized, 'routeFilesystem'));
|
|
11
|
-
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(pageConfigSerialized, 'configValuesSerialized'));
|
|
12
|
-
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(pageConfigSerialized, 'configValuesImported'));
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
exports.assertPageConfigsSerialized = assertPageConfigsSerialized;
|
|
16
|
-
function assertPageConfigGlobalSerialized(pageConfigGlobalSerialized) {
|
|
17
|
-
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(pageConfigGlobalSerialized, 'configValuesImported'));
|
|
18
|
-
}
|
|
19
|
-
exports.assertPageConfigGlobalSerialized = assertPageConfigGlobalSerialized;
|
|
@@ -1,23 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parsePageConfigs = void 0;
|
|
4
|
-
const parseConfigValuesImported_js_1 = require("./parseConfigValuesImported.js");
|
|
3
|
+
exports.parseConfigValuesSerialized = exports.parsePageConfigs = void 0;
|
|
5
4
|
const utils_js_1 = require("../../utils.js");
|
|
6
5
|
const getConfigDefinedAt_js_1 = require("../getConfigDefinedAt.js");
|
|
7
|
-
const
|
|
6
|
+
const parse_1 = require("@brillout/json-serializer/parse");
|
|
7
|
+
const assertPlusFileExport_js_1 = require("../assertPlusFileExport.js");
|
|
8
|
+
function parseConfigValuesSerialized(configValuesSerialized) {
|
|
9
|
+
const configValues = parseConfigValuesSerialized_tmp(configValuesSerialized);
|
|
10
|
+
return configValues;
|
|
11
|
+
}
|
|
12
|
+
exports.parseConfigValuesSerialized = parseConfigValuesSerialized;
|
|
8
13
|
function parsePageConfigs(pageConfigsSerialized, pageConfigGlobalSerialized) {
|
|
14
|
+
// pageConfigs
|
|
9
15
|
const pageConfigs = pageConfigsSerialized.map((pageConfigSerialized) => {
|
|
10
|
-
const configValues =
|
|
11
|
-
{
|
|
12
|
-
const { configValuesSerialized } = pageConfigSerialized;
|
|
13
|
-
const configValuesAddendum = (0, parseConfigValuesSerialized_js_1.parseConfigValuesSerialized)(configValuesSerialized);
|
|
14
|
-
Object.assign(configValues, configValuesAddendum);
|
|
15
|
-
}
|
|
16
|
-
{
|
|
17
|
-
const { configValuesImported } = pageConfigSerialized;
|
|
18
|
-
const configValuesAddendum = (0, parseConfigValuesImported_js_1.parseConfigValuesImported)(configValuesImported);
|
|
19
|
-
Object.assign(configValues, configValuesAddendum);
|
|
20
|
-
}
|
|
16
|
+
const configValues = parseConfigValuesSerialized(pageConfigSerialized.configValuesSerialized);
|
|
21
17
|
const { pageId, isErrorPage, routeFilesystem, loadConfigValuesAll } = pageConfigSerialized;
|
|
22
18
|
assertRouteConfigValue(configValues);
|
|
23
19
|
return {
|
|
@@ -28,10 +24,11 @@ function parsePageConfigs(pageConfigsSerialized, pageConfigGlobalSerialized) {
|
|
|
28
24
|
loadConfigValuesAll
|
|
29
25
|
};
|
|
30
26
|
});
|
|
27
|
+
// pageConfigsGlobal
|
|
31
28
|
const pageConfigGlobal = { configValues: {} };
|
|
32
29
|
{
|
|
33
|
-
const
|
|
34
|
-
Object.assign(pageConfigGlobal.configValues,
|
|
30
|
+
const configValues = parseConfigValuesSerialized(pageConfigGlobalSerialized.configValuesSerialized);
|
|
31
|
+
Object.assign(pageConfigGlobal.configValues, configValues);
|
|
35
32
|
}
|
|
36
33
|
return { pageConfigs, pageConfigGlobal };
|
|
37
34
|
}
|
|
@@ -55,3 +52,100 @@ function assertRouteConfigValue(configValues) {
|
|
|
55
52
|
}
|
|
56
53
|
*/
|
|
57
54
|
}
|
|
55
|
+
function parseConfigValuesSerialized_tmp(configValuesSerialized) {
|
|
56
|
+
const configValues = {};
|
|
57
|
+
Object.entries(configValuesSerialized).forEach(([configName, configValueSeriliazed]) => {
|
|
58
|
+
let configValue;
|
|
59
|
+
if (configValueSeriliazed.type === 'cumulative') {
|
|
60
|
+
const { valueSerialized, ...common } = configValueSeriliazed;
|
|
61
|
+
const value = valueSerialized.map((valueSerializedElement, i) => {
|
|
62
|
+
const { value, sideExports } = parseValueSerialized(valueSerializedElement, configName, () => {
|
|
63
|
+
const definedAtFile = configValueSeriliazed.definedAtData[i];
|
|
64
|
+
(0, utils_js_1.assert)(definedAtFile);
|
|
65
|
+
return definedAtFile;
|
|
66
|
+
});
|
|
67
|
+
addSideExports(sideExports);
|
|
68
|
+
return value;
|
|
69
|
+
});
|
|
70
|
+
configValue = { value, ...common };
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
const { valueSerialized, ...common } = configValueSeriliazed;
|
|
74
|
+
const { value, sideExports } = parseValueSerialized(valueSerialized, configName, () => {
|
|
75
|
+
(0, utils_js_1.assert)(configValueSeriliazed.type !== 'computed');
|
|
76
|
+
return configValueSeriliazed.definedAtData;
|
|
77
|
+
});
|
|
78
|
+
addSideExports(sideExports);
|
|
79
|
+
configValue = { value, ...common };
|
|
80
|
+
}
|
|
81
|
+
configValues[configName] = configValue;
|
|
82
|
+
});
|
|
83
|
+
return configValues;
|
|
84
|
+
function addSideExports(sideExports) {
|
|
85
|
+
sideExports.forEach((sideExport) => {
|
|
86
|
+
const { configName, configValue } = sideExport;
|
|
87
|
+
if (!configValues[configName]) {
|
|
88
|
+
configValues[configName] = configValue;
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
// Side-exports have lower precedence.
|
|
92
|
+
// We can't avoid side-export conflicts upstream. (We cannot know about side-exports at build-time.)
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
function parseValueSerialized(valueSerialized, configName, getDefinedAtFile) {
|
|
98
|
+
if (valueSerialized.type === 'js-serialized') {
|
|
99
|
+
let { value } = valueSerialized;
|
|
100
|
+
value = (0, parse_1.parseTransform)(value);
|
|
101
|
+
return { value, sideExports: [] };
|
|
102
|
+
}
|
|
103
|
+
if (valueSerialized.type === 'pointer-import') {
|
|
104
|
+
const { value } = valueSerialized;
|
|
105
|
+
return { value, sideExports: [] };
|
|
106
|
+
}
|
|
107
|
+
if (valueSerialized.type === 'plus-file') {
|
|
108
|
+
const definedAtFile = getDefinedAtFile();
|
|
109
|
+
const { exportValues } = valueSerialized;
|
|
110
|
+
(0, assertPlusFileExport_js_1.assertPlusFileExport)(exportValues, definedAtFile.filePathToShowToUser, configName);
|
|
111
|
+
let value;
|
|
112
|
+
let valueWasFound = false;
|
|
113
|
+
const sideExports = [];
|
|
114
|
+
Object.entries(exportValues).forEach(([exportName, exportValue]) => {
|
|
115
|
+
const isSideExport = exportName !== 'default' && exportName !== configName;
|
|
116
|
+
if (!isSideExport) {
|
|
117
|
+
value = exportValue;
|
|
118
|
+
(0, utils_js_1.assert)(!valueWasFound);
|
|
119
|
+
valueWasFound = true;
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
sideExports.push({
|
|
123
|
+
configName: exportName,
|
|
124
|
+
configValue: {
|
|
125
|
+
type: 'standard', // We don't support side exports for cumulative values. We could support it but it isn't trivial.
|
|
126
|
+
value: exportValue,
|
|
127
|
+
definedAtData: {
|
|
128
|
+
filePathToShowToUser: definedAtFile.filePathToShowToUser,
|
|
129
|
+
fileExportPathToShowToUser: [exportName]
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
(0, utils_js_1.assert)(valueWasFound);
|
|
136
|
+
return { value, sideExports };
|
|
137
|
+
}
|
|
138
|
+
(0, utils_js_1.assert)(false);
|
|
139
|
+
}
|
|
140
|
+
/* [NULL_HANDLING] Do we really need this?
|
|
141
|
+
function assertIsNotNull(configValue: unknown, configName: string, filePathToShowToUser: string) {
|
|
142
|
+
assert(!filePathToShowToUser.includes('+config.'))
|
|
143
|
+
// Re-use this for:
|
|
144
|
+
// - upcoming config.requestPageContextOnNavigation
|
|
145
|
+
// - for cumulative values in the future: we don't need this for now because, currently, cumulative values are never imported.
|
|
146
|
+
assertUsage(
|
|
147
|
+
configValue !== null,
|
|
148
|
+
`Set ${pc.cyan(configName)} to ${pc.cyan('null')} in a +config.js file instead of ${filePathToShowToUser}`
|
|
149
|
+
)
|
|
150
|
+
}
|
|
151
|
+
*/
|