vike 0.4.220-commit-5c7810f → 0.4.220-commit-af5c91f
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/api/utils.js +1 -1
- package/dist/cjs/node/plugin/index.js +1 -1
- package/dist/cjs/node/plugin/onLoad.js +1 -1
- package/dist/cjs/node/plugin/plugins/buildConfig/fixServerAssets.js +5 -3
- package/dist/cjs/node/plugin/plugins/buildConfig.js +7 -5
- package/dist/cjs/node/plugin/plugins/buildEntry/index.js +2 -1
- package/dist/cjs/node/plugin/plugins/commonConfig.js +1 -2
- package/dist/cjs/node/plugin/plugins/extractAssetsPlugin.js +3 -2
- package/dist/cjs/node/plugin/plugins/extractExportNamesPlugin.js +2 -1
- package/dist/cjs/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.js +10 -8
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.js +32 -41
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolvePointerImport.js +9 -64
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js +11 -5
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +281 -313
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js +2 -1
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigs.js +7 -6
- package/dist/cjs/node/plugin/plugins/packageJsonFile.js +2 -2
- package/dist/cjs/node/plugin/plugins/previewConfig.js +4 -3
- package/dist/cjs/node/plugin/plugins/setGlobalContext.js +2 -1
- package/dist/cjs/node/plugin/shared/findPageFiles.js +2 -1
- package/dist/cjs/node/plugin/{getOutDirs.js → shared/getOutDirs.js} +24 -27
- package/dist/cjs/node/plugin/{resolveClientEntriesDev.js → shared/resolveClientEntriesDev.js} +5 -8
- package/dist/cjs/{utils → node/plugin/shared}/viteIsSSR.js +2 -2
- package/dist/cjs/node/plugin/utils.js +0 -1
- package/dist/cjs/node/prerender/context.js +8 -3
- package/dist/cjs/node/prerender/resolvePrerenderConfig.js +26 -5
- package/dist/cjs/node/prerender/runPrerender.js +6 -11
- package/dist/cjs/node/prerender/utils.js +1 -2
- package/dist/cjs/node/runtime/html/injectAssets/getHtmlTags.js +9 -4
- package/dist/cjs/node/runtime/renderPage/getEarlyHints.js +2 -27
- package/dist/cjs/node/runtime/renderPage/isFontFallback.js +29 -0
- package/dist/cjs/node/runtime/utils.js +1 -3
- package/dist/cjs/shared/getPageFiles/fileTypes.js +0 -1
- package/dist/cjs/shared/getPageFiles/getAllPageIdFiles.js +0 -3
- package/dist/cjs/shared/getPageFiles/getPageFileObject.js +0 -5
- package/dist/cjs/shared/page-configs/serialize/serializeConfigValues.js +69 -18
- package/dist/cjs/shared/utils.js +0 -1
- package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
- package/dist/cjs/utils/findFile.js +3 -3
- package/dist/cjs/utils/isDev.js +2 -5
- package/dist/cjs/utils/isFilePathAbsoluteFilesystem.js +2 -2
- package/dist/cjs/utils/path.js +48 -0
- package/dist/cjs/utils/requireResolve.js +3 -3
- package/dist/esm/node/api/utils.d.ts +1 -1
- package/dist/esm/node/api/utils.js +1 -1
- package/dist/esm/node/plugin/index.js +1 -1
- package/dist/esm/node/plugin/onLoad.js +1 -1
- package/dist/esm/node/plugin/plugins/buildConfig/fixServerAssets.js +3 -1
- package/dist/esm/node/plugin/plugins/buildConfig.js +3 -1
- package/dist/esm/node/plugin/plugins/buildEntry/index.js +2 -1
- package/dist/esm/node/plugin/plugins/commonConfig.js +2 -3
- package/dist/esm/node/plugin/plugins/extractAssetsPlugin.js +2 -1
- package/dist/esm/node/plugin/plugins/extractExportNamesPlugin.js +2 -1
- package/dist/esm/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.js +9 -7
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.d.ts +14 -11
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.js +35 -44
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolvePointerImport.d.ts +8 -18
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolvePointerImport.js +10 -65
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.d.ts +6 -2
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js +12 -6
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.d.ts +8 -6
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +284 -316
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js +2 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigs.js +7 -6
- package/dist/esm/node/plugin/plugins/packageJsonFile.js +1 -1
- package/dist/esm/node/plugin/plugins/previewConfig.js +2 -1
- package/dist/esm/node/plugin/plugins/setGlobalContext.js +2 -1
- package/dist/esm/node/plugin/shared/findPageFiles.js +2 -1
- package/dist/esm/node/plugin/{getOutDirs.js → shared/getOutDirs.js} +2 -5
- package/dist/esm/node/plugin/{resolveClientEntriesDev.js → shared/resolveClientEntriesDev.js} +5 -8
- package/dist/esm/{utils → node/plugin/shared}/viteIsSSR.js +2 -2
- package/dist/esm/node/plugin/utils.d.ts +0 -1
- package/dist/esm/node/plugin/utils.js +0 -1
- package/dist/esm/node/prerender/context.d.ts +2 -0
- package/dist/esm/node/prerender/context.js +8 -3
- package/dist/esm/node/prerender/resolvePrerenderConfig.d.ts +8 -1
- package/dist/esm/node/prerender/resolvePrerenderConfig.js +26 -5
- package/dist/esm/node/prerender/runPrerender.js +7 -12
- package/dist/esm/node/prerender/utils.d.ts +1 -2
- package/dist/esm/node/prerender/utils.js +1 -2
- package/dist/esm/node/runtime/html/injectAssets/getHtmlTags.js +9 -4
- package/dist/esm/node/runtime/renderPage/getEarlyHints.js +1 -26
- package/dist/esm/node/runtime/renderPage/getPageAssets.d.ts +1 -1
- package/dist/esm/node/runtime/renderPage/isFontFallback.d.ts +3 -0
- package/dist/esm/node/runtime/renderPage/isFontFallback.js +27 -0
- package/dist/esm/node/runtime/utils.d.ts +1 -3
- package/dist/esm/node/runtime/utils.js +1 -3
- package/dist/esm/shared/getPageFiles/fileTypes.js +1 -2
- package/dist/esm/shared/getPageFiles/getAllPageIdFiles.js +0 -3
- package/dist/esm/shared/getPageFiles/getPageFileObject.js +0 -5
- package/dist/esm/shared/page-configs/PageConfig.d.ts +0 -1
- package/dist/esm/shared/page-configs/serialize/serializeConfigValues.d.ts +7 -1
- package/dist/esm/shared/page-configs/serialize/serializeConfigValues.js +70 -19
- package/dist/esm/shared/utils.d.ts +0 -1
- package/dist/esm/shared/utils.js +0 -1
- package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
- package/dist/esm/utils/PROJECT_VERSION.js +1 -1
- package/dist/esm/utils/findFile.js +1 -1
- package/dist/esm/utils/isDev.js +3 -6
- package/dist/esm/utils/isFilePathAbsoluteFilesystem.js +1 -1
- package/dist/esm/utils/path.d.ts +14 -0
- package/dist/esm/utils/path.js +46 -0
- package/dist/esm/utils/projectInfo.d.ts +1 -1
- package/dist/esm/utils/requireResolve.js +1 -1
- package/package.json +1 -1
- package/dist/cjs/node/plugin/plugins/importUserCode/addImportStatement.js +0 -29
- package/dist/cjs/shared/assertPageFilePath.js +0 -11
- package/dist/cjs/utils/path-shim.js +0 -19
- package/dist/cjs/utils/toPosixPath.js +0 -18
- package/dist/esm/node/plugin/plugins/importUserCode/addImportStatement.d.ts +0 -14
- package/dist/esm/node/plugin/plugins/importUserCode/addImportStatement.js +0 -27
- package/dist/esm/shared/assertPageFilePath.d.ts +0 -2
- package/dist/esm/shared/assertPageFilePath.js +0 -9
- package/dist/esm/utils/path-shim.d.ts +0 -2
- package/dist/esm/utils/path-shim.js +0 -17
- package/dist/esm/utils/toPosixPath.d.ts +0 -4
- package/dist/esm/utils/toPosixPath.js +0 -16
- /package/dist/esm/node/plugin/{getOutDirs.d.ts → shared/getOutDirs.d.ts} +0 -0
- /package/dist/esm/node/plugin/{resolveClientEntriesDev.d.ts → shared/resolveClientEntriesDev.d.ts} +0 -0
- /package/dist/esm/{utils → node/plugin/shared}/viteIsSSR.d.ts +0 -0
package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js
CHANGED
|
@@ -31,9 +31,10 @@ async function getVirtualFilePageConfigValuesAll(id, isDev, config) {
|
|
|
31
31
|
function getLoadConfigValuesAll(pageConfig, isForClientSide, pageId, includeAssetsImportedByServer, isDev) {
|
|
32
32
|
const lines = [];
|
|
33
33
|
const importStatements = [];
|
|
34
|
+
const filesEnv = new Map();
|
|
34
35
|
const isClientRouting = getConfigValueBuildTime(pageConfig, 'clientRouting', 'boolean')?.value ?? false;
|
|
35
36
|
lines.push('export const configValuesSerialized = {');
|
|
36
|
-
lines.push(...serializeConfigValues(pageConfig, importStatements, (configEnv) => isRuntimeEnvMatch(configEnv, { isForClientSide, isClientRouting, isDev }), '', false));
|
|
37
|
+
lines.push(...serializeConfigValues(pageConfig, importStatements, filesEnv, (configEnv) => isRuntimeEnvMatch(configEnv, { isForClientSide, isClientRouting, isDev }), '', false));
|
|
37
38
|
lines.push('};');
|
|
38
39
|
if (!fixServerAssets_isEnabled() && includeAssetsImportedByServer && isForClientSide && !isDev) {
|
|
39
40
|
importStatements.push(`import '${extractAssetsAddQuery(getVirtualFileIdPageConfigValuesAll(pageId, false))}'`);
|
|
@@ -12,17 +12,18 @@ async function getVirtualFilePageConfigs(isForClientSide, isDev, id, isClientRou
|
|
|
12
12
|
function getCode(pageConfigs, pageConfigGlobal, isForClientSide, isDev, id, isClientRouting) {
|
|
13
13
|
const lines = [];
|
|
14
14
|
const importStatements = [];
|
|
15
|
+
const filesEnv = new Map();
|
|
15
16
|
lines.push('export const pageConfigsSerialized = [');
|
|
16
|
-
lines.push(getCodePageConfigsSerialized(pageConfigs, isForClientSide, isClientRouting, isDev, importStatements));
|
|
17
|
+
lines.push(getCodePageConfigsSerialized(pageConfigs, isForClientSide, isClientRouting, isDev, importStatements, filesEnv));
|
|
17
18
|
lines.push('];');
|
|
18
19
|
lines.push('export const pageConfigGlobalSerialized = {');
|
|
19
|
-
lines.push(getCodePageConfigGlobalSerialized(pageConfigGlobal, isForClientSide, isClientRouting, isDev, importStatements));
|
|
20
|
+
lines.push(getCodePageConfigGlobalSerialized(pageConfigGlobal, isForClientSide, isClientRouting, isDev, importStatements, filesEnv));
|
|
20
21
|
lines.push('};');
|
|
21
22
|
const code = [...importStatements, ...lines].join('\n');
|
|
22
23
|
debug(id, isForClientSide ? 'CLIENT-SIDE' : 'SERVER-SIDE', code);
|
|
23
24
|
return code;
|
|
24
25
|
}
|
|
25
|
-
function getCodePageConfigsSerialized(pageConfigs, isForClientSide, isClientRouting, isDev, importStatements) {
|
|
26
|
+
function getCodePageConfigsSerialized(pageConfigs, isForClientSide, isClientRouting, isDev, importStatements, filesEnv) {
|
|
26
27
|
const lines = [];
|
|
27
28
|
pageConfigs.forEach((pageConfig) => {
|
|
28
29
|
const { pageId, routeFilesystem, isErrorPage } = pageConfig;
|
|
@@ -34,17 +35,17 @@ function getCodePageConfigsSerialized(pageConfigs, isForClientSide, isClientRout
|
|
|
34
35
|
const load = `() => ({ moduleId: ${virtualFileId}, moduleExports: import(${virtualFileId}) })`;
|
|
35
36
|
lines.push(` loadConfigValuesAll: ${load},`);
|
|
36
37
|
lines.push(` configValuesSerialized: {`);
|
|
37
|
-
lines.push(...serializeConfigValues(pageConfig, importStatements, (configEnv) => isRuntimeEnvMatch(configEnv, { isForClientSide, isClientRouting, isDev }), ' ', true));
|
|
38
|
+
lines.push(...serializeConfigValues(pageConfig, importStatements, filesEnv, (configEnv) => isRuntimeEnvMatch(configEnv, { isForClientSide, isClientRouting, isDev }), ' ', true));
|
|
38
39
|
lines.push(` },`);
|
|
39
40
|
lines.push(` },`);
|
|
40
41
|
});
|
|
41
42
|
const code = lines.join('\n');
|
|
42
43
|
return code;
|
|
43
44
|
}
|
|
44
|
-
function getCodePageConfigGlobalSerialized(pageConfigGlobal, isForClientSide, isClientRouting, isDev, importStatements) {
|
|
45
|
+
function getCodePageConfigGlobalSerialized(pageConfigGlobal, isForClientSide, isClientRouting, isDev, importStatements, filesEnv) {
|
|
45
46
|
const lines = [];
|
|
46
47
|
lines.push(` configValuesSerialized: {`);
|
|
47
|
-
lines.push(...serializeConfigValues(pageConfigGlobal, importStatements, (configEnv) => isRuntimeEnvMatch(configEnv, { isForClientSide, isClientRouting, isDev }), ' ', null));
|
|
48
|
+
lines.push(...serializeConfigValues(pageConfigGlobal, importStatements, filesEnv, (configEnv) => isRuntimeEnvMatch(configEnv, { isForClientSide, isClientRouting, isDev }), ' ', null));
|
|
48
49
|
lines.push(` },`);
|
|
49
50
|
const code = lines.join('\n');
|
|
50
51
|
return code;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
export { previewConfig };
|
|
2
|
-
import { assertUsage,
|
|
2
|
+
import { assertUsage, applyPreview } from '../utils.js';
|
|
3
3
|
import fs from 'fs';
|
|
4
4
|
import path from 'path';
|
|
5
5
|
import { addSsrMiddleware } from '../shared/addSsrMiddleware.js';
|
|
6
6
|
import pc from '@brillout/picocolors';
|
|
7
7
|
import { logDockerHint } from './devConfig/index.js';
|
|
8
|
+
import { getOutDirs, resolveOutDir } from '../shared/getOutDirs.js';
|
|
8
9
|
function previewConfig() {
|
|
9
10
|
let config;
|
|
10
11
|
// let vikeConfig: VikeConfigObject
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export { setGlobalContext };
|
|
2
2
|
import { setGlobalContext_isViteDev, setGlobalContext_viteDevServer, setGlobalContext_viteConfig, setGlobalContext_vikeConfig } from '../../runtime/globalContext.js';
|
|
3
|
-
import { assertFilePathAbsoluteFilesystem,
|
|
3
|
+
import { assertFilePathAbsoluteFilesystem, isDevCheck, markSetup_isViteDev, markSetup_viteDevServer, markSetup_vitePreviewServer } from '../utils.js';
|
|
4
4
|
import { getVikeConfig } from './importUserCode/v1-design/getVikeConfig.js';
|
|
5
|
+
import { getOutDirs } from '../shared/getOutDirs.js';
|
|
5
6
|
function setGlobalContext() {
|
|
6
7
|
return [
|
|
7
8
|
{
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export { findPageFiles };
|
|
2
2
|
import glob from 'fast-glob';
|
|
3
|
-
import { assertWarning, toPosixPath, scriptFileExtensions
|
|
3
|
+
import { assertWarning, toPosixPath, scriptFileExtensions } from '../utils.js';
|
|
4
4
|
import pc from '@brillout/picocolors';
|
|
5
|
+
import { getOutDirs } from './getOutDirs.js';
|
|
5
6
|
async function findPageFiles(config, fileTypes, isDev) {
|
|
6
7
|
const cwd = config.root;
|
|
7
8
|
const { outDirRoot } = getOutDirs(config);
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
export { getOutDirs };
|
|
2
2
|
export { resolveOutDir };
|
|
3
|
-
import { viteIsSSR } from '../../utils/viteIsSSR.js';
|
|
4
|
-
import { assert, assertUsage } from '../../utils/assert.js';
|
|
5
|
-
import { pathJoin } from '../../utils/path-shim.js';
|
|
6
|
-
import { assertPosixPath, toPosixPath } from '../../utils/toPosixPath.js';
|
|
7
3
|
import pc from '@brillout/picocolors';
|
|
8
|
-
import { createDebugger } from '
|
|
4
|
+
import { assert, assertPosixPath, assertUsage, createDebugger, pathJoin, toPosixPath } from '../utils.js';
|
|
5
|
+
import { viteIsSSR } from './viteIsSSR.js';
|
|
9
6
|
const debug = createDebugger('vike:outDir');
|
|
10
7
|
function getOutDirs(config) {
|
|
11
8
|
debug('getOutDirs()', new Error().stack);
|
package/dist/esm/node/plugin/{resolveClientEntriesDev.js → shared/resolveClientEntriesDev.js}
RENAMED
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
export { resolveClientEntriesDev };
|
|
2
|
-
import { assert, assertPosixPath, toPosixPath, pathJoin, assertIsNpmPackageImport, assertIsNotProductionRuntime } from '
|
|
2
|
+
import { assert, assertPosixPath, toPosixPath, pathJoin, assertIsNpmPackageImport, assertIsNotProductionRuntime } from '../utils.js';
|
|
3
3
|
import { createRequire } from 'module';
|
|
4
|
-
import { dirname } from 'path';
|
|
5
|
-
import { fileURLToPath } from 'url';
|
|
6
4
|
// @ts-ignore Shimmed by dist-cjs-fixup.js for CJS build.
|
|
7
5
|
const importMetaUrl = import.meta.url;
|
|
8
6
|
const require_ = createRequire(importMetaUrl);
|
|
9
|
-
const __dirname_ = dirname(fileURLToPath(importMetaUrl));
|
|
10
7
|
assertIsNotProductionRuntime();
|
|
11
8
|
async function resolveClientEntriesDev(clientEntry, viteDevServer) {
|
|
12
9
|
let root = viteDevServer.config.root;
|
|
@@ -32,13 +29,13 @@ async function resolveClientEntriesDev(clientEntry, viteDevServer) {
|
|
|
32
29
|
assert(clientEntry.endsWith('.js'));
|
|
33
30
|
try {
|
|
34
31
|
// For Vitest (which doesn't resolve vike to its dist but to its source files)
|
|
35
|
-
// [RELATIVE_PATH_FROM_DIST] Current file: node_modules/vike/node/plugin/resolveClientEntriesDev.js
|
|
36
|
-
filePath = toPosixPath(require_.resolve(clientEntry.replace('@@vike/dist/esm/client/', '
|
|
32
|
+
// [RELATIVE_PATH_FROM_DIST] Current file: node_modules/vike/node/plugin/shared/resolveClientEntriesDev.js
|
|
33
|
+
filePath = toPosixPath(require_.resolve(clientEntry.replace('@@vike/dist/esm/client/', '../../../client/').replace('.js', '.ts')));
|
|
37
34
|
}
|
|
38
35
|
catch {
|
|
39
36
|
// For users
|
|
40
|
-
// [RELATIVE_PATH_FROM_DIST] Current file: node_modules/vike/dist/esm/node/plugin/resolveClientEntriesDev.js
|
|
41
|
-
filePath = toPosixPath(require_.resolve(clientEntry.replace('@@vike/dist/esm/client/', '
|
|
37
|
+
// [RELATIVE_PATH_FROM_DIST] Current file: node_modules/vike/dist/esm/node/plugin/shared/resolveClientEntriesDev.js
|
|
38
|
+
filePath = toPosixPath(require_.resolve(clientEntry.replace('@@vike/dist/esm/client/', '../../../../../dist/esm/client/')));
|
|
42
39
|
}
|
|
43
40
|
}
|
|
44
41
|
else {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { assert } from '
|
|
2
|
-
import { isObject } from '
|
|
1
|
+
import { assert } from '../../../utils/assert.js';
|
|
2
|
+
import { isObject } from '../../../utils/isObject.js';
|
|
3
3
|
export { viteIsSSR };
|
|
4
4
|
export { viteIsSSR_options };
|
|
5
5
|
function viteIsSSR(config) {
|
|
@@ -5,7 +5,6 @@ onLoad();
|
|
|
5
5
|
// It's common practice for Vike's Vite plugin to import from Vike's sever runtime
|
|
6
6
|
export * from '../runtime/utils.js';
|
|
7
7
|
// Utils only needed by `plugin/*`
|
|
8
|
-
export * from '../../utils/viteIsSSR.js';
|
|
9
8
|
export * from '../../utils/requireResolve.js';
|
|
10
9
|
export * from '../../utils/includes.js';
|
|
11
10
|
export * from '../../utils/isDev.js';
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
export { isPrerenderEnabled };
|
|
1
2
|
export { isPrerenderAutoRunEnabled };
|
|
2
3
|
export { temp_disablePrerenderAutoRun };
|
|
3
4
|
export { isPrerendering };
|
|
4
5
|
export { setContextIsPrerendering };
|
|
5
6
|
import type { VikeConfigObject } from '../plugin/plugins/importUserCode/v1-design/getVikeConfig.js';
|
|
7
|
+
declare function isPrerenderEnabled(vikeConfig: VikeConfigObject): boolean;
|
|
6
8
|
declare function isPrerenderAutoRunEnabled(vikeConfig: VikeConfigObject): boolean;
|
|
7
9
|
declare function temp_disablePrerenderAutoRun(): void;
|
|
8
10
|
declare function isPrerendering(): boolean;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export { isPrerenderEnabled };
|
|
1
2
|
export { isPrerenderAutoRunEnabled };
|
|
2
3
|
export { temp_disablePrerenderAutoRun };
|
|
3
4
|
export { isPrerendering };
|
|
@@ -5,10 +6,14 @@ export { setContextIsPrerendering };
|
|
|
5
6
|
import { getGlobalObject } from '../../utils/getGlobalObject.js';
|
|
6
7
|
import { resolvePrerenderConfig } from './resolvePrerenderConfig.js';
|
|
7
8
|
const globalObject = getGlobalObject('prerender/context.ts', {});
|
|
9
|
+
function isPrerenderEnabled(vikeConfig) {
|
|
10
|
+
const prerenderConfig = resolvePrerenderConfig(vikeConfig);
|
|
11
|
+
return !!prerenderConfig;
|
|
12
|
+
}
|
|
8
13
|
function isPrerenderAutoRunEnabled(vikeConfig) {
|
|
9
|
-
const prerenderConfig = resolvePrerenderConfig(vikeConfig
|
|
10
|
-
return (
|
|
11
|
-
!prerenderConfig.disableAutoRun &&
|
|
14
|
+
const prerenderConfig = resolvePrerenderConfig(vikeConfig);
|
|
15
|
+
return (isPrerenderEnabled(vikeConfig) &&
|
|
16
|
+
!(prerenderConfig || {}).disableAutoRun &&
|
|
12
17
|
!globalObject.isDisabled &&
|
|
13
18
|
vikeConfig.global.config.disableAutoFullBuild !== 'prerender');
|
|
14
19
|
}
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
export { resolvePrerenderConfig };
|
|
2
|
+
export { resolvePrerenderConfigLocal };
|
|
2
3
|
import type { ConfigResolved } from '../../shared/page-configs/Config/PageContextConfig.js';
|
|
4
|
+
import { VikeConfigObject } from '../plugin/plugins/importUserCode/v1-design/getVikeConfig.js';
|
|
5
|
+
import type { PageConfigBuildTime } from '../../shared/page-configs/PageConfig.js';
|
|
3
6
|
type PrerenderConfigSemiResolved = ConfigResolved['prerender'];
|
|
4
7
|
type PrerenderConfig = false | Exclude<Required<NonNullable<PrerenderConfigSemiResolved>[number]>, boolean>;
|
|
5
|
-
declare function resolvePrerenderConfig(
|
|
8
|
+
declare function resolvePrerenderConfig(vikeConfig: VikeConfigObject): PrerenderConfig;
|
|
9
|
+
declare function resolvePrerenderConfigLocal(pageConfig: PageConfigBuildTime): {
|
|
10
|
+
value: boolean;
|
|
11
|
+
configValueFilePathToShowToUser: string;
|
|
12
|
+
} | null;
|
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
export { resolvePrerenderConfig };
|
|
2
|
+
export { resolvePrerenderConfigLocal };
|
|
3
|
+
import { assert, isArray } from './utils.js';
|
|
4
|
+
import { getConfigValueBuildTime } from '../../shared/page-configs/getConfigValueBuildTime.js';
|
|
5
|
+
import { getConfigValueFilePathToShowToUser } from '../../shared/page-configs/helpers.js';
|
|
2
6
|
// TODO/now:
|
|
3
7
|
// - prerender.value
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
if (!prerenderConfigs
|
|
8
|
+
function resolvePrerenderConfig(vikeConfig) {
|
|
9
|
+
const prerenderConfigs = vikeConfig.global.config.prerender;
|
|
10
|
+
if (!prerenderConfigs &&
|
|
11
|
+
!vikeConfig.pageConfigs.some((pageConfig) => resolvePrerenderConfigLocal(pageConfig)?.value)) {
|
|
7
12
|
return false;
|
|
8
13
|
}
|
|
9
|
-
|
|
14
|
+
let prerenderSettings = prerenderConfigs || [];
|
|
15
|
+
// Needed because of backwards compatibility of `vike({prerender:true})` in `vite.config.js`; after we remove it we can remove this line.
|
|
16
|
+
prerenderSettings = prerenderSettings.filter(isObject2);
|
|
17
|
+
assert(prerenderSettings.every(isObject2));
|
|
10
18
|
const prerenderConfig = {
|
|
11
19
|
partial: pickFirst(prerenderSettings.map((c) => c.partial)) ?? false,
|
|
12
20
|
noExtraDir: pickFirst(prerenderSettings.map((c) => c.noExtraDir)) ?? false,
|
|
@@ -15,8 +23,21 @@ function resolvePrerenderConfig(prerenderConfigs) {
|
|
|
15
23
|
};
|
|
16
24
|
return prerenderConfig;
|
|
17
25
|
}
|
|
26
|
+
function resolvePrerenderConfigLocal(pageConfig) {
|
|
27
|
+
const configValue = getConfigValueBuildTime(pageConfig, 'prerender');
|
|
28
|
+
if (!configValue)
|
|
29
|
+
return null;
|
|
30
|
+
const values = configValue.value;
|
|
31
|
+
assert(isArray(values));
|
|
32
|
+
const value = values[0];
|
|
33
|
+
assert(typeof value === 'boolean');
|
|
34
|
+
assert(isArray(configValue.definedAtData));
|
|
35
|
+
const configValueFilePathToShowToUser = getConfigValueFilePathToShowToUser(configValue.definedAtData[0]);
|
|
36
|
+
assert(configValueFilePathToShowToUser);
|
|
37
|
+
return { value, configValueFilePathToShowToUser };
|
|
38
|
+
}
|
|
18
39
|
function isObject2(p) {
|
|
19
|
-
return typeof p === 'object';
|
|
40
|
+
return typeof p === 'object' && p !== null;
|
|
20
41
|
}
|
|
21
42
|
function pickFirst(arr) {
|
|
22
43
|
return arr.filter((v) => v !== undefined)[0];
|
|
@@ -4,7 +4,7 @@ export { runPrerenderFromAutoRun };
|
|
|
4
4
|
export { runPrerender_forceExit };
|
|
5
5
|
import path from 'path';
|
|
6
6
|
import { route } from '../../shared/route/index.js';
|
|
7
|
-
import { assert, assertUsage, assertWarning, hasProp, projectInfo, objectAssign, isObjectWithKeys, isCallable,
|
|
7
|
+
import { assert, assertUsage, assertWarning, hasProp, projectInfo, objectAssign, isObjectWithKeys, isCallable, isPropertyGetter, assertPosixPath, urlToFile, isPlainObject, pLimit, isArray, changeEnumerable, onSetupPrerender, isObject, makePublicCopy } from './utils.js';
|
|
8
8
|
import { prerenderPage, prerender404Page, getPageContextInitEnhanced } from '../runtime/renderPage/renderPageAlreadyRouted.js';
|
|
9
9
|
import pc from '@brillout/picocolors';
|
|
10
10
|
import { cpus } from 'os';
|
|
@@ -13,7 +13,6 @@ import { resolveConfig } from 'vite';
|
|
|
13
13
|
import { getPageFilesServerSide } from '../../shared/getPageFiles.js';
|
|
14
14
|
import { getPageContextRequestUrl } from '../../shared/getPageContextRequestUrl.js';
|
|
15
15
|
import { getUrlFromRouteString } from '../../shared/route/resolveRouteString.js';
|
|
16
|
-
import { getConfigValueFilePathToShowToUser } from '../../shared/page-configs/helpers.js';
|
|
17
16
|
import { getConfigValueRuntime } from '../../shared/page-configs/getConfigValueRuntime.js';
|
|
18
17
|
import { loadConfigValues } from '../../shared/page-configs/loadConfigValues.js';
|
|
19
18
|
import { isErrorPage } from '../../shared/error-page.js';
|
|
@@ -25,10 +24,10 @@ import { noRouteMatch } from '../../shared/route/noRouteMatch.js';
|
|
|
25
24
|
import { getVikeConfig } from '../plugin/plugins/importUserCode/v1-design/getVikeConfig.js';
|
|
26
25
|
import { logErrorHint } from '../runtime/renderPage/logErrorHint.js';
|
|
27
26
|
import { executeHook, isUserHookError } from '../../shared/hooks/executeHook.js';
|
|
28
|
-
import { getConfigValueBuildTime } from '../../shared/page-configs/getConfigValueBuildTime.js';
|
|
29
27
|
import { prepareViteApiCall } from '../api/prepareViteApiCall.js';
|
|
30
28
|
import { setContextIsPrerendering } from './context.js';
|
|
31
|
-
import { resolvePrerenderConfig } from './resolvePrerenderConfig.js';
|
|
29
|
+
import { resolvePrerenderConfig, resolvePrerenderConfigLocal } from './resolvePrerenderConfig.js';
|
|
30
|
+
import { getOutDirs } from '../plugin/shared/getOutDirs.js';
|
|
32
31
|
async function runPrerenderFromAPI(options = {}) {
|
|
33
32
|
return await runPrerender(options, 'prerender()');
|
|
34
33
|
// - We purposely propagate the error to the user land, so that the error interrupts the user land. It's also, I guess, a nice-to-have that the user has control over the error.
|
|
@@ -75,7 +74,7 @@ async function runPrerender(options = {}, standaloneTrigger) {
|
|
|
75
74
|
const vikeConfig = await getVikeConfig(viteConfig);
|
|
76
75
|
const { outDirClient } = getOutDirs(viteConfig);
|
|
77
76
|
const { root } = viteConfig;
|
|
78
|
-
const prerenderConfig = resolvePrerenderConfig(vikeConfig
|
|
77
|
+
const prerenderConfig = resolvePrerenderConfig(vikeConfig);
|
|
79
78
|
validatePrerenderConfig(prerenderConfig);
|
|
80
79
|
if (!prerenderConfig) {
|
|
81
80
|
assert(standaloneTrigger);
|
|
@@ -122,15 +121,11 @@ async function runPrerender(options = {}, standaloneTrigger) {
|
|
|
122
121
|
async function collectDoNoPrerenderList(pageConfigs, doNotPrerenderList, concurrencyLimit) {
|
|
123
122
|
// V1 design
|
|
124
123
|
pageConfigs.forEach((pageConfig) => {
|
|
125
|
-
const
|
|
126
|
-
const configValue = getConfigValueBuildTime(pageConfig, configName);
|
|
124
|
+
const configValue = resolvePrerenderConfigLocal(pageConfig);
|
|
127
125
|
if (!configValue)
|
|
128
126
|
return;
|
|
129
|
-
|
|
130
|
-
if (
|
|
131
|
-
assert(isArray(configValue.definedAtData));
|
|
132
|
-
const configValueFilePathToShowToUser = getConfigValueFilePathToShowToUser(configValue.definedAtData[0]);
|
|
133
|
-
assert(configValueFilePathToShowToUser);
|
|
127
|
+
const { value, configValueFilePathToShowToUser } = configValue;
|
|
128
|
+
if (value === false) {
|
|
134
129
|
doNotPrerenderList.push({
|
|
135
130
|
pageId: pageConfig.pageId,
|
|
136
131
|
setByConfigName: 'prerender',
|
|
@@ -4,9 +4,8 @@ export * from '../../utils/projectInfo.js';
|
|
|
4
4
|
export * from '../../utils/objectAssign.js';
|
|
5
5
|
export * from '../../utils/isObjectWithKeys.js';
|
|
6
6
|
export * from '../../utils/isCallable.js';
|
|
7
|
-
export * from '../plugin/getOutDirs.js';
|
|
8
7
|
export * from '../../utils/isPropertyGetter.js';
|
|
9
|
-
export * from '../../utils/
|
|
8
|
+
export * from '../../utils/path.js';
|
|
10
9
|
export * from '../../utils/urlToFile.js';
|
|
11
10
|
export * from '../../utils/isPlainObject.js';
|
|
12
11
|
export * from '../../utils/assertSetup.js';
|
|
@@ -6,9 +6,8 @@ export * from '../../utils/projectInfo.js';
|
|
|
6
6
|
export * from '../../utils/objectAssign.js';
|
|
7
7
|
export * from '../../utils/isObjectWithKeys.js';
|
|
8
8
|
export * from '../../utils/isCallable.js';
|
|
9
|
-
export * from '../plugin/getOutDirs.js';
|
|
10
9
|
export * from '../../utils/isPropertyGetter.js';
|
|
11
|
-
export * from '../../utils/
|
|
10
|
+
export * from '../../utils/path.js';
|
|
12
11
|
export * from '../../utils/urlToFile.js';
|
|
13
12
|
export * from '../../utils/isPlainObject.js';
|
|
14
13
|
export * from '../../utils/assertSetup.js';
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isFontFallback } from '../../renderPage/isFontFallback.js';
|
|
1
2
|
export { getHtmlTags };
|
|
2
3
|
import { assert, assertWarning, assertUsage, isObject, freezePartial } from '../../utils.js';
|
|
3
4
|
import { serializePageContextClientSide } from '../serializePageContextClientSide.js';
|
|
@@ -15,7 +16,8 @@ function getHtmlTags(pageContext, streamFromReactStreamingPackage, injectFilter,
|
|
|
15
16
|
const isHtmlOnly = pageContext._isHtmlOnly;
|
|
16
17
|
const { isProduction } = getGlobalContext();
|
|
17
18
|
const injectScriptsAt = getInjectScriptsAt(pageContext.pageId, pageContext._pageConfigs);
|
|
18
|
-
const injectFilterEntries =
|
|
19
|
+
const injectFilterEntries = [];
|
|
20
|
+
pageAssets
|
|
19
21
|
.filter((asset) => {
|
|
20
22
|
if (asset.isEntry && asset.assetType === 'script') {
|
|
21
23
|
// We could allow the user to change the position of <script> but we currently don't:
|
|
@@ -26,15 +28,18 @@ function getHtmlTags(pageContext, streamFromReactStreamingPackage, injectFilter,
|
|
|
26
28
|
}
|
|
27
29
|
return true;
|
|
28
30
|
})
|
|
29
|
-
.
|
|
31
|
+
.forEach((asset) => {
|
|
30
32
|
const inject = (() => {
|
|
31
33
|
if (!isProduction) {
|
|
32
34
|
// In development, we should always load assets as soon as possible, in order to eagerly process assets (e.g. applying the transform() hooks of Vite plugins) which are lazily discovered.
|
|
33
35
|
return 'HTML_BEGIN';
|
|
34
36
|
}
|
|
35
|
-
if (asset.assetType === 'style'
|
|
37
|
+
if (asset.assetType === 'style') {
|
|
36
38
|
return 'HTML_BEGIN';
|
|
37
39
|
}
|
|
40
|
+
if (asset.assetType === 'font') {
|
|
41
|
+
return !isFontFallback(asset, injectFilterEntries) ? 'HTML_BEGIN' : false;
|
|
42
|
+
}
|
|
38
43
|
if (asset.assetType === 'script') {
|
|
39
44
|
if (isHtmlOnly)
|
|
40
45
|
return false;
|
|
@@ -48,7 +53,7 @@ function getHtmlTags(pageContext, streamFromReactStreamingPackage, injectFilter,
|
|
|
48
53
|
// @ts-ignore
|
|
49
54
|
[stamp]: true
|
|
50
55
|
};
|
|
51
|
-
|
|
56
|
+
injectFilterEntries.push(entry);
|
|
52
57
|
});
|
|
53
58
|
assertInjectFilterEntries(injectFilterEntries);
|
|
54
59
|
// ==============
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { getEarlyHints };
|
|
2
|
+
import { isFontFallback } from './isFontFallback.js';
|
|
2
3
|
import { inferEarlyHintLink } from '../html/injectAssets/inferHtmlTags.js';
|
|
3
|
-
import { assert } from '../utils.js';
|
|
4
4
|
function getEarlyHints(assets) {
|
|
5
5
|
const earlyHints = [];
|
|
6
6
|
{
|
|
@@ -16,28 +16,3 @@ function getEarlyHints(assets) {
|
|
|
16
16
|
}
|
|
17
17
|
return earlyHints;
|
|
18
18
|
}
|
|
19
|
-
function isFontFallback(asset, earlyHints) {
|
|
20
|
-
if (asset.assetType !== 'font') {
|
|
21
|
-
return false;
|
|
22
|
-
}
|
|
23
|
-
const fontUrlBase = removeFileExtentionAndHash(asset.src);
|
|
24
|
-
return earlyHints.some((hint) => {
|
|
25
|
-
return hint.assetType === 'font' && removeFileExtentionAndHash(hint.src) === fontUrlBase;
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
function removeFileExtentionAndHash(assetUrl) {
|
|
29
|
-
assert(!assetUrl.includes('\\'));
|
|
30
|
-
// The logic below doesn't work for '/assets/chunk-0e184ced.js'
|
|
31
|
-
assert(!assetUrl.endsWith('.js'));
|
|
32
|
-
const paths = assetUrl.split('/');
|
|
33
|
-
{
|
|
34
|
-
const filename = paths[paths.length - 1];
|
|
35
|
-
const filenameParts = filename.split('.');
|
|
36
|
-
assert(filenameParts.length >= 2);
|
|
37
|
-
// User may set config.build.rollupOptions.output.assetFileNames => we can't assume the filename to be `*.${hash}.${ext}`
|
|
38
|
-
const filenameBase = filenameParts.slice(0, filenameParts.length === 2 ? -1 : -2);
|
|
39
|
-
assert(filenameBase.length >= 1);
|
|
40
|
-
paths[paths.length - 1] = filenameBase.join('.');
|
|
41
|
-
}
|
|
42
|
-
return paths.join('/');
|
|
43
|
-
}
|
|
@@ -5,7 +5,7 @@ export type { GetPageAssets };
|
|
|
5
5
|
export type { PageContextGetPageAssets };
|
|
6
6
|
import { type MediaType } from './inferMediaType.js';
|
|
7
7
|
import type { ClientDependency } from '../../../shared/getPageFiles/analyzePageClientSide/ClientDependency.js';
|
|
8
|
-
import type { ResolveClientEntriesDev } from '../../plugin/resolveClientEntriesDev.js';
|
|
8
|
+
import type { ResolveClientEntriesDev } from '../../plugin/shared/resolveClientEntriesDev.js';
|
|
9
9
|
type PageAsset = {
|
|
10
10
|
src: string;
|
|
11
11
|
assetType: null | NonNullable<MediaType>['assetType'];
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export { isFontFallback };
|
|
2
|
+
import { assert } from '../../../utils/assert.js';
|
|
3
|
+
function isFontFallback(asset, pageAssets) {
|
|
4
|
+
if (asset.assetType !== 'font') {
|
|
5
|
+
return false;
|
|
6
|
+
}
|
|
7
|
+
const fontUrlBase = removeFileExtentionAndHash(asset.src);
|
|
8
|
+
return pageAssets.some((assetOther) => {
|
|
9
|
+
return assetOther.assetType === 'font' && removeFileExtentionAndHash(assetOther.src) === fontUrlBase;
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
function removeFileExtentionAndHash(assetUrl) {
|
|
13
|
+
assert(!assetUrl.includes('\\'));
|
|
14
|
+
// The logic below doesn't work for '/assets/chunk-0e184ced.js'
|
|
15
|
+
assert(!assetUrl.endsWith('.js'));
|
|
16
|
+
const paths = assetUrl.split('/');
|
|
17
|
+
{
|
|
18
|
+
const filename = paths[paths.length - 1];
|
|
19
|
+
const filenameParts = filename.split('.');
|
|
20
|
+
assert(filenameParts.length >= 2);
|
|
21
|
+
// User may set config.build.rollupOptions.output.assetFileNames => we can't assume the filename to be `*.${hash}.${ext}`
|
|
22
|
+
const filenameBase = filenameParts.slice(0, filenameParts.length === 2 ? -1 : -2);
|
|
23
|
+
assert(filenameBase.length >= 1);
|
|
24
|
+
paths[paths.length - 1] = filenameBase.join('.');
|
|
25
|
+
}
|
|
26
|
+
return paths.join('/');
|
|
27
|
+
}
|
|
@@ -21,8 +21,6 @@ export * from '../../utils/compareString.js';
|
|
|
21
21
|
export * from '../../utils/isObjectWithKeys.js';
|
|
22
22
|
export * from '../../utils/stringifyStringArray.js';
|
|
23
23
|
export * from '../../utils/unique.js';
|
|
24
|
-
export * from '../../utils/toPosixPath.js';
|
|
25
|
-
export * from '../plugin/getOutDirs.js';
|
|
26
24
|
export * from '../../utils/capitalizeFirstLetter.js';
|
|
27
25
|
export * from '../../utils/debugGlob.js';
|
|
28
26
|
export * from '../../utils/isSameErrorMessage.js';
|
|
@@ -41,7 +39,7 @@ export * from '../../utils/objectEntries.js';
|
|
|
41
39
|
export * from '../../utils/objectFromEntries.js';
|
|
42
40
|
export * from '../../utils/getFileExtension.js';
|
|
43
41
|
export * from '../../utils/assertSetup.js';
|
|
44
|
-
export * from '../../utils/path
|
|
42
|
+
export * from '../../utils/path.js';
|
|
45
43
|
export * from '../../utils/isHtml.js';
|
|
46
44
|
export * from '../../utils/warnIfErrorIsNotObject.js';
|
|
47
45
|
export * from '../../utils/stripAnsi.js';
|
|
@@ -25,8 +25,6 @@ export * from '../../utils/compareString.js';
|
|
|
25
25
|
export * from '../../utils/isObjectWithKeys.js';
|
|
26
26
|
export * from '../../utils/stringifyStringArray.js';
|
|
27
27
|
export * from '../../utils/unique.js';
|
|
28
|
-
export * from '../../utils/toPosixPath.js';
|
|
29
|
-
export * from '../plugin/getOutDirs.js';
|
|
30
28
|
export * from '../../utils/capitalizeFirstLetter.js';
|
|
31
29
|
export * from '../../utils/debugGlob.js';
|
|
32
30
|
export * from '../../utils/isSameErrorMessage.js';
|
|
@@ -45,7 +43,7 @@ export * from '../../utils/objectEntries.js';
|
|
|
45
43
|
export * from '../../utils/objectFromEntries.js';
|
|
46
44
|
export * from '../../utils/getFileExtension.js';
|
|
47
45
|
export * from '../../utils/assertSetup.js';
|
|
48
|
-
export * from '../../utils/path
|
|
46
|
+
export * from '../../utils/path.js';
|
|
49
47
|
export * from '../../utils/isHtml.js';
|
|
50
48
|
export * from '../../utils/warnIfErrorIsNotObject.js';
|
|
51
49
|
export * from '../../utils/stripAnsi.js';
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
export { fileTypes };
|
|
3
3
|
export { isValidFileType };
|
|
4
4
|
export { determineFileType };
|
|
5
|
-
import { assert
|
|
5
|
+
import { assert } from '../utils.js';
|
|
6
6
|
import { isScriptFile } from '../../utils/isScriptFile.js';
|
|
7
7
|
const fileTypes = [
|
|
8
8
|
'.page',
|
|
@@ -18,7 +18,6 @@ function isValidFileType(filePath) {
|
|
|
18
18
|
return ['.js', '.mjs', '.cjs', '.css'].some((ext) => filePath.endsWith(ext));
|
|
19
19
|
}
|
|
20
20
|
function determineFileType(filePath) {
|
|
21
|
-
assertPosixPath(filePath);
|
|
22
21
|
{
|
|
23
22
|
const isCSS = filePath.endsWith('.css');
|
|
24
23
|
if (isCSS) {
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
export { getPageFilesClientSide };
|
|
3
3
|
export { getPageFilesServerSide };
|
|
4
4
|
import { assert, assertUsage, isNotNullish } from '../utils.js';
|
|
5
|
-
import { assertPageFilePath } from '../assertPageFilePath.js';
|
|
6
5
|
function getPageFilesClientSide(pageFilesAll, pageId) {
|
|
7
6
|
return determine(pageFilesAll, pageId, true);
|
|
8
7
|
}
|
|
@@ -86,8 +85,6 @@ function getPageFilesSorter(envIsClient, pageId) {
|
|
|
86
85
|
};
|
|
87
86
|
}
|
|
88
87
|
function getPathDistance(pathA, pathB) {
|
|
89
|
-
assertPageFilePath(pathA);
|
|
90
|
-
assertPageFilePath(pathB);
|
|
91
88
|
// Index of first different character
|
|
92
89
|
let idx = 0;
|
|
93
90
|
for (; idx < pathA.length && idx < pathB.length; idx++) {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
// TODO/v1-release: remove
|
|
2
2
|
export { getPageFileObject };
|
|
3
3
|
import { determinePageIdOld } from '../determinePageIdOld.js';
|
|
4
|
-
import { assertPageFilePath } from '../assertPageFilePath.js';
|
|
5
4
|
import { isErrorPageId } from '../error-page.js';
|
|
6
5
|
import { assert, slice } from '../utils.js';
|
|
7
6
|
import { determineFileType } from './fileTypes.js';
|
|
@@ -36,19 +35,15 @@ function getPageFileObject(filePath) {
|
|
|
36
35
|
return pageFile;
|
|
37
36
|
}
|
|
38
37
|
function isDefaultFilePath(filePath) {
|
|
39
|
-
assertPageFilePath(filePath);
|
|
40
38
|
if (isErrorPageId(filePath, false)) {
|
|
41
39
|
return false;
|
|
42
40
|
}
|
|
43
41
|
return filePath.includes('/_default');
|
|
44
42
|
}
|
|
45
43
|
function isRendererFilePath(filePath) {
|
|
46
|
-
assertPageFilePath(filePath);
|
|
47
44
|
return filePath.includes('/renderer/');
|
|
48
45
|
}
|
|
49
46
|
function isAncestorDefaultPage(pageId, defaultPageFilePath) {
|
|
50
|
-
assertPageFilePath(pageId);
|
|
51
|
-
assertPageFilePath(defaultPageFilePath);
|
|
52
47
|
assert(!pageId.endsWith('/'));
|
|
53
48
|
assert(!defaultPageFilePath.endsWith('/'));
|
|
54
49
|
assert(isDefaultFilePath(defaultPageFilePath));
|
|
@@ -49,7 +49,6 @@ type PageConfigBuildTime = PageConfigCommon & {
|
|
|
49
49
|
/** Global config that applies to all pages, build-time data structure */
|
|
50
50
|
type PageConfigGlobalBuildTime = {
|
|
51
51
|
configValueSources: ConfigValueSources;
|
|
52
|
-
interfaceFiles: InterfaceFilesByLocationId;
|
|
53
52
|
configDefinitions: ConfigDefinitions;
|
|
54
53
|
configValuesComputed?: undefined;
|
|
55
54
|
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export { serializeConfigValues };
|
|
2
2
|
export { getConfigValuesBase };
|
|
3
|
+
export type { FilesEnv };
|
|
3
4
|
import type { ConfigEnvInternal, ConfigValueSource, DefinedAtFile, PageConfigBuildTime, PageConfigGlobalBuildTime } from '../PageConfig.js';
|
|
4
|
-
declare function serializeConfigValues(pageConfig: PageConfigBuildTime | PageConfigGlobalBuildTime, importStatements: string[], isEnvMatch: (configEnv: ConfigEnvInternal) => boolean, tabspace: string, isEager: boolean | null): string[];
|
|
5
|
+
declare function serializeConfigValues(pageConfig: PageConfigBuildTime | PageConfigGlobalBuildTime, importStatements: string[], filesEnv: FilesEnv, isEnvMatch: (configEnv: ConfigEnvInternal) => boolean, tabspace: string, isEager: boolean | null): string[];
|
|
5
6
|
declare function getConfigValuesBase(pageConfig: PageConfigBuildTime | PageConfigGlobalBuildTime, isEnvMatch: (configEnv: ConfigEnvInternal) => boolean, isEager: boolean | null): ConfigValuesBase;
|
|
6
7
|
type ConfigValuesBase = ({
|
|
7
8
|
configValueBase: {
|
|
@@ -9,6 +10,7 @@ type ConfigValuesBase = ({
|
|
|
9
10
|
definedAtData: null;
|
|
10
11
|
};
|
|
11
12
|
value: unknown;
|
|
13
|
+
configEnv: ConfigEnvInternal;
|
|
12
14
|
configName: string;
|
|
13
15
|
} | {
|
|
14
16
|
configValueBase: {
|
|
@@ -25,3 +27,7 @@ type ConfigValuesBase = ({
|
|
|
25
27
|
sourcesRelevant: ConfigValueSource[];
|
|
26
28
|
configName: string;
|
|
27
29
|
})[];
|
|
30
|
+
type FilesEnv = Map<string, {
|
|
31
|
+
configEnv: ConfigEnvInternal;
|
|
32
|
+
configName: string;
|
|
33
|
+
}[]>;
|