vike 0.4.218 → 0.4.219

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 (178) hide show
  1. package/dist/cjs/__internal/index.js +11 -11
  2. package/dist/cjs/node/api/build.js +20 -11
  3. package/dist/cjs/node/api/context.js +5 -1
  4. package/dist/cjs/node/api/index.js +17 -7
  5. package/dist/cjs/node/api/prepareViteApiCall.js +39 -11
  6. package/dist/cjs/node/cli/entry.js +19 -7
  7. package/dist/cjs/node/plugin/index.js +5 -5
  8. package/dist/cjs/node/plugin/plugins/autoFullBuild.js +3 -4
  9. package/dist/cjs/node/plugin/plugins/baseUrls.js +3 -10
  10. package/dist/cjs/node/plugin/plugins/buildConfig.js +2 -2
  11. package/dist/cjs/node/plugin/plugins/{importBuild → buildEntry}/index.js +16 -17
  12. package/dist/cjs/node/plugin/plugins/commonConfig.js +38 -3
  13. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +26 -23
  14. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +171 -68
  15. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js +1 -1
  16. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigs.js +4 -3
  17. package/dist/cjs/node/plugin/plugins/setGlobalContext.js +1 -1
  18. package/dist/cjs/node/plugin/plugins/{vite6HmrRegressionWorkaround.js → workaroundVite6HmrRegression.js} +3 -3
  19. package/dist/cjs/node/plugin/shared/getHttpRequestAsyncStore.js +17 -7
  20. package/dist/cjs/node/prerender/isPrerenderAutoRunEnabled.js +16 -0
  21. package/dist/cjs/node/prerender/runPrerender.js +94 -66
  22. package/dist/cjs/node/prerender/utils.js +1 -0
  23. package/dist/cjs/node/runtime/globalContext.js +108 -34
  24. package/dist/cjs/node/runtime/html/injectAssets/getHtmlTags.js +2 -2
  25. package/dist/cjs/node/runtime/index-common.js +0 -15
  26. package/dist/cjs/node/runtime/onLoad.js +17 -3
  27. package/dist/cjs/node/runtime/page-files/setup.js +2 -4
  28. package/dist/cjs/node/runtime/renderPage/analyzePage.js +2 -2
  29. package/dist/cjs/node/runtime/renderPage/createHttpResponse/getCacheControl.js +2 -2
  30. package/dist/cjs/node/runtime/renderPage/loadUserFilesServerSide.js +1 -1
  31. package/dist/cjs/node/runtime/renderPage/renderPageAlreadyRouted.js +11 -33
  32. package/dist/cjs/node/runtime/renderPage/resolveRedirects.js +9 -1
  33. package/dist/cjs/node/runtime/renderPage.js +21 -22
  34. package/dist/cjs/node/runtime/utils.js +1 -0
  35. package/dist/cjs/node/runtime-dev/index.js +17 -7
  36. package/dist/cjs/node/shared/assertRuntimeManifest.js +0 -2
  37. package/dist/cjs/shared/getPageFiles/analyzeClientSide.js +3 -3
  38. package/dist/cjs/shared/getPageFiles/{setPageFiles.js → getPageFiles.js} +8 -6
  39. package/dist/cjs/shared/getPageFiles.js +3 -9
  40. package/dist/cjs/shared/hooks/getHook.js +3 -3
  41. package/dist/cjs/shared/{getPageFiles/getExports.js → page-configs/getPageConfigUserFriendly.js} +113 -81
  42. package/dist/cjs/shared/page-configs/serialize/serializeConfigValues.js +80 -55
  43. package/dist/cjs/shared/route/loadPageRoutes.js +3 -3
  44. package/dist/cjs/shared/utils.js +1 -0
  45. package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
  46. package/dist/cjs/utils/assert.js +4 -3
  47. package/dist/cjs/utils/assertSetup.js +33 -16
  48. package/dist/cjs/utils/debug.js +11 -6
  49. package/dist/cjs/utils/getGlobalObject.js +1 -2
  50. package/dist/cjs/utils/objectReplace.js +9 -0
  51. package/dist/esm/__internal/index.d.ts +3 -5
  52. package/dist/esm/__internal/index.js +6 -8
  53. package/dist/esm/client/client-routing-runtime/createPageContext.js +4 -1
  54. package/dist/esm/client/client-routing-runtime/entry.d.ts +1 -1
  55. package/dist/esm/client/client-routing-runtime/entry.js +0 -1
  56. package/dist/esm/client/client-routing-runtime/getPageContextCurrent.d.ts +2 -2
  57. package/dist/esm/client/client-routing-runtime/getPageContextFromHooks.d.ts +4 -4
  58. package/dist/esm/client/client-routing-runtime/getPageContextFromHooks.js +1 -1
  59. package/dist/esm/client/client-routing-runtime/prefetch/getPrefetchSettings.d.ts +2 -2
  60. package/dist/esm/client/client-routing-runtime/prefetch.d.ts +2 -2
  61. package/dist/esm/client/client-routing-runtime/prefetch.js +2 -2
  62. package/dist/esm/client/server-routing-runtime/entry.d.ts +1 -1
  63. package/dist/esm/client/server-routing-runtime/entry.js +0 -1
  64. package/dist/esm/client/server-routing-runtime/getPageContext.d.ts +1 -1
  65. package/dist/esm/client/server-routing-runtime/getPageContext.js +5 -2
  66. package/dist/esm/client/shared/executeOnRenderClientHook.d.ts +2 -2
  67. package/dist/esm/client/shared/loadUserFilesClientSide.d.ts +2 -2
  68. package/dist/esm/client/shared/loadUserFilesClientSide.js +2 -2
  69. package/dist/esm/client/shared/preparePageContextForUserConsumptionClientSide.d.ts +2 -2
  70. package/dist/esm/node/api/build.js +3 -4
  71. package/dist/esm/node/api/context.d.ts +3 -1
  72. package/dist/esm/node/api/context.js +6 -2
  73. package/dist/esm/node/api/prepareViteApiCall.d.ts +1 -1
  74. package/dist/esm/node/api/prepareViteApiCall.js +25 -7
  75. package/dist/esm/node/cli/entry.js +2 -0
  76. package/dist/esm/node/cli/parseCli.d.ts +1 -1
  77. package/dist/esm/node/plugin/index.d.ts +1 -1
  78. package/dist/esm/node/plugin/index.js +5 -5
  79. package/dist/esm/node/plugin/plugins/autoFullBuild.js +3 -4
  80. package/dist/esm/node/plugin/plugins/baseUrls.d.ts +1 -1
  81. package/dist/esm/node/plugin/plugins/baseUrls.js +4 -11
  82. package/dist/esm/node/plugin/plugins/buildConfig.js +2 -2
  83. package/dist/esm/node/plugin/plugins/{importBuild → buildEntry}/getVikeManifest.d.ts +1 -1
  84. package/dist/esm/node/plugin/plugins/{importBuild → buildEntry}/index.d.ts +2 -2
  85. package/dist/esm/node/plugin/plugins/{importBuild → buildEntry}/index.js +16 -17
  86. package/dist/esm/node/plugin/plugins/commonConfig.d.ts +3 -0
  87. package/dist/esm/node/plugin/plugins/commonConfig.js +39 -4
  88. package/dist/esm/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.d.ts +1 -1
  89. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.d.ts +6 -9
  90. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +25 -22
  91. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.d.ts +96 -1
  92. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +167 -64
  93. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js +1 -1
  94. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigs.js +4 -3
  95. package/dist/esm/node/plugin/plugins/setGlobalContext.js +1 -1
  96. package/dist/esm/node/plugin/plugins/workaroundVite6HmrRegression.d.ts +3 -0
  97. package/dist/esm/node/plugin/plugins/{vite6HmrRegressionWorkaround.js → workaroundVite6HmrRegression.js} +3 -3
  98. package/dist/esm/node/prerender/isPrerenderAutoRunEnabled.d.ts +5 -0
  99. package/dist/esm/node/prerender/isPrerenderAutoRunEnabled.js +14 -0
  100. package/dist/esm/node/prerender/runPrerender.d.ts +1 -2
  101. package/dist/esm/node/prerender/runPrerender.js +78 -60
  102. package/dist/esm/node/prerender/utils.d.ts +1 -0
  103. package/dist/esm/node/prerender/utils.js +1 -0
  104. package/dist/esm/node/runtime/globalContext.d.ts +23 -7
  105. package/dist/esm/node/runtime/globalContext.js +108 -34
  106. package/dist/esm/node/runtime/html/injectAssets/getHtmlTags.js +1 -1
  107. package/dist/esm/node/runtime/index-common.d.ts +0 -1
  108. package/dist/esm/node/runtime/index-common.js +0 -15
  109. package/dist/esm/node/runtime/index-deprecated.d.ts +1 -0
  110. package/dist/esm/node/runtime/onLoad.js +16 -2
  111. package/dist/esm/node/runtime/page-files/setup.js +3 -3
  112. package/dist/esm/node/runtime/renderPage/analyzePage.js +1 -1
  113. package/dist/esm/node/runtime/renderPage/createHttpResponse/getCacheControl.js +1 -1
  114. package/dist/esm/node/runtime/renderPage/executeOnBeforeRenderAndDataHooks.d.ts +2 -2
  115. package/dist/esm/node/runtime/renderPage/loadUserFilesServerSide.d.ts +1 -1
  116. package/dist/esm/node/runtime/renderPage/loadUserFilesServerSide.js +2 -2
  117. package/dist/esm/node/runtime/renderPage/preparePageContextForUserConsumptionServerSide.d.ts +2 -2
  118. package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.d.ts +31 -46
  119. package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.js +11 -33
  120. package/dist/esm/node/runtime/renderPage/resolveRedirects.d.ts +1 -1
  121. package/dist/esm/node/runtime/renderPage/resolveRedirects.js +9 -1
  122. package/dist/esm/node/runtime/renderPage.js +22 -23
  123. package/dist/esm/node/runtime/utils.d.ts +1 -0
  124. package/dist/esm/node/runtime/utils.js +1 -0
  125. package/dist/esm/node/shared/assertPluginManifest.d.ts +0 -1
  126. package/dist/esm/node/shared/assertRuntimeManifest.d.ts +0 -1
  127. package/dist/esm/node/shared/assertRuntimeManifest.js +1 -3
  128. package/dist/esm/shared/getPageFiles/analyzeClientSide.js +1 -1
  129. package/dist/esm/shared/getPageFiles/{setPageFiles.d.ts → getPageFiles.d.ts} +3 -1
  130. package/dist/esm/shared/getPageFiles/{setPageFiles.js → getPageFiles.js} +8 -6
  131. package/dist/esm/shared/getPageFiles.d.ts +2 -5
  132. package/dist/esm/shared/getPageFiles.js +1 -4
  133. package/dist/esm/shared/hooks/getHook.d.ts +3 -3
  134. package/dist/esm/shared/hooks/getHook.js +1 -1
  135. package/dist/esm/shared/page-configs/Config/PageContextConfig.d.ts +9 -5
  136. package/dist/esm/shared/page-configs/Config.d.ts +20 -2
  137. package/dist/esm/shared/page-configs/PageConfig.d.ts +7 -3
  138. package/dist/esm/shared/{getPageFiles/getExports.d.ts → page-configs/getPageConfigUserFriendly.d.ts} +26 -12
  139. package/dist/esm/shared/{getPageFiles/getExports.js → page-configs/getPageConfigUserFriendly.js} +112 -80
  140. package/dist/esm/shared/page-configs/serialize/serializeConfigValues.d.ts +26 -6
  141. package/dist/esm/shared/page-configs/serialize/serializeConfigValues.js +80 -55
  142. package/dist/esm/shared/route/executeGuardHook.d.ts +2 -2
  143. package/dist/esm/shared/route/loadPageRoutes.js +1 -1
  144. package/dist/esm/shared/types.d.ts +1 -1
  145. package/dist/esm/shared/utils.d.ts +1 -0
  146. package/dist/esm/shared/utils.js +1 -0
  147. package/dist/esm/types/index.d.ts +1 -1
  148. package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
  149. package/dist/esm/utils/PROJECT_VERSION.js +1 -1
  150. package/dist/esm/utils/assert.js +4 -3
  151. package/dist/esm/utils/assertSetup.js +33 -16
  152. package/dist/esm/utils/debug.d.ts +1 -1
  153. package/dist/esm/utils/debug.js +11 -6
  154. package/dist/esm/utils/getGlobalObject.js +1 -2
  155. package/dist/esm/utils/objectReplace.d.ts +1 -0
  156. package/dist/esm/utils/objectReplace.js +6 -0
  157. package/dist/esm/utils/projectInfo.d.ts +1 -1
  158. package/package.json +4 -13
  159. package/__internal/loadImportBuild.js +0 -3
  160. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveVikeConfigGlobal.js +0 -128
  161. package/dist/cjs/node/runtime/globalContext/loadImportBuild.js +0 -25
  162. package/dist/cjs/node/runtime/page-files/getPageFilesExports.js +0 -22
  163. package/dist/esm/client/client-routing-runtime/pageFiles.d.ts +0 -1
  164. package/dist/esm/client/client-routing-runtime/pageFiles.js +0 -4
  165. package/dist/esm/client/server-routing-runtime/pageFiles.d.ts +0 -1
  166. package/dist/esm/client/server-routing-runtime/pageFiles.js +0 -4
  167. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveVikeConfigGlobal.d.ts +0 -104
  168. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveVikeConfigGlobal.js +0 -123
  169. package/dist/esm/node/plugin/plugins/vite6HmrRegressionWorkaround.d.ts +0 -3
  170. package/dist/esm/node/runtime/globalContext/loadImportBuild.d.ts +0 -18
  171. package/dist/esm/node/runtime/globalContext/loadImportBuild.js +0 -23
  172. package/dist/esm/node/runtime/page-files/getPageFilesExports.d.ts +0 -2
  173. package/dist/esm/node/runtime/page-files/getPageFilesExports.js +0 -20
  174. /package/dist/cjs/node/plugin/plugins/{importBuild → buildEntry}/getVikeManifest.js +0 -0
  175. /package/dist/cjs/shared/page-configs/{getConfigValue.js → getConfigValueRuntime.js} +0 -0
  176. /package/dist/esm/node/plugin/plugins/{importBuild → buildEntry}/getVikeManifest.js +0 -0
  177. /package/dist/esm/shared/page-configs/{getConfigValue.d.ts → getConfigValueRuntime.d.ts} +0 -0
  178. /package/dist/esm/shared/page-configs/{getConfigValue.js → getConfigValueRuntime.js} +0 -0
@@ -28,7 +28,10 @@ const resolvePointerImport_js_1 = require("./getVikeConfig/resolvePointerImport.
28
28
  const getFilePath_js_1 = require("../../../shared/getFilePath.js");
29
29
  const getConfigValueBuildTime_js_1 = require("../../../../../shared/page-configs/getConfigValueBuildTime.js");
30
30
  const assertExtensions_js_1 = require("./assertExtensions.js");
31
- const resolveVikeConfigGlobal_js_1 = require("./getVikeConfig/resolveVikeConfigGlobal.js");
31
+ const getPageConfigUserFriendly_js_1 = require("../../../../../shared/page-configs/getPageConfigUserFriendly.js");
32
+ const serializeConfigValues_js_1 = require("../../../../../shared/page-configs/serialize/serializeConfigValues.js");
33
+ const configDefinitionsBuiltIn = getConfigDefinitionsBuiltIn();
34
+ const configDefinitionsBuiltInGlobal = getConfigDefinitionsBuiltInGlobal();
32
35
  (0, utils_js_1.assertIsNotProductionRuntime)();
33
36
  let restartVite = false;
34
37
  let wasConfigInvalid = null;
@@ -166,7 +169,7 @@ async function loadInterfaceFiles(userRootDir) {
166
169
  // We don't have access to the custom config definitions defined by the user yet.
167
170
  // - If `configDef` is `undefined` => we load the file +{configName}.js later.
168
171
  // - We already need to load +meta.js here (to get the custom config definitions defined by the user)
169
- const configDef = getConfigDefinitionOptional(configDefinitionsBuiltIn_js_1.configDefinitionsBuiltIn, configName);
172
+ const configDef = getConfigDefinitionOptional(configDefinitionsBuiltIn, configName);
170
173
  if (configDef && isLoadableAtBuildTime(configDef)) {
171
174
  await (0, loadFileAtConfigTime_js_1.loadValueFile)(interfaceFile, configName, userRootDir);
172
175
  }
@@ -245,7 +248,8 @@ async function loadVikeConfig_withErrorHandling(userRootDir, isDev, vikeVitePlug
245
248
  configDefinitions: {},
246
249
  configValueSources: {}
247
250
  },
248
- vikeConfigGlobal: (0, resolveVikeConfigGlobal_js_1.resolveVikeConfigGlobal)({}, {})
251
+ vikeConfigGlobal: resolveVikeConfigGlobal({}, {}),
252
+ global: (0, getPageConfigUserFriendly_js_1.getPageConfigUserFriendlyNew)({ configValues: {} })
249
253
  };
250
254
  return dummyData;
251
255
  }
@@ -254,8 +258,97 @@ async function loadVikeConfig_withErrorHandling(userRootDir, isDev, vikeVitePlug
254
258
  async function loadVikeConfig(userRootDir, vikeVitePluginOptions) {
255
259
  const interfaceFilesByLocationId = await loadInterfaceFiles(userRootDir);
256
260
  const importedFilesLoaded = {};
257
- const { pageConfigGlobal, pageConfigGlobalValues } = await getGlobalConfigs(interfaceFilesByLocationId, userRootDir, importedFilesLoaded);
258
- const vikeConfigGlobal = (0, resolveVikeConfigGlobal_js_1.resolveVikeConfigGlobal)(vikeVitePluginOptions, pageConfigGlobalValues);
261
+ const [globalConfigs, pageConfigs] = await Promise.all([
262
+ getGlobalConfigs(interfaceFilesByLocationId, userRootDir, importedFilesLoaded, vikeVitePluginOptions),
263
+ getPageConfigs(interfaceFilesByLocationId, userRootDir, importedFilesLoaded)
264
+ ]);
265
+ return { pageConfigs, ...globalConfigs };
266
+ }
267
+ async function getGlobalConfigs(interfaceFilesByLocationId, userRootDir, importedFilesLoaded, vikeVitePluginOptions) {
268
+ const locationIds = (0, utils_js_1.objectKeys)(interfaceFilesByLocationId);
269
+ const interfaceFilesGlobal = (0, utils_js_1.objectFromEntries)((0, utils_js_1.objectEntries)(interfaceFilesByLocationId).filter(([locationId]) => {
270
+ return (0, filesystemRouting_js_1.isGlobalLocation)(locationId, locationIds);
271
+ }));
272
+ // Validate that global configs live in global interface files
273
+ {
274
+ const interfaceFilesGlobalPaths = [];
275
+ (0, utils_js_1.objectEntries)(interfaceFilesGlobal).forEach(([locationId, interfaceFiles]) => {
276
+ (0, utils_js_1.assert)((0, filesystemRouting_js_1.isGlobalLocation)(locationId, locationIds));
277
+ interfaceFiles.forEach(({ filePath: { filePathAbsoluteUserRootDir } }) => {
278
+ if (filePathAbsoluteUserRootDir) {
279
+ interfaceFilesGlobalPaths.push(filePathAbsoluteUserRootDir);
280
+ }
281
+ });
282
+ });
283
+ const globalPaths = Array.from(new Set(interfaceFilesGlobalPaths.map((p) => path_1.default.posix.dirname(p))));
284
+ (0, utils_js_1.objectEntries)(interfaceFilesByLocationId).forEach(([locationId, interfaceFiles]) => {
285
+ interfaceFiles.forEach((interfaceFile) => {
286
+ Object.keys(interfaceFile.fileExportsByConfigName).forEach((configName) => {
287
+ if (!(0, filesystemRouting_js_1.isGlobalLocation)(locationId, locationIds) && isGlobalConfig(configName)) {
288
+ (0, utils_js_1.assertUsage)(false, [
289
+ `${interfaceFile.filePath.filePathToShowToUser} defines the config ${picocolors_1.default.cyan(configName)} which is global:`,
290
+ globalPaths.length
291
+ ? `define ${picocolors_1.default.cyan(configName)} in ${(0, utils_js_1.joinEnglish)(globalPaths, 'or')} instead`
292
+ : `create a global config (e.g. /pages/+config.js) and define ${picocolors_1.default.cyan(configName)} there instead`
293
+ ].join(' '));
294
+ }
295
+ });
296
+ });
297
+ });
298
+ }
299
+ const pageConfigGlobalValues = {};
300
+ const pageConfigGlobal = {
301
+ configDefinitions: configDefinitionsBuiltInGlobal,
302
+ configValueSources: {}
303
+ };
304
+ await Promise.all((0, utils_js_1.objectEntries)(configDefinitionsBuiltInGlobal).map(async ([configName, configDef]) => {
305
+ const sources = await resolveConfigValueSources(configName, configDef, interfaceFilesGlobal, userRootDir, importedFilesLoaded);
306
+ const configValueSource = sources[0];
307
+ if (!configValueSource)
308
+ return;
309
+ pageConfigGlobal.configValueSources[configName] = sources;
310
+ // TODO/now
311
+ if (configName === 'onBeforeRoute' || configName === 'onPrerenderStart') {
312
+ (0, utils_js_1.assert)(!('value' in configValueSource));
313
+ }
314
+ else {
315
+ (0, utils_js_1.assert)('value' in configValueSource);
316
+ // TODO/now
317
+ if (configName === 'prerender' && typeof configValueSource.value === 'boolean')
318
+ return;
319
+ pageConfigGlobalValues[configName] = configValueSource.value;
320
+ }
321
+ }));
322
+ const vikeConfigGlobal = resolveVikeConfigGlobal(vikeVitePluginOptions, pageConfigGlobalValues);
323
+ {
324
+ (0, utils_js_1.assert)((0, utils_js_1.isObject)(vikeVitePluginOptions));
325
+ Object.entries(vikeVitePluginOptions).forEach(([configName, value]) => {
326
+ var _a;
327
+ (0, utils_js_1.assert)((0, utils_js_1.includes)((0, utils_js_1.objectKeys)(configDefinitionsBuiltInGlobal), configName));
328
+ const configDef = configDefinitionsBuiltInGlobal[configName];
329
+ const sources = ((_a = pageConfigGlobal.configValueSources)[configName] ?? (_a[configName] = []));
330
+ sources.push({
331
+ value,
332
+ configEnv: configDef.env,
333
+ definedAtFilePath: {
334
+ ...(0, getFilePath_js_1.getFilePathResolved)({
335
+ userRootDir,
336
+ filePathAbsoluteUserRootDir: '/vite.config.js'
337
+ }),
338
+ fileExportPathToShowToUser: null
339
+ },
340
+ locationId: '/',
341
+ isOverriden: configDef.cumulative ? false : sources.length > 0,
342
+ valueIsImportedAtRuntime: false,
343
+ valueIsDefinedByPlusFile: false
344
+ });
345
+ });
346
+ }
347
+ const configValues = getConfigValues(pageConfigGlobal);
348
+ const global = (0, getPageConfigUserFriendly_js_1.getPageConfigUserFriendlyNew)({ configValues });
349
+ return { pageConfigGlobal, vikeConfigGlobal, global };
350
+ }
351
+ async function getPageConfigs(interfaceFilesByLocationId, userRootDir, importedFilesLoaded) {
259
352
  const pageConfigs = await Promise.all((0, utils_js_1.objectEntries)(interfaceFilesByLocationId)
260
353
  .filter(([_pageId, interfaceFiles]) => isDefiningPage(interfaceFiles))
261
354
  .map(async ([locationId]) => {
@@ -277,7 +370,7 @@ async function loadVikeConfig(userRootDir, vikeVitePluginOptions) {
277
370
  if (isAlreadyLoaded)
278
371
  return;
279
372
  // Value files of built-in configs should have already been loaded at loadInterfaceFiles()
280
- (0, utils_js_1.assert)(!(configName in configDefinitionsBuiltIn_js_1.configDefinitionsBuiltIn));
373
+ (0, utils_js_1.assert)(!(configName in configDefinitionsBuiltIn));
281
374
  await (0, loadFileAtConfigTime_js_1.loadValueFile)(interfaceFile, configName, userRootDir);
282
375
  }));
283
376
  let configValueSources = {};
@@ -305,9 +398,37 @@ async function loadVikeConfig(userRootDir, vikeVitePluginOptions) {
305
398
  return pageConfig;
306
399
  }));
307
400
  assertPageConfigs(pageConfigs);
308
- return { pageConfigs, pageConfigGlobal, vikeConfigGlobal };
401
+ return pageConfigs;
309
402
  }
310
- // TODO/soon: refactor
403
+ function getConfigValues(pageConfig) {
404
+ const configValues = {};
405
+ (0, serializeConfigValues_js_1.getConfigValuesBase)(pageConfig, (configEnv) => !!configEnv.config, null).forEach((entry) => {
406
+ if (entry.configValueBase.type === 'computed') {
407
+ (0, utils_js_1.assert)('value' in entry); // Help TS
408
+ const { configValueBase, value, configName } = entry;
409
+ configValues[configName] = { ...configValueBase, value };
410
+ }
411
+ if (entry.configValueBase.type === 'standard') {
412
+ (0, utils_js_1.assert)('sourceRelevant' in entry); // Help TS
413
+ const { configValueBase, sourceRelevant, configName } = entry;
414
+ (0, utils_js_1.assert)('value' in sourceRelevant);
415
+ const { value } = sourceRelevant;
416
+ configValues[configName] = { ...configValueBase, value };
417
+ }
418
+ if (entry.configValueBase.type === 'cumulative') {
419
+ (0, utils_js_1.assert)('sourcesRelevant' in entry); // Help TS
420
+ const { configValueBase, sourcesRelevant, configName } = entry;
421
+ const values = [];
422
+ sourcesRelevant.forEach((source) => {
423
+ (0, utils_js_1.assert)('value' in source);
424
+ values.push(source.value);
425
+ });
426
+ configValues[configName] = { ...configValueBase, value: values };
427
+ }
428
+ });
429
+ return configValues;
430
+ }
431
+ // TODO/now: refactor
311
432
  // - Dedupe: most of the assertUsageGlobalConfigs() code below is a copy-paste of the assertUsage() logic inside getGlobalConfigs()
312
433
  // - This assertUsage() message is slightly better: use this one for getGlobalConfigs()
313
434
  // Global configs should be defined at global locations
@@ -324,7 +445,7 @@ function assertUsageGlobalConfigs(interfaceFilesRelevantList, configDefinitions,
324
445
  if (isGlobalConfig(configName))
325
446
  return;
326
447
  const configDef = getConfigDefinition(configDefinitions, configName, interfaceFile.filePath.filePathToShowToUser);
327
- if (configDef.global) {
448
+ if (configDef.global === true) {
328
449
  const locationIds = (0, utils_js_1.objectKeys)(interfaceFilesByLocationId);
329
450
  if (!(0, filesystemRouting_js_1.isGlobalLocation)(interfaceFile.locationId, locationIds)) {
330
451
  const interfaceFilesGlobal = (0, utils_js_1.objectFromEntries)((0, utils_js_1.objectEntries)(interfaceFilesByLocationId).filter(([locationId]) => {
@@ -383,63 +504,6 @@ function getInterfaceFilesRelevant(interfaceFilesByLocationId, locationIdPage) {
383
504
  .sort(([locationId1], [locationId2]) => (0, filesystemRouting_js_1.sortAfterInheritanceOrder)(locationId1, locationId2, locationIdPage)));
384
505
  return interfaceFilesRelevant;
385
506
  }
386
- async function getGlobalConfigs(interfaceFilesByLocationId, userRootDir, importedFilesLoaded) {
387
- const locationIds = (0, utils_js_1.objectKeys)(interfaceFilesByLocationId);
388
- const interfaceFilesGlobal = (0, utils_js_1.objectFromEntries)((0, utils_js_1.objectEntries)(interfaceFilesByLocationId).filter(([locationId]) => {
389
- return (0, filesystemRouting_js_1.isGlobalLocation)(locationId, locationIds);
390
- }));
391
- // Validate that global configs live in global interface files
392
- {
393
- const interfaceFilesGlobalPaths = [];
394
- (0, utils_js_1.objectEntries)(interfaceFilesGlobal).forEach(([locationId, interfaceFiles]) => {
395
- (0, utils_js_1.assert)((0, filesystemRouting_js_1.isGlobalLocation)(locationId, locationIds));
396
- interfaceFiles.forEach(({ filePath: { filePathAbsoluteUserRootDir } }) => {
397
- if (filePathAbsoluteUserRootDir) {
398
- interfaceFilesGlobalPaths.push(filePathAbsoluteUserRootDir);
399
- }
400
- });
401
- });
402
- const globalPaths = Array.from(new Set(interfaceFilesGlobalPaths.map((p) => path_1.default.posix.dirname(p))));
403
- (0, utils_js_1.objectEntries)(interfaceFilesByLocationId).forEach(([locationId, interfaceFiles]) => {
404
- interfaceFiles.forEach((interfaceFile) => {
405
- Object.keys(interfaceFile.fileExportsByConfigName).forEach((configName) => {
406
- if (!(0, filesystemRouting_js_1.isGlobalLocation)(locationId, locationIds) && isGlobalConfig(configName)) {
407
- (0, utils_js_1.assertUsage)(false, [
408
- `${interfaceFile.filePath.filePathToShowToUser} defines the config ${picocolors_1.default.cyan(configName)} which is global:`,
409
- globalPaths.length
410
- ? `define ${picocolors_1.default.cyan(configName)} in ${(0, utils_js_1.joinEnglish)(globalPaths, 'or')} instead`
411
- : `create a global config (e.g. /pages/+config.js) and define ${picocolors_1.default.cyan(configName)} there instead`
412
- ].join(' '));
413
- }
414
- });
415
- });
416
- });
417
- }
418
- const pageConfigGlobalValues = {};
419
- const pageConfigGlobal = {
420
- configDefinitions: configDefinitionsBuiltIn_js_1.configDefinitionsBuiltInGlobal,
421
- configValueSources: {}
422
- };
423
- await Promise.all((0, utils_js_1.objectEntries)(configDefinitionsBuiltIn_js_1.configDefinitionsBuiltInGlobal).map(async ([configName, configDef]) => {
424
- const sources = await resolveConfigValueSources(configName, configDef, interfaceFilesGlobal, userRootDir, importedFilesLoaded);
425
- const configValueSource = sources[0];
426
- if (!configValueSource)
427
- return;
428
- if (configName === 'onBeforeRoute' || configName === 'onPrerenderStart') {
429
- (0, utils_js_1.assert)(!('value' in configValueSource));
430
- pageConfigGlobal.configValueSources[configName] = [configValueSource];
431
- }
432
- else {
433
- (0, utils_js_1.assert)('value' in configValueSource);
434
- if (configName === 'prerender' && typeof configValueSource.value === 'boolean')
435
- return;
436
- const { filePathToShowToUser } = configValueSource.definedAtFilePath;
437
- (0, utils_js_1.assertWarning)(false, `Being able to define config ${picocolors_1.default.cyan(configName)} in ${filePathToShowToUser} is experimental and will likely be removed. Define the config ${picocolors_1.default.cyan(configName)} in Vike's Vite plugin options instead.`, { onlyOnce: true });
438
- pageConfigGlobalValues[configName] = configValueSource.value;
439
- }
440
- }));
441
- return { pageConfigGlobal, pageConfigGlobalValues };
442
- }
443
507
  async function resolveConfigValueSources(configName, configDef, interfaceFilesRelevant, userRootDir, importedFilesLoaded) {
444
508
  const sourcesInfo = [];
445
509
  // interfaceFilesRelevant is sorted by sortAfterInheritanceOrder()
@@ -653,7 +717,7 @@ function isDefiningPageConfig(configName) {
653
717
  return ['Page', 'route'].includes(configName);
654
718
  }
655
719
  function getConfigDefinitions(interfaceFilesRelevant) {
656
- const configDefinitionsMerged = { ...configDefinitionsBuiltIn_js_1.configDefinitionsBuiltIn };
720
+ const configDefinitionsMerged = { ...configDefinitionsBuiltIn };
657
721
  Object.entries(interfaceFilesRelevant)
658
722
  .reverse()
659
723
  .forEach(([_locationId, interfaceFiles]) => {
@@ -982,13 +1046,20 @@ function isLoadableAtBuildTime(configDef) {
982
1046
  return !!configDef.env.config && !configDef._valueIsFilePath;
983
1047
  }
984
1048
  function isGlobalConfig(configName) {
1049
+ // TODO/now
985
1050
  if (configName === 'prerender')
986
1051
  return false;
987
1052
  const configNamesGlobal = getConfigNamesGlobal();
988
1053
  return (0, utils_js_1.includes)(configNamesGlobal, configName);
989
1054
  }
990
1055
  function getConfigNamesGlobal() {
991
- return Object.keys(configDefinitionsBuiltIn_js_1.configDefinitionsBuiltInGlobal);
1056
+ return Object.keys(configDefinitionsBuiltInGlobal);
1057
+ }
1058
+ function getConfigDefinitionsBuiltInGlobal() {
1059
+ return (0, utils_js_1.objectFromEntries)((0, utils_js_1.objectEntries)(configDefinitionsBuiltIn_js_1.configDefinitionsBuiltInAll).filter(([_configName, configDef]) => configDef.global !== undefined));
1060
+ }
1061
+ function getConfigDefinitionsBuiltIn() {
1062
+ return (0, utils_js_1.objectFromEntries)((0, utils_js_1.objectEntries)(configDefinitionsBuiltIn_js_1.configDefinitionsBuiltInAll).filter(([_configName, configDef]) => configDef.global !== true));
992
1063
  }
993
1064
  function assertConfigExists(configName, configNamesRelevant, filePathToShowToUser) {
994
1065
  const configNames = [...configNamesRelevant, ...getConfigNamesGlobal()];
@@ -1016,3 +1087,35 @@ function sortConfigValueSources(configValueSources, locationIdPage) {
1016
1087
  function getConfigValueInterfaceFile(interfaceFile, configName) {
1017
1088
  return interfaceFile.fileExportsByConfigName[configName]?.configValue;
1018
1089
  }
1090
+ // TODO/now: refactor code below
1091
+ function resolveVikeConfigGlobal(vikeVitePluginOptions, pageConfigGlobalValues) {
1092
+ const configs = [vikeVitePluginOptions, pageConfigGlobalValues];
1093
+ const vikeConfigGlobal = {
1094
+ disableAutoFullBuild: pickFirst(configs.map((c) => c.disableAutoFullBuild)) ?? null,
1095
+ prerender: resolvePrerenderOptions(configs),
1096
+ includeAssetsImportedByServer: pickFirst(configs.map((c) => c.includeAssetsImportedByServer)) ?? true,
1097
+ baseServer: pickFirst(configs.map((c) => c.baseServer)) ?? null,
1098
+ baseAssets: pickFirst(configs.map((c) => c.baseAssets)) ?? null,
1099
+ disableUrlNormalization: pickFirst(configs.map((c) => c.disableUrlNormalization)) ?? false,
1100
+ trailingSlash: pickFirst(configs.map((c) => c.trailingSlash)) ?? false
1101
+ };
1102
+ return vikeConfigGlobal;
1103
+ }
1104
+ function resolvePrerenderOptions(configs) {
1105
+ if (!configs.some((c) => c.prerender)) {
1106
+ return false;
1107
+ }
1108
+ const configsPrerender = configs.map((c) => c.prerender).filter(isObject2);
1109
+ return {
1110
+ partial: pickFirst(configsPrerender.map((c) => c.partial)) ?? false,
1111
+ noExtraDir: pickFirst(configsPrerender.map((c) => c.noExtraDir)) ?? false,
1112
+ parallel: pickFirst(configsPrerender.map((c) => c.parallel)) ?? true,
1113
+ disableAutoRun: pickFirst(configsPrerender.map((c) => c.disableAutoRun)) ?? false
1114
+ };
1115
+ }
1116
+ function isObject2(p) {
1117
+ return typeof p === 'object';
1118
+ }
1119
+ function pickFirst(arr) {
1120
+ return arr.filter((v) => v !== undefined)[0];
1121
+ }
@@ -33,7 +33,7 @@ function getLoadConfigValuesAll(pageConfig, isForClientSide, pageId, includeAsse
33
33
  const importStatements = [];
34
34
  const isClientRouting = (0, getConfigValueBuildTime_js_1.getConfigValueBuildTime)(pageConfig, 'clientRouting', 'boolean')?.value ?? false;
35
35
  lines.push('export const configValuesSerialized = {');
36
- lines.push(...(0, serializeConfigValues_js_1.serializeConfigValues)(pageConfig, importStatements, (configEnv) => (0, isRuntimeEnvMatch_js_1.isRuntimeEnvMatch)(configEnv, { isForClientSide, isClientRouting, isDev }), { isEager: false }, ''));
36
+ lines.push(...(0, serializeConfigValues_js_1.serializeConfigValues)(pageConfig, importStatements, (configEnv) => (0, isRuntimeEnvMatch_js_1.isRuntimeEnvMatch)(configEnv, { isForClientSide, isClientRouting, isDev }), '', false));
37
37
  lines.push('};');
38
38
  if (!(0, fixServerAssets_js_1.fixServerAssets_isEnabled)() && includeAssetsImportedByServer && isForClientSide && !isDev) {
39
39
  importStatements.push(`import '${(0, extractAssetsQuery_js_1.extractAssetsAddQuery)((0, virtualFilePageConfigValuesAll_js_1.getVirtualFileIdPageConfigValuesAll)(pageId, false))}'`);
@@ -7,7 +7,8 @@ const getVikeConfig_js_1 = require("./getVikeConfig.js");
7
7
  const isRuntimeEnvMatch_js_1 = require("./isRuntimeEnvMatch.js");
8
8
  const serializeConfigValues_js_1 = require("../../../../../shared/page-configs/serialize/serializeConfigValues.js");
9
9
  async function getVirtualFilePageConfigs(isForClientSide, isDev, id, isClientRouting, config) {
10
- const { pageConfigs, pageConfigGlobal } = await (0, getVikeConfig_js_1.getVikeConfig)(config, { doNotRestartViteOnError: true });
10
+ const vikeConfig = await (0, getVikeConfig_js_1.getVikeConfig)(config, { doNotRestartViteOnError: true });
11
+ const { pageConfigs, pageConfigGlobal } = vikeConfig;
11
12
  return getCode(pageConfigs, pageConfigGlobal, isForClientSide, isDev, id, isClientRouting);
12
13
  }
13
14
  function getCode(pageConfigs, pageConfigGlobal, isForClientSide, isDev, id, isClientRouting) {
@@ -34,7 +35,7 @@ function getCodePageConfigsSerialized(pageConfigs, isForClientSide, isClientRout
34
35
  lines.push(` routeFilesystem: ${JSON.stringify(routeFilesystem)},`);
35
36
  lines.push(` loadConfigValuesAll: () => import(${JSON.stringify(virtualFileIdPageConfigValuesAll)}),`);
36
37
  lines.push(` configValuesSerialized: {`);
37
- lines.push(...(0, serializeConfigValues_js_1.serializeConfigValues)(pageConfig, importStatements, (configEnv) => (0, isRuntimeEnvMatch_js_1.isRuntimeEnvMatch)(configEnv, { isForClientSide, isClientRouting, isDev }), { isEager: true }, ' '));
38
+ lines.push(...(0, serializeConfigValues_js_1.serializeConfigValues)(pageConfig, importStatements, (configEnv) => (0, isRuntimeEnvMatch_js_1.isRuntimeEnvMatch)(configEnv, { isForClientSide, isClientRouting, isDev }), ' ', true));
38
39
  lines.push(` },`);
39
40
  lines.push(` },`);
40
41
  });
@@ -44,7 +45,7 @@ function getCodePageConfigsSerialized(pageConfigs, isForClientSide, isClientRout
44
45
  function getCodePageConfigGlobalSerialized(pageConfigGlobal, isForClientSide, isClientRouting, isDev, importStatements) {
45
46
  const lines = [];
46
47
  lines.push(` configValuesSerialized: {`);
47
- lines.push(...(0, serializeConfigValues_js_1.serializeConfigValues)(pageConfigGlobal, importStatements, (configEnv) => (0, isRuntimeEnvMatch_js_1.isRuntimeEnvMatch)(configEnv, { isForClientSide, isClientRouting, isDev }), { isEager: true }, ' '));
48
+ lines.push(...(0, serializeConfigValues_js_1.serializeConfigValues)(pageConfigGlobal, importStatements, (configEnv) => (0, isRuntimeEnvMatch_js_1.isRuntimeEnvMatch)(configEnv, { isForClientSide, isClientRouting, isDev }), ' ', null));
48
49
  lines.push(` },`);
49
50
  const code = lines.join('\n');
50
51
  return code;
@@ -35,7 +35,7 @@ function setGlobalContext() {
35
35
  order: 'post',
36
36
  async handler(config) {
37
37
  const { outDirRoot } = (0, utils_js_1.getOutDirs)(config);
38
- (0, utils_js_1.assertFilePathAbsoluteFilesystem)(outDirRoot); // Needed for loadImportBuild(outDir) of @brillout/vite-plugin-server-entry
38
+ (0, utils_js_1.assertFilePathAbsoluteFilesystem)(outDirRoot); // Needed for `importServerProductionEntry({ outDir })` of @brillout/vite-plugin-server-entry
39
39
  (0, globalContext_js_1.setGlobalContext_viteConfig)(config, outDirRoot);
40
40
  const vikeConfig = await (0, getVikeConfig_js_1.getVikeConfig)(config);
41
41
  (0, globalContext_js_1.setGlobalContext_vikeConfig)(vikeConfig);
@@ -1,13 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.vite6HmrRegressionWorkaround = vite6HmrRegressionWorkaround;
3
+ exports.workaroundVite6HmrRegression = workaroundVite6HmrRegression;
4
4
  // https://vite.dev/guide/migration (will be 404 after vite@7 release) > search for `hmrReload()`
5
5
  // https://v6.vite.dev/guide/migration (will exist after vite@7 release) > search for `hmrReload()`
6
6
  // Workaround seems to work for docs page /banner (which is HTML-only)
7
7
  // But doesn't seem to work for /examples/render-modes/ (see https://github.com/vikejs/vike/pull/2069 commit `renable HMR test for HTML-only`)
8
- function vite6HmrRegressionWorkaround() {
8
+ function workaroundVite6HmrRegression() {
9
9
  return {
10
- name: 'vike:vite6HmrRegressionWorkaround',
10
+ name: 'vike:workaroundVite6HmrRegression',
11
11
  enforce: 'post',
12
12
  hotUpdate: {
13
13
  order: 'post',
@@ -18,13 +18,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
18
18
  }) : function(o, v) {
19
19
  o["default"] = v;
20
20
  });
21
- var __importStar = (this && this.__importStar) || function (mod) {
22
- if (mod && mod.__esModule) return mod;
23
- var result = {};
24
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
25
- __setModuleDefault(result, mod);
26
- return result;
27
- };
21
+ var __importStar = (this && this.__importStar) || (function () {
22
+ var ownKeys = function(o) {
23
+ ownKeys = Object.getOwnPropertyNames || function (o) {
24
+ var ar = [];
25
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
26
+ return ar;
27
+ };
28
+ return ownKeys(o);
29
+ };
30
+ return function (mod) {
31
+ if (mod && mod.__esModule) return mod;
32
+ var result = {};
33
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
34
+ __setModuleDefault(result, mod);
35
+ return result;
36
+ };
37
+ })();
28
38
  Object.defineProperty(exports, "__esModule", { value: true });
29
39
  exports.getHttpRequestAsyncStore = getHttpRequestAsyncStore;
30
40
  exports.installHttpRequestAsyncStore = installHttpRequestAsyncStore;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isPrerenderAutoRunEnabled = isPrerenderAutoRunEnabled;
4
+ exports.temp_disablePrerenderAutoRun = temp_disablePrerenderAutoRun;
5
+ const getGlobalObject_js_1 = require("../../utils/getGlobalObject.js");
6
+ const globalObject = (0, getGlobalObject_js_1.getGlobalObject)('isPrerenderAutoRunEnabled.ts', {});
7
+ function isPrerenderAutoRunEnabled(vikeConfigGlobal) {
8
+ return (vikeConfigGlobal.prerender &&
9
+ !vikeConfigGlobal.prerender.disableAutoRun &&
10
+ !globalObject.isDisabled &&
11
+ vikeConfigGlobal.disableAutoFullBuild !== 'prerender');
12
+ }
13
+ // TODO/v1-release: remove
14
+ function temp_disablePrerenderAutoRun() {
15
+ globalObject.isDisabled = true;
16
+ }