vike 0.4.144 → 0.4.145-commit-2520555

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 (198) hide show
  1. package/dist/cjs/__internal/index.js +6 -2
  2. package/dist/cjs/node/plugin/plugins/buildConfig.js +3 -3
  3. package/dist/cjs/node/plugin/plugins/commonConfig.js +0 -3
  4. package/dist/cjs/node/plugin/plugins/config/index.js +3 -3
  5. package/dist/cjs/node/plugin/plugins/devConfig/determineOptimizeDeps.js +8 -8
  6. package/dist/cjs/node/plugin/plugins/devConfig/index.js +1 -0
  7. package/dist/cjs/node/plugin/plugins/envVars.js +34 -20
  8. package/dist/cjs/node/plugin/plugins/importBuild/index.js +3 -3
  9. package/dist/cjs/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.js +1 -1
  10. package/dist/cjs/node/plugin/plugins/importUserCode/index.js +3 -3
  11. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +5 -4
  12. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/filesystemRouting.js +12 -12
  13. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +249 -228
  14. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js +8 -6
  15. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigs.js +36 -14
  16. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/helpers.js +1 -14
  17. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/isRuntimeEnvMatch.js +18 -0
  18. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/transpileAndExecuteFile.js +15 -17
  19. package/dist/cjs/node/plugin/plugins/previewConfig.js +11 -2
  20. package/dist/cjs/node/prerender/runPrerender.js +34 -26
  21. package/dist/cjs/node/prerender/utils.js +1 -1
  22. package/dist/cjs/node/runtime/html/serializePageContextClientSide.js +20 -6
  23. package/dist/cjs/node/runtime/renderPage/debugPageFiles.js +5 -5
  24. package/dist/cjs/node/runtime/renderPage/log404/index.js +28 -17
  25. package/dist/cjs/node/runtime/renderPage/renderPageAlreadyRouted.js +3 -3
  26. package/dist/cjs/node/runtime/renderPage.js +3 -3
  27. package/dist/cjs/node/runtime/utils.js +1 -1
  28. package/dist/cjs/node/shared/getClientEntryFilePath.js +2 -2
  29. package/dist/cjs/node/shared/getConfigVike.js +4 -1
  30. package/dist/cjs/shared/addUrlComputedProps.js +24 -12
  31. package/dist/cjs/shared/getPageFiles/analyzeClientSide.js +4 -6
  32. package/dist/cjs/shared/getPageFiles/getExports.js +3 -3
  33. package/dist/cjs/shared/hooks/getHook.js +1 -1
  34. package/dist/cjs/shared/page-configs/getExportPath.js +3 -3
  35. package/dist/cjs/shared/page-configs/helpers/getConfigDefinedAtString.js +43 -0
  36. package/dist/cjs/shared/page-configs/helpers/getConfigValue.js +44 -0
  37. package/dist/cjs/shared/page-configs/helpers.js +33 -0
  38. package/dist/cjs/shared/page-configs/loadConfigValues.js +2 -2
  39. package/dist/cjs/shared/page-configs/serialize/parseConfigValuesImported.js +14 -13
  40. package/dist/cjs/shared/page-configs/serialize/parsePageConfigs.js +2 -2
  41. package/dist/cjs/shared/page-configs/serialize/serializeConfigValue.js +9 -10
  42. package/dist/cjs/shared/route/abort.js +1 -1
  43. package/dist/cjs/shared/route/executeOnBeforeRouteHook.js +41 -15
  44. package/dist/cjs/shared/route/index.js +22 -32
  45. package/dist/cjs/shared/route/loadPageRoutes.js +11 -10
  46. package/dist/cjs/shared/route/noRouteMatch.js +4 -0
  47. package/dist/cjs/shared/route/resolveRouteFunction.js +1 -1
  48. package/dist/cjs/shared/utils.js +1 -1
  49. package/dist/cjs/utils/getFilePathAbsolute.js +11 -11
  50. package/dist/cjs/utils/isExternalLink.js +7 -0
  51. package/dist/cjs/utils/{hasPropertyGetter.js → isPropertyGetter.js} +3 -3
  52. package/dist/cjs/utils/onPageVisibilityChange.js +19 -0
  53. package/dist/cjs/utils/parseUrl.js +1 -1
  54. package/dist/cjs/utils/projectInfo.js +1 -1
  55. package/dist/cjs/utils/truncateString.js +12 -7
  56. package/dist/esm/__internal/index.d.ts +6 -3
  57. package/dist/esm/__internal/index.js +8 -3
  58. package/dist/esm/client/client-routing-runtime/createPageContext.d.ts +2 -3
  59. package/dist/esm/client/client-routing-runtime/createPageContext.js +3 -4
  60. package/dist/esm/client/client-routing-runtime/entry.js +2 -2
  61. package/dist/esm/client/client-routing-runtime/getBaseServer.d.ts +2 -1
  62. package/dist/esm/client/client-routing-runtime/getBaseServer.js +2 -1
  63. package/dist/esm/client/client-routing-runtime/getPageContextFromHooks.d.ts +39 -0
  64. package/dist/esm/client/client-routing-runtime/{getPageContext.js → getPageContextFromHooks.js} +50 -79
  65. package/dist/esm/client/client-routing-runtime/history.d.ts +3 -1
  66. package/dist/esm/client/client-routing-runtime/history.js +31 -9
  67. package/dist/esm/client/client-routing-runtime/installClientRouter.d.ts +2 -0
  68. package/dist/esm/client/client-routing-runtime/installClientRouter.js +22 -0
  69. package/dist/esm/client/client-routing-runtime/isClientSideRoutable.d.ts +8 -0
  70. package/dist/esm/client/client-routing-runtime/isClientSideRoutable.js +12 -0
  71. package/dist/esm/client/client-routing-runtime/navigate.d.ts +0 -2
  72. package/dist/esm/client/client-routing-runtime/navigate.js +9 -8
  73. package/dist/esm/client/client-routing-runtime/onBrowserHistoryNavigation.d.ts +4 -0
  74. package/dist/esm/client/client-routing-runtime/onBrowserHistoryNavigation.js +63 -0
  75. package/dist/esm/client/client-routing-runtime/onLinkClick.d.ts +2 -0
  76. package/dist/esm/client/client-routing-runtime/onLinkClick.js +40 -0
  77. package/dist/esm/client/client-routing-runtime/prefetch.js +54 -29
  78. package/dist/esm/client/client-routing-runtime/renderPageClientSide.d.ts +19 -0
  79. package/dist/esm/client/client-routing-runtime/renderPageClientSide.js +347 -0
  80. package/dist/esm/client/client-routing-runtime/scrollRestoration.d.ts +6 -0
  81. package/dist/esm/client/client-routing-runtime/scrollRestoration.js +25 -0
  82. package/dist/esm/client/client-routing-runtime/setScrollPosition.d.ts +7 -0
  83. package/dist/esm/client/client-routing-runtime/setScrollPosition.js +77 -0
  84. package/dist/esm/client/client-routing-runtime/skipLink.d.ts +0 -1
  85. package/dist/esm/client/client-routing-runtime/skipLink.js +9 -5
  86. package/dist/esm/client/client-routing-runtime/utils.d.ts +2 -0
  87. package/dist/esm/client/client-routing-runtime/utils.js +2 -0
  88. package/dist/esm/client/server-routing-runtime/getPageContext.js +1 -1
  89. package/dist/esm/client/shared/executeOnRenderClientHook.js +6 -5
  90. package/dist/esm/client/shared/getPageContextProxyForUser.js +13 -7
  91. package/dist/esm/client/shared/loadPageFilesClientSide.d.ts +8 -3
  92. package/dist/esm/client/shared/loadPageFilesClientSide.js +5 -5
  93. package/dist/esm/node/plugin/plugins/buildConfig.js +3 -3
  94. package/dist/esm/node/plugin/plugins/commonConfig.js +0 -3
  95. package/dist/esm/node/plugin/plugins/config/index.js +4 -4
  96. package/dist/esm/node/plugin/plugins/devConfig/determineOptimizeDeps.js +9 -9
  97. package/dist/esm/node/plugin/plugins/devConfig/index.js +1 -0
  98. package/dist/esm/node/plugin/plugins/envVars.d.ts +2 -0
  99. package/dist/esm/node/plugin/plugins/envVars.js +35 -20
  100. package/dist/esm/node/plugin/plugins/importBuild/index.js +3 -3
  101. package/dist/esm/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.js +1 -1
  102. package/dist/esm/node/plugin/plugins/importUserCode/index.js +3 -3
  103. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.d.ts +2 -1
  104. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +5 -4
  105. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/filesystemRouting.d.ts +1 -1
  106. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/filesystemRouting.js +12 -12
  107. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.d.ts +2 -1
  108. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +250 -229
  109. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.d.ts +2 -2
  110. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js +7 -5
  111. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigs.d.ts +2 -2
  112. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigs.js +37 -15
  113. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/helpers.js +1 -14
  114. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/isRuntimeEnvMatch.d.ts +7 -0
  115. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/isRuntimeEnvMatch.js +15 -0
  116. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/transpileAndExecuteFile.d.ts +2 -2
  117. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/transpileAndExecuteFile.js +16 -18
  118. package/dist/esm/node/plugin/plugins/previewConfig.js +11 -2
  119. package/dist/esm/node/prerender/runPrerender.js +29 -21
  120. package/dist/esm/node/prerender/utils.d.ts +1 -1
  121. package/dist/esm/node/prerender/utils.js +1 -1
  122. package/dist/esm/node/runtime/html/serializePageContextClientSide.js +21 -7
  123. package/dist/esm/node/runtime/renderPage/debugPageFiles.d.ts +5 -5
  124. package/dist/esm/node/runtime/renderPage/debugPageFiles.js +5 -5
  125. package/dist/esm/node/runtime/renderPage/loadPageFilesServerSide.d.ts +2 -2
  126. package/dist/esm/node/runtime/renderPage/log404/index.d.ts +2 -2
  127. package/dist/esm/node/runtime/renderPage/log404/index.js +28 -16
  128. package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.js +2 -2
  129. package/dist/esm/node/runtime/renderPage.js +3 -3
  130. package/dist/esm/node/runtime/utils.d.ts +1 -1
  131. package/dist/esm/node/runtime/utils.js +1 -1
  132. package/dist/esm/node/shared/getClientEntryFilePath.js +1 -1
  133. package/dist/esm/node/shared/getConfigVike.d.ts +2 -1
  134. package/dist/esm/node/shared/getConfigVike.js +4 -1
  135. package/dist/esm/shared/addUrlComputedProps.d.ts +1 -0
  136. package/dist/esm/shared/addUrlComputedProps.js +25 -13
  137. package/dist/esm/shared/getPageFiles/analyzeClientSide.js +2 -4
  138. package/dist/esm/shared/getPageFiles/getExports.js +2 -2
  139. package/dist/esm/shared/hooks/getHook.js +1 -1
  140. package/dist/esm/shared/page-configs/PageConfig.d.ts +55 -31
  141. package/dist/esm/shared/page-configs/getExportPath.d.ts +1 -1
  142. package/dist/esm/shared/page-configs/getExportPath.js +3 -3
  143. package/dist/esm/shared/page-configs/helpers/getConfigDefinedAtString.d.ts +7 -0
  144. package/dist/esm/shared/page-configs/helpers/getConfigDefinedAtString.js +37 -0
  145. package/dist/esm/shared/page-configs/helpers/getConfigValue.d.ts +14 -0
  146. package/dist/esm/shared/page-configs/helpers/getConfigValue.js +38 -0
  147. package/dist/esm/shared/page-configs/helpers.d.ts +13 -0
  148. package/dist/esm/shared/page-configs/helpers.js +27 -0
  149. package/dist/esm/shared/page-configs/loadConfigValues.js +2 -2
  150. package/dist/esm/shared/page-configs/serialize/PageConfigSerialized.d.ts +4 -4
  151. package/dist/esm/shared/page-configs/serialize/parseConfigValuesImported.js +15 -11
  152. package/dist/esm/shared/page-configs/serialize/parsePageConfigs.js +2 -2
  153. package/dist/esm/shared/page-configs/serialize/serializeConfigValue.js +9 -10
  154. package/dist/esm/shared/route/abort.js +1 -1
  155. package/dist/esm/shared/route/executeOnBeforeRouteHook.d.ts +5 -8
  156. package/dist/esm/shared/route/executeOnBeforeRouteHook.js +41 -15
  157. package/dist/esm/shared/route/index.d.ts +12 -10
  158. package/dist/esm/shared/route/index.js +23 -33
  159. package/dist/esm/shared/route/loadPageRoutes.js +8 -7
  160. package/dist/esm/shared/route/noRouteMatch.d.ts +1 -0
  161. package/dist/esm/shared/route/noRouteMatch.js +1 -0
  162. package/dist/esm/shared/route/resolveRouteFunction.js +1 -1
  163. package/dist/esm/shared/utils.d.ts +1 -1
  164. package/dist/esm/shared/utils.js +1 -1
  165. package/dist/esm/utils/getFilePathAbsolute.d.ts +1 -1
  166. package/dist/esm/utils/getFilePathAbsolute.js +11 -11
  167. package/dist/esm/utils/isPropertyGetter.d.ts +1 -0
  168. package/dist/esm/utils/{hasPropertyGetter.js → isPropertyGetter.js} +1 -1
  169. package/dist/esm/utils/onPageVisibilityChange.d.ts +4 -0
  170. package/dist/esm/utils/onPageVisibilityChange.js +16 -0
  171. package/dist/esm/utils/parseUrl.js +1 -1
  172. package/dist/esm/utils/projectInfo.d.ts +1 -1
  173. package/dist/esm/utils/projectInfo.js +1 -1
  174. package/dist/esm/utils/truncateString.d.ts +2 -1
  175. package/dist/esm/utils/truncateString.js +10 -7
  176. package/node/cli/bin-entry.js +1 -1
  177. package/package.json +2 -3
  178. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getFilePathToShowToUser.js +0 -16
  179. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/isConfigEnvMatch.js +0 -13
  180. package/dist/cjs/shared/page-configs/utils.js +0 -103
  181. package/dist/esm/client/client-routing-runtime/getPageContext.d.ts +0 -29
  182. package/dist/esm/client/client-routing-runtime/getPageId.d.ts +0 -10
  183. package/dist/esm/client/client-routing-runtime/getPageId.js +0 -17
  184. package/dist/esm/client/client-routing-runtime/navigationState.d.ts +0 -5
  185. package/dist/esm/client/client-routing-runtime/navigationState.js +0 -14
  186. package/dist/esm/client/client-routing-runtime/skipLink/isClientSideRoutable.d.ts +0 -2
  187. package/dist/esm/client/client-routing-runtime/skipLink/isClientSideRoutable.js +0 -15
  188. package/dist/esm/client/client-routing-runtime/useClientRouter.d.ts +0 -6
  189. package/dist/esm/client/client-routing-runtime/useClientRouter.js +0 -493
  190. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getFilePathToShowToUser.d.ts +0 -24
  191. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getFilePathToShowToUser.js +0 -13
  192. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/isConfigEnvMatch.d.ts +0 -3
  193. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/isConfigEnvMatch.js +0 -10
  194. package/dist/esm/shared/page-configs/utils.d.ts +0 -35
  195. package/dist/esm/shared/page-configs/utils.js +0 -97
  196. package/dist/esm/utils/hasPropertyGetter.d.ts +0 -1
  197. /package/dist/esm/{client/client-routing-runtime → utils}/isExternalLink.d.ts +0 -0
  198. /package/dist/esm/{client/client-routing-runtime → utils}/isExternalLink.js +0 -0
@@ -3,7 +3,8 @@ 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.getPagesAndRoutesInfo = exports.log404 = void 0;
6
+ exports.getRoutesInfo = exports.log404 = void 0;
7
+ const noRouteMatch_js_1 = require("../../../../shared/route/noRouteMatch.js");
7
8
  const globalContext_js_1 = require("../../globalContext.js");
8
9
  const utils_js_1 = require("../../utils.js");
9
10
  const picocolors_1 = __importDefault(require("@brillout/picocolors"));
@@ -17,15 +18,20 @@ async function log404(pageContext) {
17
18
  );
18
19
  const globalContext = (0, globalContext_js_1.getGlobalContext)();
19
20
  if (!globalContext.isProduction && !isFileRequest(urlPathname) && !pageContext.isClientSideNavigation) {
20
- (0, utils_js_1.assertInfo)(false, [
21
- `URL ${picocolors_1.default.cyan(urlPathname)} doesn't match the route of any of your pages:`,
22
- getPagesAndRoutesInfo(pageRoutes),
23
- 'See https://vike.dev/routing for more information about routing.'
24
- ].join('\n'), { onlyOnce: false });
21
+ const routesInfo = getRoutesInfo(pageRoutes);
22
+ let msg = `URL ${picocolors_1.default.cyan(urlPathname)} ${noRouteMatch_js_1.noRouteMatch}`;
23
+ const outro = 'See https://vike.dev/routing for more information about routing.';
24
+ if (!routesInfo) {
25
+ msg = `${msg}. ${picocolors_1.default.dim(outro)}`;
26
+ }
27
+ else {
28
+ msg = `${msg}:\n${routesInfo}\n${outro}`;
29
+ }
30
+ (0, utils_js_1.assertInfo)(false, msg, { onlyOnce: false });
25
31
  }
26
32
  }
27
33
  exports.log404 = log404;
28
- function getPagesAndRoutesInfo(pageRoutes) {
34
+ function getRoutesInfo(pageRoutes) {
29
35
  const entries = pageRoutes
30
36
  .map((pageRoute) => {
31
37
  let routeStr;
@@ -74,19 +80,24 @@ function getPagesAndRoutesInfo(pageRoutes) {
74
80
  const terminalWidth = (0, utils_js_1.getTerminalWidth)() || 134;
75
81
  let width2 = Math.max(...linesContent.map(({ routeTypeSrc }) => (0, utils_js_1.stripAnsi)(routeTypeSrc).length));
76
82
  let width3 = Math.max(...linesContent.map(({ routeDefinedBy }) => (0, utils_js_1.stripAnsi)(routeDefinedBy).length));
77
- let width1 = terminalWidth - width3 - width2 - 10;
83
+ const width1_max = terminalWidth -
84
+ width3 -
85
+ width2 -
86
+ // Total width of table border & padding
87
+ 10;
88
+ if (width1_max < 10)
89
+ return null;
78
90
  linesContent.forEach((lineContent) => {
79
91
  let { routeStr } = lineContent;
80
- if (lineContent.routeTypeSrc !== 'Route Function') {
81
- routeStr = (0, utils_js_1.truncateString)(routeStr, width1, (s) => picocolors_1.default.dim(s));
82
- }
83
- else {
84
- routeStr = truncateRouteFunction(routeStr, width1);
92
+ if (lineContent.routeTypeSrc === 'Route Function') {
93
+ routeStr = truncateRouteFunction(routeStr, width1_max);
94
+ (0, utils_js_1.assert)((0, utils_js_1.stripAnsi)(routeStr).length <= width1_max);
85
95
  }
86
- (0, utils_js_1.assert)((0, utils_js_1.stripAnsi)(routeStr).length <= width1);
87
96
  lineContent.routeStr = routeStr;
88
97
  });
89
- width1 = Math.max(...linesContent.map(({ routeStr }) => (0, utils_js_1.stripAnsi)(routeStr).length));
98
+ let width1 = Math.max(...linesContent.map(({ routeStr }) => (0, utils_js_1.stripAnsi)(routeStr).length));
99
+ if (width1 > width1_max)
100
+ return null;
90
101
  let lines = linesContent.map(({ routeStr, routeTypeSrc, routeDefinedBy }, i) => {
91
102
  let cell1 = padEnd(routeStr, width1 + ((0, utils_js_1.stripAnsi)(routeStr).length - (0, utils_js_1.stripAnsi)(routeStr).length));
92
103
  let cell2 = padEnd(routeTypeSrc, width2);
@@ -117,12 +128,12 @@ function getPagesAndRoutesInfo(pageRoutes) {
117
128
  });
118
129
  return lines.join('\n');
119
130
  }
120
- exports.getPagesAndRoutesInfo = getPagesAndRoutesInfo;
131
+ exports.getRoutesInfo = getRoutesInfo;
121
132
  function truncateRouteFunction(routeStr, lenMax) {
122
133
  routeStr = (0, utils_js_1.stripAnsi)(routeStr);
123
134
  routeStr = removeNonAscii(routeStr);
124
135
  routeStr = routeStr.split(/\s/).filter(Boolean).join(' ');
125
- routeStr = (0, utils_js_1.truncateString)(routeStr, lenMax, (s) => picocolors_1.default.dim(s));
136
+ routeStr = (0, utils_js_1.truncateString)(routeStr, lenMax);
126
137
  return routeStr;
127
138
  }
128
139
  /** Same as String.prototype.padEnd but with stripAnsi() */
@@ -21,7 +21,7 @@ const preparePageContextForUserConsumptionServerSide_js_1 = require("./preparePa
21
21
  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
- const utils_js_2 = require("../../../shared/page-configs/utils.js");
24
+ const helpers_js_1 = require("../../../shared/page-configs/helpers.js");
25
25
  async function renderPageAlreadyRouted(pageContext) {
26
26
  // pageContext._pageId can either be the:
27
27
  // - ID of the page matching the routing, or the
@@ -105,7 +105,7 @@ async function prerender404Page(renderContext, pageContextInit_) {
105
105
  routeParams: {},
106
106
  // `prerender404Page()` is about generating `dist/client/404.html` for static hosts; there is no Client Routing.
107
107
  _usesClientRouter: false,
108
- _routeMatches: []
108
+ _debugRouteMatches: []
109
109
  };
110
110
  const pageContextInit = {
111
111
  urlOriginal: '/fake-404-url',
@@ -173,7 +173,7 @@ function assertNonMixedDesign(pageFilesAll, pageConfigs) {
173
173
  const indent = '- ';
174
174
  const v1Files = (0, utils_js_1.unique)(pageConfigs
175
175
  .map((p) => Object.values(p.configValues)
176
- .map(utils_js_2.getConfigValueFilePathToShowToUser)
176
+ .map(helpers_js_1.getConfigValueFilePathToShowToUser)
177
177
  .filter(utils_js_1.isNotNullish)
178
178
  .map((filePathToShowToUser) => indent + filePathToShowToUser))
179
179
  .flat(2));
@@ -246,8 +246,8 @@ async function renderPageNominal(pageContext) {
246
246
  }
247
247
  // Route
248
248
  {
249
- const routeResult = await (0, index_js_1.route)(pageContext);
250
- (0, utils_js_1.objectAssign)(pageContext, routeResult.pageContextAddendum);
249
+ const pageContextFromRoute = await (0, index_js_1.route)(pageContext);
250
+ (0, utils_js_1.objectAssign)(pageContext, pageContextFromRoute);
251
251
  (0, utils_js_1.objectAssign)(pageContext, { is404: pageContext._pageId ? null : true });
252
252
  if (pageContext._pageId === null) {
253
253
  const errorPageId = (0, error_page_js_1.getErrorPageId)(pageContext._pageFilesAll, pageContext._pageConfigs);
@@ -274,7 +274,7 @@ async function getPageContextErrorPageInit(pageContextInit, errNominalPage, page
274
274
  routeParams: {}
275
275
  };
276
276
  (0, utils_js_1.objectAssign)(pageContext, {
277
- _routeMatches: pageContextNominalPagePartial._routeMatches || 'ROUTE_ERROR'
277
+ _debugRouteMatches: pageContextNominalPagePartial._debugRouteMatches || 'ROUTING_ERROR'
278
278
  });
279
279
  (0, utils_js_1.assert)(pageContext.errorWhileRendering);
280
280
  return pageContext;
@@ -44,7 +44,7 @@ __exportStar(require("../../utils/capitalizeFirstLetter.js"), exports);
44
44
  __exportStar(require("../../utils/debugGlob.js"), exports);
45
45
  __exportStar(require("../../utils/isEquivalentError.js"), exports);
46
46
  __exportStar(require("../../utils/styleFileRE.js"), exports);
47
- __exportStar(require("../../utils/hasPropertyGetter.js"), exports);
47
+ __exportStar(require("../../utils/isPropertyGetter.js"), exports);
48
48
  __exportStar(require("../../utils/debug.js"), exports);
49
49
  __exportStar(require("../../utils/urlToFile.js"), exports);
50
50
  __exportStar(require("../../utils/getGlobalObject.js"), exports);
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getClientEntryFilePath = void 0;
4
- const utils_js_1 = require("../../shared/page-configs/utils.js");
4
+ const helpers_js_1 = require("../../shared/page-configs/helpers.js");
5
5
  function getClientEntryFilePath(pageConfig) {
6
6
  const configName = 'client';
7
- const configValue = (0, utils_js_1.getConfigValue)(pageConfig, configName, 'string');
7
+ const configValue = (0, helpers_js_1.getConfigValue)(pageConfig, configName, 'string');
8
8
  if (!configValue)
9
9
  return null;
10
10
  return configValue.value;
@@ -1,8 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getConfigVike = void 0;
4
+ const utils_js_1 = require("./utils.js");
4
5
  async function getConfigVike(config) {
5
- const configVike = (await config.configVikePromise);
6
+ const { configVikePromise } = config;
7
+ (0, utils_js_1.assert)(configVikePromise);
8
+ const configVike = await configVikePromise;
6
9
  return configVike;
7
10
  }
8
11
  exports.getConfigVike = getConfigVike;
@@ -6,24 +6,36 @@ const utils_js_1 = require("./utils.js");
6
6
  function addUrlComputedProps(pageContext, enumerable = true) {
7
7
  (0, utils_js_1.assert)(pageContext.urlOriginal);
8
8
  if ('urlPathname' in pageContext) {
9
- (0, utils_js_1.assert)((0, utils_js_1.hasPropertyGetter)(pageContext, 'urlPathname'));
9
+ (0, utils_js_1.assert)(typeof pageContext.urlPathname === 'string');
10
+ /* If this assert() fails then it's most likely because Object.assign() was used instead of objectAssign(), i.e.:
11
+ ```js
12
+ // Add property getters such as pageContext.urlPathname to pageContext
13
+ addUrlComputedProps(pageContext)
14
+ // ❌ Breaks the property getters of pageContext set by addUrlComputedProps() such as pageContext.urlPathname
15
+ Object.assign(pageContext2, pageContext)
16
+ // ❌ Also breaks the property getters
17
+ const pageContext3 = { ...pageContext }
18
+ // ✅ Preserves property getters of pageContext (see objectAssign() implementation)
19
+ objectAssign(pageContext2, pageContext)
20
+ ```
21
+ */
22
+ (0, utils_js_1.assert)((0, utils_js_1.isPropertyGetter)(pageContext, 'urlPathname'));
10
23
  }
24
+ if ('urlParsed' in pageContext)
25
+ (0, utils_js_1.assert)((0, utils_js_1.isPropertyGetter)(pageContext, 'urlParsed'));
26
+ // TODO/v1-release: move pageContext.urlParsed to pageContext.url
27
+ if ('url' in pageContext)
28
+ (0, utils_js_1.assert)((0, utils_js_1.isPropertyGetter)(pageContext, 'url'));
11
29
  Object.defineProperty(pageContext, 'urlPathname', {
12
30
  get: urlPathnameGetter,
13
31
  enumerable,
14
32
  configurable: true
15
33
  });
16
- // TODO/v1-release: move pageContext.urlParsed to pageContext.url
17
- if ('url' in pageContext)
18
- (0, utils_js_1.assert)((0, utils_js_1.hasPropertyGetter)(pageContext, 'url'));
19
34
  Object.defineProperty(pageContext, 'url', {
20
35
  get: urlGetter,
21
36
  enumerable: false,
22
37
  configurable: true
23
38
  });
24
- if ('urlParsed' in pageContext) {
25
- (0, utils_js_1.assert)((0, utils_js_1.hasPropertyGetter)(pageContext, 'urlParsed'));
26
- }
27
39
  Object.defineProperty(pageContext, 'urlParsed', {
28
40
  get: urlParsedGetter,
29
41
  enumerable,
@@ -32,17 +44,17 @@ function addUrlComputedProps(pageContext, enumerable = true) {
32
44
  }
33
45
  exports.addUrlComputedProps = addUrlComputedProps;
34
46
  function getUrlParsed(pageContext) {
35
- // We use a url handler function because the onBeforeRoute() hook may modify pageContext.urlOriginal (e.g. for i18n)
47
+ // We need a url handler function because the onBeforeRoute() hook may set pageContext.urlLogical (typically for i18n)
36
48
  let urlHandler = pageContext._urlHandler;
37
49
  if (!urlHandler) {
38
50
  urlHandler = (url) => url;
39
51
  }
40
- const url = pageContext._urlRewrite ?? pageContext.urlOriginal;
41
- (0, utils_js_1.assert)(url && typeof url === 'string');
42
- const urlLogical = urlHandler(url);
52
+ let urlResolved = pageContext._urlRewrite ?? pageContext.urlLogical ?? pageContext.urlOriginal;
53
+ urlResolved = urlHandler(urlResolved);
43
54
  const baseServer = pageContext._baseServer;
55
+ (0, utils_js_1.assert)(urlResolved && typeof urlResolved === 'string');
44
56
  (0, utils_js_1.assert)(baseServer.startsWith('/'));
45
- return (0, utils_js_1.parseUrl)(urlLogical, baseServer);
57
+ return (0, utils_js_1.parseUrl)(urlResolved, baseServer);
46
58
  }
47
59
  function urlPathnameGetter() {
48
60
  const { pathname } = getUrlParsed(this);
@@ -1,19 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.analyzeClientSide = void 0;
4
- const utils_js_1 = require("../page-configs/utils.js");
4
+ const helpers_js_1 = require("../page-configs/helpers.js");
5
5
  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, utils_js_1.getConfigValue)(pageConfig, 'clientRouting', 'boolean')?.value ?? false;
10
- const isClientSideRenderable = (0, utils_js_1.getConfigValue)(pageConfig, 'isClientSideRenderable', 'boolean')?.value ?? false;
9
+ const isClientRouting = (0, helpers_js_1.getConfigValue)(pageConfig, 'clientRouting', 'boolean')?.value ?? false;
10
+ const isClientSideRenderable = (0, helpers_js_1.getConfigValue)(pageConfig, 'isClientSideRenderable', 'boolean')?.value ?? false;
11
11
  return { isClientSideRenderable, isClientRouting };
12
12
  }
13
13
  else {
14
- // TODO/v1-release:
15
- // - remove V0.4 implementation
16
- // - globally rename isHtmlOnly to !isClientSideRenderable
14
+ // TODO/v1-release: remove
17
15
  // V0.4 design
18
16
  const { isHtmlOnly, isClientRouting } = (0, analyzePageClientSide_js_1.analyzePageClientSide)(pageFilesAll, pageId);
19
17
  return { isClientSideRenderable: !isHtmlOnly, isClientRouting };
@@ -7,7 +7,7 @@ exports.getExports = exports.getExportUnion = void 0;
7
7
  const isScriptFile_js_1 = require("../../utils/isScriptFile.js");
8
8
  const utils_js_1 = require("../utils.js");
9
9
  const assert_exports_old_design_js_1 = require("./assert_exports_old_design.js");
10
- const utils_js_2 = require("../page-configs/utils.js");
10
+ const helpers_js_1 = require("../page-configs/helpers.js");
11
11
  const picocolors_1 = __importDefault(require("@brillout/picocolors"));
12
12
  function getExports(pageFiles, pageConfig) {
13
13
  const configEntries = {};
@@ -34,8 +34,8 @@ function getExports(pageFiles, pageConfig) {
34
34
  if (pageConfig) {
35
35
  Object.entries(pageConfig.configValues).forEach(([configName, configValue]) => {
36
36
  const { value } = configValue;
37
- const configValueFilePathToShowToUser = (0, utils_js_2.getConfigValueFilePathToShowToUser)(configValue);
38
- const configDefinedAt = (0, utils_js_2.getConfigDefinedAtString)(configName, configValue, true);
37
+ const configValueFilePathToShowToUser = (0, helpers_js_1.getConfigValueFilePathToShowToUser)(configValue);
38
+ const configDefinedAt = (0, helpers_js_1.getConfigDefinedAtString)('Config', configName, configValue);
39
39
  config[configName] = config[configName] ?? value;
40
40
  configEntries[configName] = configEntries[configName] ?? [];
41
41
  // Currently each configName has only one entry. Adding an entry for each overriden config value isn't implemented yet. (This is an isomorphic file and it isn't clear whether this can/should be implemented on the client-side. We should load a minimum amount of code on the client-side.)
@@ -25,7 +25,7 @@ exports.assertHook = assertHook;
25
25
  function assertHookFn(hookFn, { hookName, hookFilePath }) {
26
26
  (0, utils_js_1.assert)(hookName && hookFilePath);
27
27
  (0, utils_js_1.assert)(!hookName.endsWith(')'));
28
- (0, utils_js_1.assertUsage)((0, utils_js_1.isCallable)(hookFn), `hook ${hookName}() defined by ${hookFilePath} should be a function`);
28
+ (0, utils_js_1.assertUsage)((0, utils_js_1.isCallable)(hookFn), `Hook ${hookName}() defined by ${hookFilePath} should be a function`);
29
29
  (0, utils_js_1.checkType)(hookFn);
30
30
  }
31
31
  exports.assertHookFn = assertHookFn;
@@ -2,10 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getExportPath = void 0;
4
4
  const utils_js_1 = require("../utils.js");
5
- function getExportPath(fileExportPath, configName) {
6
- if (!fileExportPath)
5
+ function getExportPath(fileExportPathToShowToUser, configName) {
6
+ if (!fileExportPathToShowToUser)
7
7
  return null;
8
- let [exportName, ...exportObjectPath] = fileExportPath;
8
+ let [exportName, ...exportObjectPath] = fileExportPathToShowToUser;
9
9
  if (!exportName)
10
10
  return null;
11
11
  if (exportObjectPath.length === 0 && ['*', 'default', configName].includes(exportName))
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getDefinedAtString = exports.getConfigDefinedAtString = void 0;
7
+ const utils_js_1 = require("../../utils.js");
8
+ const picocolors_1 = __importDefault(require("@brillout/picocolors"));
9
+ const getExportPath_js_1 = require("../getExportPath.js");
10
+ function getConfigDefinedAtString(sentenceBegin, configName, { definedAt }) {
11
+ const definedAtString = getDefinedAtString(definedAt, configName);
12
+ const definedAtStr = definedAtString === 'internally' ? definedAtString : `at ${definedAtString}`;
13
+ let configNameStr = `${configName}${sentenceBegin === 'Hook' ? '()' : ''}`;
14
+ const configDefinedAt = `${sentenceBegin} ${picocolors_1.default.cyan(configNameStr)} defined ${definedAtStr}`;
15
+ return configDefinedAt;
16
+ }
17
+ exports.getConfigDefinedAtString = getConfigDefinedAtString;
18
+ function getDefinedAtString(definedAt, configName) {
19
+ if ('isComputed' in definedAt) {
20
+ return 'internally';
21
+ }
22
+ let files;
23
+ if ('files' in definedAt) {
24
+ files = definedAt.files;
25
+ }
26
+ else {
27
+ files = [definedAt];
28
+ }
29
+ (0, utils_js_1.assert)(files.length >= 1);
30
+ const definedAtString = files
31
+ .map((source) => {
32
+ const { filePathToShowToUser, fileExportPathToShowToUser } = source;
33
+ let s = filePathToShowToUser;
34
+ const exportPath = (0, getExportPath_js_1.getExportPath)(fileExportPathToShowToUser, configName);
35
+ if (exportPath) {
36
+ s = `${s} > ${picocolors_1.default.cyan(exportPath)}`;
37
+ }
38
+ return s;
39
+ })
40
+ .join(' / ');
41
+ return definedAtString;
42
+ }
43
+ exports.getDefinedAtString = getDefinedAtString;
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getConfigValue = void 0;
7
+ const utils_js_1 = require("../../utils.js");
8
+ const picocolors_1 = __importDefault(require("@brillout/picocolors"));
9
+ const getConfigDefinedAtString_js_1 = require("./getConfigDefinedAtString.js");
10
+ // prettier-ignore
11
+ function getConfigValue(pageConfig, configName, type) {
12
+ const configValue = getConfigValueEntry(pageConfig, configName);
13
+ if (configValue === null)
14
+ return null;
15
+ const { value, definedAt } = configValue;
16
+ if (type)
17
+ assertConfigValueType(value, type, configName, definedAt);
18
+ return configValue;
19
+ }
20
+ exports.getConfigValue = getConfigValue;
21
+ function assertConfigValueType(value, type, configName, definedAt) {
22
+ (0, utils_js_1.assert)(value !== null);
23
+ const typeActual = typeof value;
24
+ if (typeActual === type)
25
+ return;
26
+ const valuePrintable = (0, utils_js_1.getValuePrintable)(value);
27
+ const problem = valuePrintable !== null
28
+ ? `value ${picocolors_1.default.cyan(valuePrintable)}`
29
+ : `type ${picocolors_1.default.cyan(typeActual)}`;
30
+ const configDefinedAt = (0, getConfigDefinedAtString_js_1.getConfigDefinedAtString)('Config', configName, {
31
+ definedAt
32
+ });
33
+ const errMsg = `${configDefinedAt} has an invalid ${problem}: it should be a ${picocolors_1.default.cyan(type)} instead`;
34
+ (0, utils_js_1.assertUsage)(false, errMsg);
35
+ }
36
+ function getConfigValueEntry(pageConfig, configName) {
37
+ const configValue = pageConfig.configValues[configName];
38
+ if (!configValue)
39
+ return null;
40
+ // Enable users to suppress global config values by setting the local config value to null
41
+ if (configValue.value === null)
42
+ return null;
43
+ return configValue;
44
+ }
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getConfigValue = exports.getDefinedAtString = exports.getConfigDefinedAtString = exports.getHookFilePathToShowToUser = exports.getConfigValueFilePathToShowToUser = exports.getPageConfig = void 0;
4
+ var getConfigDefinedAtString_js_1 = require("./helpers/getConfigDefinedAtString.js");
5
+ Object.defineProperty(exports, "getConfigDefinedAtString", { enumerable: true, get: function () { return getConfigDefinedAtString_js_1.getConfigDefinedAtString; } });
6
+ Object.defineProperty(exports, "getDefinedAtString", { enumerable: true, get: function () { return getConfigDefinedAtString_js_1.getDefinedAtString; } });
7
+ var getConfigValue_js_1 = require("./helpers/getConfigValue.js");
8
+ Object.defineProperty(exports, "getConfigValue", { enumerable: true, get: function () { return getConfigValue_js_1.getConfigValue; } });
9
+ const utils_js_1 = require("../utils.js");
10
+ function getPageConfig(pageId, pageConfigs) {
11
+ const pageConfig = pageConfigs.find((p) => p.pageId === pageId);
12
+ (0, utils_js_1.assert)(pageConfigs.length > 0);
13
+ (0, utils_js_1.assert)(pageConfig);
14
+ return pageConfig;
15
+ }
16
+ exports.getPageConfig = getPageConfig;
17
+ function getConfigValueFilePathToShowToUser({ definedAt }) {
18
+ // A unique file path only exists if the config value isn't cumulative nor computed:
19
+ // - cumulative config values have multiple file paths
20
+ // - computed values don't have any file path
21
+ if ('isComputed' in definedAt || 'files' in definedAt)
22
+ return null;
23
+ const { filePathToShowToUser } = definedAt;
24
+ (0, utils_js_1.assert)(filePathToShowToUser);
25
+ return filePathToShowToUser;
26
+ }
27
+ exports.getConfigValueFilePathToShowToUser = getConfigValueFilePathToShowToUser;
28
+ function getHookFilePathToShowToUser({ definedAt }) {
29
+ const filePathToShowToUser = getConfigValueFilePathToShowToUser({ definedAt });
30
+ (0, utils_js_1.assert)(filePathToShowToUser);
31
+ return filePathToShowToUser;
32
+ }
33
+ exports.getHookFilePathToShowToUser = getHookFilePathToShowToUser;
@@ -4,7 +4,7 @@ exports.loadConfigValues = void 0;
4
4
  const utils_js_1 = require("../utils.js");
5
5
  const parseConfigValuesImported_js_1 = require("./serialize/parseConfigValuesImported.js");
6
6
  async function loadConfigValues(pageConfig, isDev) {
7
- if ('isLoaded' in pageConfig &&
7
+ if ('isAllLoaded' in pageConfig &&
8
8
  // We don't need to cache in dev, since Vite already caches the virtual module
9
9
  !isDev) {
10
10
  return pageConfig;
@@ -12,7 +12,7 @@ async function loadConfigValues(pageConfig, isDev) {
12
12
  const configValuesImported = await pageConfig.loadConfigValuesAll();
13
13
  const configValuesAddendum = (0, parseConfigValuesImported_js_1.parseConfigValuesImported)(configValuesImported);
14
14
  Object.assign(pageConfig.configValues, configValuesAddendum);
15
- (0, utils_js_1.objectAssign)(pageConfig, { isLoaded: true });
15
+ (0, utils_js_1.objectAssign)(pageConfig, { isAllLoaded: true });
16
16
  return pageConfig;
17
17
  }
18
18
  exports.loadConfigValues = loadConfigValues;
@@ -1,26 +1,20 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.parseConfigValuesImported = void 0;
7
4
  const utils_js_1 = require("../../utils.js");
8
5
  const assertExports_js_1 = require("../assertExports.js");
9
- const picocolors_1 = __importDefault(require("@brillout/picocolors"));
10
6
  function parseConfigValuesImported(configValuesImported) {
11
7
  const configValues = {};
12
8
  const addConfigValue = (configName, value, importPath, exportName) => {
13
9
  configValues[configName] = {
14
10
  value,
15
11
  definedAt: {
16
- file: {
17
- // importPath cannot be relative to the current file, since the current file is a virtual file
18
- filePathToShowToUser: importPath,
19
- fileExportPath: [configName, 'default'].includes(exportName)
20
- ? []
21
- : // Side-effect config
22
- [exportName]
23
- }
12
+ // importPath cannot be relative to the current file, since the current file is a virtual file
13
+ filePathToShowToUser: importPath,
14
+ fileExportPathToShowToUser: [configName, 'default'].includes(exportName)
15
+ ? []
16
+ : // Side-effect config
17
+ [exportName]
24
18
  }
25
19
  };
26
20
  assertIsNotNull(value, configName, importPath);
@@ -52,5 +46,12 @@ function parseConfigValuesImported(configValuesImported) {
52
46
  exports.parseConfigValuesImported = parseConfigValuesImported;
53
47
  function assertIsNotNull(configValue, configName, importPath) {
54
48
  (0, utils_js_1.assert)(!importPath.includes('+config.'));
55
- (0, utils_js_1.assertUsage)(configValue !== null, `Set ${picocolors_1.default.cyan(configName)} to ${picocolors_1.default.cyan('null')} in a +config.h.js file instead of ${importPath}`);
49
+ /* Re-use this for:
50
+ * - upcoming config.requestPageContextOnNavigation
51
+ * - for cumulative values in the future: we don't need this for now because, currently, cumulative values are never imported.
52
+ assertUsage(
53
+ configValue !== null,
54
+ `Set ${pc.cyan(configName)} to ${pc.cyan('null')} in a +config.h.js file instead of ${importPath}`
55
+ )
56
+ */
56
57
  }
@@ -4,7 +4,7 @@ exports.parsePageConfigs = void 0;
4
4
  const parse_1 = require("@brillout/json-serializer/parse");
5
5
  const parseConfigValuesImported_js_1 = require("./parseConfigValuesImported.js");
6
6
  const utils_js_1 = require("../../utils.js");
7
- const utils_js_2 = require("../utils.js");
7
+ const helpers_js_1 = require("../helpers.js");
8
8
  function parsePageConfigs(pageConfigsSerialized, pageConfigGlobalSerialized) {
9
9
  const pageConfigs = pageConfigsSerialized.map((pageConfigSerialized) => {
10
10
  const configValues = {};
@@ -52,7 +52,7 @@ function assertRouteConfigValue(configValues) {
52
52
  return;
53
53
  const { value } = configValue;
54
54
  const configValueType = typeof value;
55
- const configDefinedAt = (0, utils_js_2.getConfigDefinedAtString)(configName, configValue, true);
55
+ const configDefinedAt = (0, helpers_js_1.getConfigDefinedAtString)('Config', configName, configValue);
56
56
  (0, utils_js_1.assertUsage)(configValueType === 'string' || (0, utils_js_1.isCallable)(value), `${configDefinedAt} has an invalid type '${configValueType}': it should be a string or a function instead, see https://vike.dev/route`);
57
57
  /* We don't use assertRouteString() in order to avoid unnecessarily bloating the client-side bundle when using Server Routing:
58
58
  * - When using Server Routing, this file is loaded => loading assertRouteString() would bloat the client bundle.
@@ -28,29 +28,28 @@ exports.serializeConfigValue = serializeConfigValue;
28
28
  function serializeConfigValueImported(configValueSource, configName, whitespace, varCounterContainer, importStatements) {
29
29
  (0, utils_js_1.assert)(!configValueSource.valueIsFilePath);
30
30
  (0, utils_js_1.assert)(whitespace.replaceAll(' ', '').length === 0);
31
- const { valueIsImportedAtRuntime, definedAtInfo } = configValueSource;
31
+ const { valueIsImportedAtRuntime, definedAt } = configValueSource;
32
32
  (0, utils_js_1.assert)(valueIsImportedAtRuntime);
33
- const { filePathRelativeToUserRootDir, importPathAbsolute, exportName } = definedAtInfo;
34
- const importPath = filePathRelativeToUserRootDir ?? importPathAbsolute;
35
- (0, utils_js_1.assertPosixPath)(importPath);
36
- const fileName = path_1.default.posix.basename(importPath);
33
+ const { filePathAbsoluteVite, fileExportName } = definedAt;
34
+ (0, utils_js_1.assertPosixPath)(filePathAbsoluteVite);
35
+ const fileName = path_1.default.posix.basename(filePathAbsoluteVite);
37
36
  const isValueFile = fileName.startsWith('+');
38
37
  if (isValueFile)
39
- (0, utils_js_1.assert)(exportName === undefined);
40
- const { importName, importStatement } = (0, generateEagerImport_js_1.generateEagerImport)(importPath, varCounterContainer.varCounter++, exportName);
38
+ (0, utils_js_1.assert)(fileExportName === undefined);
39
+ const { importName, importStatement } = (0, generateEagerImport_js_1.generateEagerImport)(filePathAbsoluteVite, varCounterContainer.varCounter++, fileExportName);
41
40
  importStatements.push(importStatement);
42
41
  const lines = [];
43
42
  lines.push(` {`);
44
43
  lines.push(` configName: '${configName}',`);
45
- lines.push(` importPath: '${importPath}',`);
44
+ lines.push(` importPath: '${filePathAbsoluteVite}',`);
46
45
  lines.push(` isValueFile: ${JSON.stringify(isValueFile)},`);
47
46
  if (isValueFile) {
48
47
  lines.push(` exportValues: ${importName},`);
49
48
  }
50
49
  else {
51
50
  lines.push(` exportValue: ${importName},`);
52
- (0, utils_js_1.assert)(exportName);
53
- lines.push(` exportName: ${JSON.stringify(exportName)},`);
51
+ (0, utils_js_1.assert)(fileExportName);
52
+ lines.push(` exportName: ${JSON.stringify(fileExportName)},`);
54
53
  }
55
54
  lines.push(` },`);
56
55
  return lines;
@@ -39,7 +39,7 @@ exports.redirect = redirect;
39
39
  function render(value, abortReason) {
40
40
  const args = [typeof value === 'number' ? String(value) : JSON.stringify(value)];
41
41
  if (abortReason !== undefined)
42
- args.push((0, utils_js_1.truncateString)(JSON.stringify(abortReason), 30, null));
42
+ args.push((0, utils_js_1.truncateString)(JSON.stringify(abortReason), 30));
43
43
  const abortCaller = 'throw render()';
44
44
  const abortCall = `throw render(${args.join(', ')})`;
45
45
  return render_(value, abortReason, abortCall, abortCaller);