vike 0.4.144-commit-d6e4411 → 0.4.144-commit-6aef8a6

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.
Files changed (42) hide show
  1. package/dist/cjs/node/plugin/plugins/importBuild/index.js +3 -3
  2. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/filesystemRouting.js +12 -12
  3. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +140 -127
  4. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/transpileAndExecuteFile.js +2 -4
  5. package/dist/cjs/node/runtime/renderPage/log404/index.js +27 -17
  6. package/dist/cjs/shared/page-configs/getExportPath.js +3 -3
  7. package/dist/cjs/shared/page-configs/loadConfigValues.js +2 -2
  8. package/dist/cjs/shared/page-configs/serialize/parseConfigValuesImported.js +1 -1
  9. package/dist/cjs/shared/page-configs/serialize/serializeConfigValue.js +8 -9
  10. package/dist/cjs/shared/page-configs/utils.js +8 -15
  11. package/dist/cjs/shared/route/abort.js +1 -1
  12. package/dist/cjs/shared/route/loadPageRoutes.js +1 -1
  13. package/dist/cjs/utils/projectInfo.js +1 -1
  14. package/dist/cjs/utils/truncateString.js +12 -7
  15. package/dist/esm/node/plugin/plugins/importBuild/index.js +3 -3
  16. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.d.ts +2 -1
  17. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/filesystemRouting.d.ts +1 -1
  18. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/filesystemRouting.js +12 -12
  19. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +140 -127
  20. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/transpileAndExecuteFile.d.ts +2 -2
  21. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/transpileAndExecuteFile.js +2 -4
  22. package/dist/esm/node/runtime/renderPage/log404/index.d.ts +2 -2
  23. package/dist/esm/node/runtime/renderPage/log404/index.js +27 -16
  24. package/dist/esm/shared/page-configs/PageConfig.d.ts +51 -21
  25. package/dist/esm/shared/page-configs/getExportPath.d.ts +1 -1
  26. package/dist/esm/shared/page-configs/getExportPath.js +3 -3
  27. package/dist/esm/shared/page-configs/loadConfigValues.js +2 -2
  28. package/dist/esm/shared/page-configs/serialize/PageConfigSerialized.d.ts +4 -4
  29. package/dist/esm/shared/page-configs/serialize/parseConfigValuesImported.js +1 -1
  30. package/dist/esm/shared/page-configs/serialize/serializeConfigValue.js +8 -9
  31. package/dist/esm/shared/page-configs/utils.d.ts +3 -3
  32. package/dist/esm/shared/page-configs/utils.js +8 -15
  33. package/dist/esm/shared/route/abort.js +1 -1
  34. package/dist/esm/shared/route/loadPageRoutes.js +1 -1
  35. package/dist/esm/utils/projectInfo.d.ts +1 -1
  36. package/dist/esm/utils/projectInfo.js +1 -1
  37. package/dist/esm/utils/truncateString.d.ts +2 -1
  38. package/dist/esm/utils/truncateString.js +10 -7
  39. package/package.json +1 -1
  40. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getFilePathToShowToUser.js +0 -16
  41. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getFilePathToShowToUser.d.ts +0 -24
  42. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getFilePathToShowToUser.js +0 -13
@@ -1,5 +1,6 @@
1
1
  export { log404 };
2
- export { getPagesAndRoutesInfo };
2
+ // Exported for ./index.spec.ts
3
+ export { getRoutesInfo };
3
4
  import { getGlobalContext } from '../../globalContext.js';
4
5
  import { assert, assertUsage, assertInfo, compareString, stripAnsi, getTerminalWidth, truncateString } from '../../utils.js';
5
6
  import pc from '@brillout/picocolors';
@@ -13,14 +14,19 @@ async function log404(pageContext) {
13
14
  );
14
15
  const globalContext = getGlobalContext();
15
16
  if (!globalContext.isProduction && !isFileRequest(urlPathname) && !pageContext.isClientSideNavigation) {
16
- assertInfo(false, [
17
- `URL ${pc.cyan(urlPathname)} doesn't match the route of any of your pages:`,
18
- getPagesAndRoutesInfo(pageRoutes),
19
- 'See https://vike.dev/routing for more information about routing.'
20
- ].join('\n'), { onlyOnce: false });
17
+ const routesInfo = getRoutesInfo(pageRoutes);
18
+ let msg = `URL ${pc.cyan(urlPathname)} doesn't match the route of any of your pages`;
19
+ const outro = 'See https://vike.dev/routing for more information about routing.';
20
+ if (!routesInfo) {
21
+ msg = `${msg}. ${pc.dim(outro)}`;
22
+ }
23
+ else {
24
+ msg = `${msg}:\n${routesInfo}\n${outro}`;
25
+ }
26
+ assertInfo(false, msg, { onlyOnce: false });
21
27
  }
22
28
  }
23
- function getPagesAndRoutesInfo(pageRoutes) {
29
+ function getRoutesInfo(pageRoutes) {
24
30
  const entries = pageRoutes
25
31
  .map((pageRoute) => {
26
32
  let routeStr;
@@ -69,19 +75,24 @@ function getPagesAndRoutesInfo(pageRoutes) {
69
75
  const terminalWidth = getTerminalWidth() || 134;
70
76
  let width2 = Math.max(...linesContent.map(({ routeTypeSrc }) => stripAnsi(routeTypeSrc).length));
71
77
  let width3 = Math.max(...linesContent.map(({ routeDefinedBy }) => stripAnsi(routeDefinedBy).length));
72
- let width1 = terminalWidth - width3 - width2 - 10;
78
+ const width1_max = terminalWidth -
79
+ width3 -
80
+ width2 -
81
+ // Total width of table border & padding
82
+ 10;
83
+ if (width1_max < 10)
84
+ return null;
73
85
  linesContent.forEach((lineContent) => {
74
86
  let { routeStr } = lineContent;
75
- if (lineContent.routeTypeSrc !== 'Route Function') {
76
- routeStr = truncateString(routeStr, width1, (s) => pc.dim(s));
77
- }
78
- else {
79
- routeStr = truncateRouteFunction(routeStr, width1);
87
+ if (lineContent.routeTypeSrc === 'Route Function') {
88
+ routeStr = truncateRouteFunction(routeStr, width1_max);
89
+ assert(stripAnsi(routeStr).length <= width1_max);
80
90
  }
81
- assert(stripAnsi(routeStr).length <= width1);
82
91
  lineContent.routeStr = routeStr;
83
92
  });
84
- width1 = Math.max(...linesContent.map(({ routeStr }) => stripAnsi(routeStr).length));
93
+ let width1 = Math.max(...linesContent.map(({ routeStr }) => stripAnsi(routeStr).length));
94
+ if (width1 > width1_max)
95
+ return null;
85
96
  let lines = linesContent.map(({ routeStr, routeTypeSrc, routeDefinedBy }, i) => {
86
97
  let cell1 = padEnd(routeStr, width1 + (stripAnsi(routeStr).length - stripAnsi(routeStr).length));
87
98
  let cell2 = padEnd(routeTypeSrc, width2);
@@ -116,7 +127,7 @@ function truncateRouteFunction(routeStr, lenMax) {
116
127
  routeStr = stripAnsi(routeStr);
117
128
  routeStr = removeNonAscii(routeStr);
118
129
  routeStr = routeStr.split(/\s/).filter(Boolean).join(' ');
119
- routeStr = truncateString(routeStr, lenMax, (s) => pc.dim(s));
130
+ routeStr = truncateString(routeStr, lenMax);
120
131
  return routeStr;
121
132
  }
122
133
  /** Same as String.prototype.padEnd but with stripAnsi() */
@@ -14,6 +14,8 @@ export type { ConfigValuesComputed };
14
14
  export type { DefinedAt };
15
15
  export type { DefinedAtFile };
16
16
  export type { DefinedAtFileInfo };
17
+ export type { FilePathResolved };
18
+ export type { FilePath };
17
19
  import type { ConfigValueImported } from './serialize/PageConfigSerialized.js';
18
20
  type PageConfigBase = {
19
21
  pageId: string;
@@ -23,9 +25,9 @@ type PageConfigBase = {
23
25
  definedBy: string;
24
26
  };
25
27
  };
26
- /** Page config data structure available and used at runtime */
28
+ /** Page config data structure available at runtime */
27
29
  type PageConfigRuntime = PageConfigBase & {
28
- /** Loaded config values */
30
+ /** All loaded config values */
29
31
  configValues: ConfigValues;
30
32
  /** Load config values that are lazily loaded such as config.Page */
31
33
  loadConfigValuesAll: () => Promise<ConfigValueImported[]>;
@@ -33,9 +35,9 @@ type PageConfigRuntime = PageConfigBase & {
33
35
  /** Same as PageConfigRuntime but also contains all lazily loaded config values such as config.Page */
34
36
  type PageConfigRuntimeLoaded = PageConfigRuntime & {
35
37
  /** Whether loadConfigValuesAll() was called */
36
- isLoaded: true;
38
+ isAllLoaded: true;
37
39
  };
38
- /** Page config data structure available and used at build-time */
40
+ /** Page config data structure available at build-time */
39
41
  type PageConfigBuildTime = PageConfigBase & {
40
42
  configValues: ConfigValues;
41
43
  configValueSources: ConfigValueSources;
@@ -55,51 +57,79 @@ type ConfigValueSource = {
55
57
  value?: unknown;
56
58
  configEnv: ConfigEnvInternal;
57
59
  definedAtInfo: DefinedAtFileInfo;
58
- /** Wether the config value is loaded at run-time, for example config.Page or config.onBeforeRender */
60
+ /** Wether the config value is loaded at runtime, for example config.Page or config.onBeforeRender */
59
61
  valueIsImportedAtRuntime: boolean;
60
62
  /** Whether the config value is a file path, for example config.client */
61
63
  valueIsFilePath?: true;
62
64
  };
65
+ type DefinedAtFileInfo = FilePath & {
66
+ fileExportName?: string;
67
+ fileExportPathToShowToUser: null | string[];
68
+ };
69
+ type ConfigValueSources = Record<string, ConfigValueSource[]>;
63
70
  type ConfigValueComputed = {
64
71
  configEnv: ConfigEnvInternal;
65
72
  value: unknown;
66
73
  };
67
74
  type ConfigValuesComputed = Record<string, ConfigValueComputed>;
68
- type ConfigValueSources = Record<string, ConfigValueSource[]>;
69
75
  type ConfigValue = {
70
76
  value: unknown;
71
77
  definedAt: DefinedAt;
72
78
  };
73
- type ConfigValues = Record<string, ConfigValue>;
74
79
  type DefinedAt = {
75
80
  file: DefinedAtFile;
76
- isEffect?: true;
77
81
  isComputed?: undefined;
78
82
  isCumulative?: undefined;
79
83
  } | {
80
84
  isCumulative: true;
81
85
  files: DefinedAtFile[];
82
- isEffect?: undefined;
83
86
  isComputed?: undefined;
84
87
  } | {
85
88
  isComputed: true;
86
- isEffect?: undefined;
87
89
  isCumulative?: undefined;
88
90
  };
89
91
  type DefinedAtFile = {
90
92
  filePathToShowToUser: string;
91
- fileExportPath: null | string[];
93
+ fileExportPathToShowToUser: null | string[];
92
94
  };
93
- type DefinedAtFileInfo = // TODO: replace filePathRelativeToUserRootDir and importPathAbsolute with following?
94
- ({
95
- filePathRelativeToUserRootDir: string;
95
+ type ConfigValues = Record<string, ConfigValue>;
96
+ type FilePathResolved = FilePath & {
96
97
  filePathAbsoluteFilesystem: string;
97
- importPathAbsolute: null;
98
- } | {
99
- filePathRelativeToUserRootDir: null;
98
+ };
99
+ type FilePath = {
100
+ /** The file's path, absolute from Vite's perspective.
101
+ *
102
+ * We use this to generate import paths in virtual modules. (Virtual modules cannot have relative import paths.)
103
+ *
104
+ * Its value is equivalent to `filePath.filePathRelativeToUserRootDir ?? filePath.importPathAbsolute`, for example:
105
+ * - `vike-react/config`, or
106
+ * - `/pages/+config.h.js`.
107
+ */
108
+ filePathAbsoluteVite: string;
109
+ /** The file's path, absolute from the filesystem root.
110
+ *
111
+ * Example: `/home/rom/code/my-app/pages/some-page/Page.js`
112
+ *
113
+ * The value is `null` upon aliased import paths which we cannot resolve (we'd need to re-implement https://www.npmjs.com/package/@rollup/plugin-alias).
114
+ */
100
115
  filePathAbsoluteFilesystem: string | null;
116
+ /** The file's path, shown to user upon logging.
117
+ *
118
+ * Currently, its value is equivalent to `FilePath['filePathAbsoluteVite']`.
119
+ */
120
+ filePathToShowToUser: string;
121
+ } & ({
122
+ filePathRelativeToUserRootDir: null;
123
+ /** The file's path, as absolute import path. It's either:
124
+ * - an npm package import (e.g. `vike-react/config`), or
125
+ * - an alias (`#components/Counter').
126
+ */
101
127
  importPathAbsolute: string;
102
- }) & {
103
- exportName?: string;
104
- fileExportPath: null | string[];
105
- };
128
+ } | {
129
+ /** The file's path, relative to Vite's root (i.e. the user project's root directory).
130
+ *
131
+ * Example: `/pages/some-page/Page.js`
132
+ */
133
+ filePathRelativeToUserRootDir: string;
134
+ importPathAbsolute: null | string;
135
+ });
@@ -1,2 +1,2 @@
1
1
  export { getExportPath };
2
- declare function getExportPath(fileExportPath: null | string[], configName: string): null | string;
2
+ declare function getExportPath(fileExportPathToShowToUser: null | string[], configName: string): null | string;
@@ -1,9 +1,9 @@
1
1
  export { getExportPath };
2
2
  import { assert } from '../utils.js';
3
- function getExportPath(fileExportPath, configName) {
4
- if (!fileExportPath)
3
+ function getExportPath(fileExportPathToShowToUser, configName) {
4
+ if (!fileExportPathToShowToUser)
5
5
  return null;
6
- let [exportName, ...exportObjectPath] = fileExportPath;
6
+ let [exportName, ...exportObjectPath] = fileExportPathToShowToUser;
7
7
  if (!exportName)
8
8
  return null;
9
9
  if (exportObjectPath.length === 0 && ['*', 'default', configName].includes(exportName))
@@ -2,7 +2,7 @@ export { loadConfigValues };
2
2
  import { objectAssign } from '../utils.js';
3
3
  import { parseConfigValuesImported } from './serialize/parseConfigValuesImported.js';
4
4
  async function loadConfigValues(pageConfig, isDev) {
5
- if ('isLoaded' in pageConfig &&
5
+ if ('isAllLoaded' in pageConfig &&
6
6
  // We don't need to cache in dev, since Vite already caches the virtual module
7
7
  !isDev) {
8
8
  return pageConfig;
@@ -10,6 +10,6 @@ async function loadConfigValues(pageConfig, isDev) {
10
10
  const configValuesImported = await pageConfig.loadConfigValuesAll();
11
11
  const configValuesAddendum = parseConfigValuesImported(configValuesImported);
12
12
  Object.assign(pageConfig.configValues, configValuesAddendum);
13
- objectAssign(pageConfig, { isLoaded: true });
13
+ objectAssign(pageConfig, { isAllLoaded: true });
14
14
  return pageConfig;
15
15
  }
@@ -3,9 +3,9 @@ export type { PageConfigGlobalRuntimeSerialized };
3
3
  export type { ConfigValueSerialized };
4
4
  export type { ConfigValueImported };
5
5
  import type { DefinedAt, PageConfigRuntime } from '../PageConfig.js';
6
- /** page config data structure serialized in virtual files: parsing it results in PageConfigRuntime */
6
+ /** Page config data structure serialized in virtual files: parsing it results in PageConfigRuntime */
7
7
  type PageConfigRuntimeSerialized = Omit<PageConfigRuntime, 'configValues'> & {
8
- /** Config values that are loaded eagerly and serializable such as config.passToClient */
8
+ /** Config values that are serializable and loaded eagerly such as config.passToClient */
9
9
  configValuesSerialized: Record<string, ConfigValueSerialized>;
10
10
  /** Config values imported eagerly such as config.route */
11
11
  configValuesImported: ConfigValueImported[];
@@ -13,12 +13,12 @@ type PageConfigRuntimeSerialized = Omit<PageConfigRuntime, 'configValues'> & {
13
13
  type PageConfigGlobalRuntimeSerialized = {
14
14
  configValuesImported: ConfigValueImported[];
15
15
  };
16
- /** Value is serialized. */
16
+ /** Value is serialized */
17
17
  type ConfigValueSerialized = {
18
18
  valueSerialized: string;
19
19
  definedAt: DefinedAt;
20
20
  };
21
- /** Value is imported. */
21
+ /** Value is imported */
22
22
  type ConfigValueImported = {
23
23
  configName: string;
24
24
  importPath: string;
@@ -11,7 +11,7 @@ function parseConfigValuesImported(configValuesImported) {
11
11
  file: {
12
12
  // importPath cannot be relative to the current file, since the current file is a virtual file
13
13
  filePathToShowToUser: importPath,
14
- fileExportPath: [configName, 'default'].includes(exportName)
14
+ fileExportPathToShowToUser: [configName, 'default'].includes(exportName)
15
15
  ? []
16
16
  : // Side-effect config
17
17
  [exportName]
@@ -25,27 +25,26 @@ function serializeConfigValueImported(configValueSource, configName, whitespace,
25
25
  assert(whitespace.replaceAll(' ', '').length === 0);
26
26
  const { valueIsImportedAtRuntime, definedAtInfo } = configValueSource;
27
27
  assert(valueIsImportedAtRuntime);
28
- const { filePathRelativeToUserRootDir, importPathAbsolute, exportName } = definedAtInfo;
29
- const importPath = filePathRelativeToUserRootDir ?? importPathAbsolute;
30
- assertPosixPath(importPath);
31
- const fileName = path.posix.basename(importPath);
28
+ const { filePathAbsoluteVite, fileExportName } = definedAtInfo;
29
+ assertPosixPath(filePathAbsoluteVite);
30
+ const fileName = path.posix.basename(filePathAbsoluteVite);
32
31
  const isValueFile = fileName.startsWith('+');
33
32
  if (isValueFile)
34
- assert(exportName === undefined);
35
- const { importName, importStatement } = generateEagerImport(importPath, varCounterContainer.varCounter++, exportName);
33
+ assert(fileExportName === undefined);
34
+ const { importName, importStatement } = generateEagerImport(filePathAbsoluteVite, varCounterContainer.varCounter++, fileExportName);
36
35
  importStatements.push(importStatement);
37
36
  const lines = [];
38
37
  lines.push(` {`);
39
38
  lines.push(` configName: '${configName}',`);
40
- lines.push(` importPath: '${importPath}',`);
39
+ lines.push(` importPath: '${filePathAbsoluteVite}',`);
41
40
  lines.push(` isValueFile: ${JSON.stringify(isValueFile)},`);
42
41
  if (isValueFile) {
43
42
  lines.push(` exportValues: ${importName},`);
44
43
  }
45
44
  else {
46
45
  lines.push(` exportValue: ${importName},`);
47
- assert(exportName);
48
- lines.push(` exportName: ${JSON.stringify(exportName)},`);
46
+ assert(fileExportName);
47
+ lines.push(` exportName: ${JSON.stringify(fileExportName)},`);
49
48
  }
50
49
  lines.push(` },`);
51
50
  return lines;
@@ -22,11 +22,11 @@ type ConfigDefinedAtUppercase<ConfigName extends string> = `Config ${ConfigName}
22
22
  type ConfigDefinedAtLowercase<ConfigName extends string> = `config ${ConfigName} defined ${'internally' | `at ${string}`}`;
23
23
  declare function getConfigDefinedAtString<ConfigName extends string>(configName: ConfigName, { definedAt }: {
24
24
  definedAt: DefinedAt;
25
- }, sentenceBegin: true, append?: 'effect'): ConfigDefinedAtUppercase<ConfigName>;
25
+ }, sentenceBegin: true): ConfigDefinedAtUppercase<ConfigName>;
26
26
  declare function getConfigDefinedAtString<ConfigName extends string>(configName: ConfigName, { definedAt }: {
27
27
  definedAt: DefinedAt;
28
- }, sentenceBegin: false, append?: 'effect'): ConfigDefinedAtLowercase<ConfigName>;
29
- declare function getDefinedAtString(configValue: ConfigValue, configName: string): string;
28
+ }, sentenceBegin: false): ConfigDefinedAtLowercase<ConfigName>;
29
+ declare function getDefinedAtString(definedAt: DefinedAt, configName: string): string;
30
30
  declare function getConfigValueFilePathToShowToUser({ definedAt }: {
31
31
  definedAt: DefinedAt;
32
32
  }): null | string;
@@ -43,10 +43,12 @@ function getPageConfig(pageId, pageConfigs) {
43
43
  return pageConfig;
44
44
  }
45
45
  function getConfigDefinedAtString(configName, { definedAt }, sentenceBegin) {
46
- const configDefinedAt = `${sentenceBegin ? `Config` : `config`} ${pc.cyan(configName)} defined ${getSourceString(definedAt, configName)}`;
46
+ const definedAtString = getDefinedAtString(definedAt, configName);
47
+ const definedAtStr = definedAtString === 'internally' ? definedAtString : `at ${definedAtString}`;
48
+ const configDefinedAt = `${sentenceBegin ? `Config` : `config`} ${pc.cyan(configName)} defined ${definedAtStr}`;
47
49
  return configDefinedAt;
48
50
  }
49
- function getSourceString(definedAt, configName) {
51
+ function getDefinedAtString(definedAt, configName) {
50
52
  if (definedAt.isComputed) {
51
53
  return 'internally';
52
54
  }
@@ -58,27 +60,18 @@ function getSourceString(definedAt, configName) {
58
60
  files = [definedAt.file];
59
61
  }
60
62
  assert(files.length >= 1);
61
- const sourceString = files
63
+ const definedAtString = files
62
64
  .map((source) => {
63
- const { filePathToShowToUser, fileExportPath } = source;
65
+ const { filePathToShowToUser, fileExportPathToShowToUser } = source;
64
66
  let s = filePathToShowToUser;
65
- const exportPath = getExportPath(fileExportPath, configName);
67
+ const exportPath = getExportPath(fileExportPathToShowToUser, configName);
66
68
  if (exportPath) {
67
69
  s = `${s} > ${pc.cyan(exportPath)}`;
68
70
  }
69
- if (definedAt.isEffect) {
70
- s = `${s} > (${pc.blue('effect')})`;
71
- }
72
71
  return s;
73
72
  })
74
73
  .join(' / ');
75
- return `at ${sourceString}`;
76
- }
77
- function getDefinedAtString(configValue, configName) {
78
- let sourceString = getSourceString(configValue.definedAt, configName);
79
- if (sourceString.startsWith('at '))
80
- sourceString = sourceString.slice('at '.length);
81
- return sourceString;
74
+ return definedAtString;
82
75
  }
83
76
  function getConfigValueFilePathToShowToUser({ definedAt }) {
84
77
  // A unique file path only exists if the config value isn't cumulative nor computed:
@@ -41,7 +41,7 @@ function redirect(url, statusCode) {
41
41
  function render(value, abortReason) {
42
42
  const args = [typeof value === 'number' ? String(value) : JSON.stringify(value)];
43
43
  if (abortReason !== undefined)
44
- args.push(truncateString(JSON.stringify(abortReason), 30, null));
44
+ args.push(truncateString(JSON.stringify(abortReason), 30));
45
45
  const abortCaller = 'throw render()';
46
46
  const abortCall = `throw render(${args.join(', ')})`;
47
47
  return render_(value, abortReason, abortCall, abortCaller);
@@ -31,7 +31,7 @@ function getPageRoutes(filesystemRoots, pageFilesAll, pageConfigs, allPageIds) {
31
31
  const configValue = getConfigValue(pageConfig, configName);
32
32
  if (configValue) {
33
33
  const route = configValue.value;
34
- const definedAt = getDefinedAtString(configValue, configName);
34
+ const definedAt = getDefinedAtString(configValue.definedAt, configName);
35
35
  if (typeof route === 'string') {
36
36
  pageRoute = {
37
37
  pageId,
@@ -5,7 +5,7 @@ type ProjectVersion = typeof projectInfo.projectVersion;
5
5
  type ProjectTag = `[${PackageName}]` | `[${PackageName}@${ProjectVersion}]`;
6
6
  declare const projectInfo: {
7
7
  projectName: "Vike";
8
- projectVersion: "0.4.144-commit-d6e4411";
8
+ projectVersion: "0.4.144-commit-6aef8a6";
9
9
  npmPackageName: "vike";
10
10
  githubRepository: "https://github.com/vikejs/vike";
11
11
  };
@@ -1,6 +1,6 @@
1
1
  export { projectInfo };
2
2
  import { onProjectInfo } from './assertSingleInstance.js';
3
- const PROJECT_VERSION = '0.4.144-commit-d6e4411';
3
+ const PROJECT_VERSION = '0.4.144-commit-6aef8a6';
4
4
  const projectInfo = {
5
5
  projectName: 'Vike',
6
6
  projectVersion: PROJECT_VERSION,
@@ -1 +1,2 @@
1
- export declare function truncateString(str: string, lenMax: number, dim: null | ((ellipsis: string) => string)): string;
1
+ export { truncateString };
2
+ declare function truncateString(str: string, lenMax: number): string;
@@ -1,14 +1,17 @@
1
- export function truncateString(str, lenMax, dim) {
1
+ export { truncateString };
2
+ import pc from '@brillout/picocolors';
3
+ import { assert } from './assert.js';
4
+ function truncateString(str, lenMax) {
5
+ const lenMaxReal = lenMax - 3;
6
+ assert(lenMaxReal >= 1); // Show at least one character before the ellipsis
2
7
  if (str.length < lenMax) {
3
8
  return str;
4
9
  }
5
10
  else {
6
- // May break ANSI codes
7
- // - So far, the str we pass to truncateString(str) are expected to not contain any ANSI code
8
- str = str.substring(0, lenMax - 3);
9
- let ellipsis = '...';
10
- if (dim)
11
- ellipsis = dim(ellipsis);
11
+ // Breaks ANSI codes.
12
+ // - So far, the `str` we pass to truncateString(str) is always expected to not contain any ANSI code
13
+ str = str.substring(0, lenMaxReal);
14
+ const ellipsis = pc.dim('...');
12
15
  str = str + ellipsis;
13
16
  return str;
14
17
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vike",
3
- "version": "0.4.144-commit-d6e4411",
3
+ "version": "0.4.144-commit-6aef8a6",
4
4
  "scripts": {
5
5
  "dev": "tsc --watch",
6
6
  "build": "rimraf dist/ && pnpm run build:esm && pnpm run build:cjs",
@@ -1,16 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getFilePathToShowToUser = void 0;
4
- const utils_js_1 = require("../../../utils.js");
5
- /*
6
- const f: FilePath = 1 as any
7
- if (f.filePathRelativeToUserRootDir === null) {
8
- f.importPathAbsolute
9
- }
10
- //*/
11
- function getFilePathToShowToUser(filePath) {
12
- const filePathToShowToUser = filePath.filePathRelativeToUserRootDir ?? filePath.filePathAbsoluteFilesystem;
13
- (0, utils_js_1.assert)(filePathToShowToUser);
14
- return filePathToShowToUser;
15
- }
16
- exports.getFilePathToShowToUser = getFilePathToShowToUser;
@@ -1,24 +0,0 @@
1
- export { getFilePathToShowToUser };
2
- export type { FilePath };
3
- type FilePath = {
4
- /** The file's path relative to the filesystem root.
5
- *
6
- * Example: `/home/rom/code/my-app/pages/some-page/Page.js`
7
- */
8
- filePathAbsoluteFilesystem: string;
9
- } & ({
10
- /** The file's path relative to the Vite's root (i.e. the user's project root directory).
11
- *
12
- * Example: `/pages/some-page/Page.js`
13
- */
14
- filePathRelativeToUserRootDir: string;
15
- importPathAbsolute: null;
16
- } | {
17
- filePathRelativeToUserRootDir: null;
18
- /** The file's absolute import path.
19
- *
20
- * Example: `vike-react/config`
21
- */
22
- importPathAbsolute: string;
23
- });
24
- declare function getFilePathToShowToUser(filePath: FilePath): string;
@@ -1,13 +0,0 @@
1
- export { getFilePathToShowToUser };
2
- import { assert } from '../../../utils.js';
3
- /*
4
- const f: FilePath = 1 as any
5
- if (f.filePathRelativeToUserRootDir === null) {
6
- f.importPathAbsolute
7
- }
8
- //*/
9
- function getFilePathToShowToUser(filePath) {
10
- const filePathToShowToUser = filePath.filePathRelativeToUserRootDir ?? filePath.filePathAbsoluteFilesystem;
11
- assert(filePathToShowToUser);
12
- return filePathToShowToUser;
13
- }