vike 0.4.228 → 0.4.229

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 (225) hide show
  1. package/dist/cjs/__internal/index.js +2 -2
  2. package/dist/cjs/client/client-routing-runtime/globalContext.js +49 -0
  3. package/dist/cjs/client/server-routing-runtime/globalContext.js +41 -0
  4. package/dist/cjs/client/server-routing-runtime/utils.js +1 -1
  5. package/dist/cjs/client/shared/createGetGlobalContextClient.js +58 -0
  6. package/dist/cjs/client/shared/getJsonSerializedInHtml.js +31 -0
  7. package/dist/cjs/client/shared/utils.js +22 -0
  8. package/dist/cjs/node/plugin/plugins/baseUrls.js +1 -1
  9. package/dist/cjs/node/plugin/plugins/build/handleAssetsManifest.js +10 -5
  10. package/dist/cjs/node/plugin/plugins/build/pluginBuildApp.js +1 -1
  11. package/dist/cjs/node/plugin/plugins/build/pluginBuildConfig.js +3 -10
  12. package/dist/cjs/node/plugin/plugins/build/pluginBuildEntry.js +9 -5
  13. package/dist/cjs/node/plugin/plugins/build/pluginModuleBanner.js +5 -1
  14. package/dist/cjs/node/plugin/plugins/commonConfig/assertResolveAlias.js +1 -1
  15. package/dist/cjs/node/plugin/plugins/commonConfig.js +14 -3
  16. package/dist/cjs/node/plugin/plugins/devConfig/determineFsAllowList.js +2 -7
  17. package/dist/cjs/node/plugin/plugins/devConfig/determineOptimizeDeps.js +1 -1
  18. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +10 -0
  19. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles/ignorePatternsBuiltIn.js +2 -0
  20. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.js +2 -2
  21. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/{transformPointerImports.js → pointerImports.js} +13 -0
  22. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolvePointerImport.js +20 -19
  23. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js +13 -10
  24. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +11 -11
  25. package/dist/cjs/node/plugin/shared/getFilePath.js +2 -2
  26. package/dist/cjs/node/plugin/shared/resolveClientEntriesDev.js +7 -19
  27. package/dist/cjs/node/plugin/utils.js +1 -0
  28. package/dist/cjs/node/prerender/runPrerender.js +44 -41
  29. package/dist/cjs/node/prerender/utils.js +1 -1
  30. package/dist/cjs/node/runtime/globalContext.js +102 -125
  31. package/dist/cjs/node/runtime/html/injectAssets/getHtmlTags.js +18 -5
  32. package/dist/cjs/node/runtime/html/injectAssets/getViteDevScript.js +2 -2
  33. package/dist/cjs/node/runtime/html/propKeys.js +47 -0
  34. package/dist/cjs/node/runtime/html/renderHtml.js +1 -1
  35. package/dist/cjs/node/runtime/html/{serializePageContextClientSide.js → serializeContext.js} +37 -67
  36. package/dist/cjs/node/runtime/index-deprecated.js +9 -38
  37. package/dist/cjs/node/runtime/index.js +56 -2
  38. package/dist/cjs/node/runtime/renderPage/analyzePage.js +1 -1
  39. package/dist/cjs/node/runtime/renderPage/createHttpResponse.js +8 -3
  40. package/dist/cjs/node/runtime/renderPage/createPageContextServerSide.js +73 -0
  41. package/dist/cjs/node/runtime/renderPage/executeOnBeforeRenderAndDataHooks.js +2 -2
  42. package/dist/cjs/node/runtime/renderPage/executeOnRenderHtmlHook.js +2 -2
  43. package/dist/cjs/node/runtime/renderPage/getPageAssets/getManifestEntry.js +1 -1
  44. package/dist/cjs/node/runtime/renderPage/getPageAssets/retrieveAssetsDev.js +1 -17
  45. package/dist/cjs/node/runtime/renderPage/getPageAssets/retrieveAssetsProd.js +1 -1
  46. package/dist/cjs/node/runtime/renderPage/getPageAssets.js +2 -2
  47. package/dist/cjs/node/runtime/renderPage/handleErrorWithoutErrorPage.js +1 -1
  48. package/dist/cjs/node/runtime/renderPage/loadUserFilesServerSide.js +1 -1
  49. package/dist/cjs/node/runtime/renderPage/log404/index.js +1 -1
  50. package/dist/cjs/node/runtime/renderPage/preparePageContextForUserConsumptionServerSide.js +1 -1
  51. package/dist/cjs/node/runtime/renderPage/renderPageAlreadyRouted.js +3 -68
  52. package/dist/cjs/node/runtime/renderPage.js +102 -81
  53. package/dist/cjs/node/runtime/universal-middleware.js +7 -1
  54. package/dist/cjs/node/runtime/utils.js +3 -2
  55. package/dist/cjs/shared/assertPageContextProvidedByUser.js +1 -1
  56. package/dist/cjs/shared/createGlobalContextShared.js +54 -0
  57. package/dist/cjs/shared/createPageContextShared.js +17 -0
  58. package/dist/cjs/shared/getPageFiles/fileTypes.js +1 -1
  59. package/dist/cjs/shared/hooks/executeHookGeneric.js +18 -0
  60. package/dist/cjs/shared/hooks/getHook.js +45 -27
  61. package/dist/cjs/shared/htmlElementIds.js +5 -0
  62. package/dist/cjs/shared/page-configs/serialize/serializeConfigValues.js +3 -7
  63. package/dist/cjs/shared/route/executeGuardHook.js +1 -1
  64. package/dist/cjs/shared/route/loadPageRoutes.js +2 -1
  65. package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
  66. package/dist/cjs/utils/catchInfiniteLoop.js +3 -3
  67. package/dist/cjs/utils/getPublicProxy.js +27 -0
  68. package/dist/cjs/utils/isImportPath.js +21 -0
  69. package/dist/cjs/utils/objectAssign.js +6 -10
  70. package/dist/cjs/utils/objectReplace.js +4 -4
  71. package/dist/cjs/utils/{isNpmPackage.js → parseNpmPackage.js} +23 -23
  72. package/dist/cjs/utils/path.js +12 -2
  73. package/dist/cjs/utils/requireResolve.js +134 -53
  74. package/dist/esm/__internal/index.js +3 -3
  75. package/dist/esm/client/client-routing-runtime/createPageContext.d.ts +29 -10
  76. package/dist/esm/client/client-routing-runtime/createPageContext.js +23 -22
  77. package/dist/esm/client/client-routing-runtime/getPageContextFromHooks.js +5 -4
  78. package/dist/esm/client/client-routing-runtime/globalContext.d.ts +20 -0
  79. package/dist/esm/client/client-routing-runtime/globalContext.js +13 -0
  80. package/dist/esm/client/client-routing-runtime/initOnLinkClick.js +2 -2
  81. package/dist/esm/client/client-routing-runtime/prefetch.js +2 -2
  82. package/dist/esm/client/client-routing-runtime/renderPageClientSide.js +8 -7
  83. package/dist/esm/client/client-routing-runtime/utils.d.ts +0 -1
  84. package/dist/esm/client/client-routing-runtime/utils.js +0 -1
  85. package/dist/esm/client/index.d.ts +1 -0
  86. package/dist/esm/client/index.js +4 -0
  87. package/dist/esm/client/node.js +1 -3
  88. package/dist/esm/client/server-routing-runtime/createPageContextClientSide.d.ts +36 -0
  89. package/dist/esm/client/server-routing-runtime/createPageContextClientSide.js +47 -0
  90. package/dist/esm/client/server-routing-runtime/entry.js +2 -2
  91. package/dist/esm/client/server-routing-runtime/globalContext.d.ts +17 -0
  92. package/dist/esm/client/server-routing-runtime/globalContext.js +5 -0
  93. package/dist/esm/client/server-routing-runtime/utils.d.ts +1 -1
  94. package/dist/esm/client/server-routing-runtime/utils.js +1 -1
  95. package/dist/esm/client/shared/createGetGlobalContextClient.d.ts +23 -0
  96. package/dist/esm/client/shared/createGetGlobalContextClient.js +58 -0
  97. package/dist/esm/client/shared/executeOnRenderClientHook.js +5 -4
  98. package/dist/esm/client/shared/{getPageContextSerializedInHtml.d.ts → getJsonSerializedInHtml.d.ts} +2 -0
  99. package/dist/esm/client/shared/getJsonSerializedInHtml.js +29 -0
  100. package/dist/esm/client/shared/removeFoucBuster.js +1 -0
  101. package/dist/esm/client/shared/utils.d.ts +4 -0
  102. package/dist/esm/client/shared/utils.js +4 -0
  103. package/dist/esm/node/plugin/plugins/baseUrls.js +2 -2
  104. package/dist/esm/node/plugin/plugins/build/handleAssetsManifest.js +11 -6
  105. package/dist/esm/node/plugin/plugins/build/pluginBuildApp.js +2 -2
  106. package/dist/esm/node/plugin/plugins/build/pluginBuildConfig.js +4 -11
  107. package/dist/esm/node/plugin/plugins/build/pluginBuildEntry.d.ts +1 -1
  108. package/dist/esm/node/plugin/plugins/build/pluginBuildEntry.js +10 -6
  109. package/dist/esm/node/plugin/plugins/build/pluginModuleBanner.js +5 -1
  110. package/dist/esm/node/plugin/plugins/commonConfig/assertResolveAlias.js +2 -2
  111. package/dist/esm/node/plugin/plugins/commonConfig.d.ts +2 -0
  112. package/dist/esm/node/plugin/plugins/commonConfig.js +15 -4
  113. package/dist/esm/node/plugin/plugins/devConfig/determineFsAllowList.js +3 -8
  114. package/dist/esm/node/plugin/plugins/devConfig/determineOptimizeDeps.js +2 -2
  115. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +10 -0
  116. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles/ignorePatternsBuiltIn.d.ts +1 -1
  117. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles/ignorePatternsBuiltIn.js +2 -0
  118. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.js +1 -1
  119. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/{transformPointerImports.d.ts → pointerImports.d.ts} +2 -0
  120. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/{transformPointerImports.js → pointerImports.js} +14 -1
  121. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolvePointerImport.d.ts +1 -1
  122. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolvePointerImport.js +20 -19
  123. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js +13 -10
  124. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +11 -11
  125. package/dist/esm/node/plugin/shared/getFilePath.js +3 -3
  126. package/dist/esm/node/plugin/shared/resolveClientEntriesDev.js +8 -20
  127. package/dist/esm/node/plugin/utils.d.ts +1 -0
  128. package/dist/esm/node/plugin/utils.js +1 -0
  129. package/dist/esm/node/prerender/runPrerender.d.ts +314 -5
  130. package/dist/esm/node/prerender/runPrerender.js +48 -45
  131. package/dist/esm/node/prerender/utils.d.ts +1 -1
  132. package/dist/esm/node/prerender/utils.js +1 -1
  133. package/dist/esm/node/runtime/globalContext.d.ts +425 -47
  134. package/dist/esm/node/runtime/globalContext.js +103 -126
  135. package/dist/esm/node/runtime/html/injectAssets/getHtmlTags.js +18 -5
  136. package/dist/esm/node/runtime/html/injectAssets/getViteDevScript.d.ts +2 -2
  137. package/dist/esm/node/runtime/html/injectAssets/getViteDevScript.js +2 -2
  138. package/dist/esm/node/runtime/html/injectAssets.d.ts +3 -3
  139. package/dist/esm/node/runtime/html/propKeys.d.ts +8 -0
  140. package/dist/esm/node/runtime/html/propKeys.js +45 -0
  141. package/dist/esm/node/runtime/html/renderHtml.js +1 -1
  142. package/dist/esm/node/runtime/html/{serializePageContextClientSide.d.ts → serializeContext.d.ts} +7 -6
  143. package/dist/esm/node/runtime/html/{serializePageContextClientSide.js → serializeContext.js} +36 -67
  144. package/dist/esm/node/runtime/index-deprecated.d.ts +1 -16
  145. package/dist/esm/node/runtime/index-deprecated.js +9 -36
  146. package/dist/esm/node/runtime/index.d.ts +23 -1
  147. package/dist/esm/node/runtime/index.js +38 -3
  148. package/dist/esm/node/runtime/renderPage/analyzePage.d.ts +2 -2
  149. package/dist/esm/node/runtime/renderPage/analyzePage.js +1 -1
  150. package/dist/esm/node/runtime/renderPage/createHttpResponse.d.ts +5 -4
  151. package/dist/esm/node/runtime/renderPage/createHttpResponse.js +8 -3
  152. package/dist/esm/node/runtime/renderPage/createPageContextServerSide.d.ts +155 -0
  153. package/dist/esm/node/runtime/renderPage/createPageContextServerSide.js +71 -0
  154. package/dist/esm/node/runtime/renderPage/executeOnBeforeRenderAndDataHooks.js +3 -3
  155. package/dist/esm/node/runtime/renderPage/executeOnRenderHtmlHook.d.ts +1 -1
  156. package/dist/esm/node/runtime/renderPage/executeOnRenderHtmlHook.js +3 -3
  157. package/dist/esm/node/runtime/renderPage/getPageAssets/getManifestEntry.js +2 -2
  158. package/dist/esm/node/runtime/renderPage/getPageAssets/retrieveAssetsDev.js +1 -17
  159. package/dist/esm/node/runtime/renderPage/getPageAssets/retrieveAssetsProd.js +2 -2
  160. package/dist/esm/node/runtime/renderPage/getPageAssets.d.ts +2 -2
  161. package/dist/esm/node/runtime/renderPage/getPageAssets.js +2 -2
  162. package/dist/esm/node/runtime/renderPage/handleErrorWithoutErrorPage.d.ts +2 -2
  163. package/dist/esm/node/runtime/renderPage/handleErrorWithoutErrorPage.js +1 -1
  164. package/dist/esm/node/runtime/renderPage/loadUserFilesServerSide.d.ts +2 -2
  165. package/dist/esm/node/runtime/renderPage/loadUserFilesServerSide.js +1 -1
  166. package/dist/esm/node/runtime/renderPage/log404/index.d.ts +2 -2
  167. package/dist/esm/node/runtime/renderPage/log404/index.js +1 -1
  168. package/dist/esm/node/runtime/renderPage/preparePageContextForUserConsumptionServerSide.d.ts +3 -3
  169. package/dist/esm/node/runtime/renderPage/preparePageContextForUserConsumptionServerSide.js +1 -1
  170. package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.d.ts +225 -179
  171. package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.js +4 -69
  172. package/dist/esm/node/runtime/renderPage.d.ts +146 -7
  173. package/dist/esm/node/runtime/renderPage.js +105 -84
  174. package/dist/esm/node/runtime/universal-middleware.js +7 -1
  175. package/dist/esm/node/runtime/utils.d.ts +3 -2
  176. package/dist/esm/node/runtime/utils.js +3 -2
  177. package/dist/esm/shared/VikeNamespace.d.ts +35 -13
  178. package/dist/esm/shared/assertPageContextProvidedByUser.js +1 -1
  179. package/dist/esm/shared/createGlobalContextShared.d.ts +39 -0
  180. package/dist/esm/shared/createGlobalContextShared.js +51 -0
  181. package/dist/esm/shared/createPageContextShared.d.ts +9 -0
  182. package/dist/esm/shared/createPageContextShared.js +15 -0
  183. package/dist/esm/shared/getPageFiles/fileTypes.js +1 -1
  184. package/dist/esm/shared/hooks/executeHookGeneric.d.ts +8 -0
  185. package/dist/esm/shared/hooks/executeHookGeneric.js +16 -0
  186. package/dist/esm/shared/hooks/getHook.d.ts +5 -3
  187. package/dist/esm/shared/hooks/getHook.js +47 -29
  188. package/dist/esm/shared/htmlElementIds.d.ts +2 -0
  189. package/dist/esm/shared/htmlElementIds.js +2 -0
  190. package/dist/esm/shared/page-configs/Config.d.ts +12 -2
  191. package/dist/esm/shared/page-configs/getConfigDefinedAt.d.ts +1 -1
  192. package/dist/esm/shared/page-configs/serialize/serializeConfigValues.js +3 -7
  193. package/dist/esm/shared/route/executeGuardHook.js +2 -2
  194. package/dist/esm/shared/route/loadPageRoutes.js +2 -1
  195. package/dist/esm/shared/types.d.ts +64 -32
  196. package/dist/esm/types/index.d.ts +1 -5
  197. package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
  198. package/dist/esm/utils/PROJECT_VERSION.js +1 -1
  199. package/dist/esm/utils/catchInfiniteLoop.js +4 -4
  200. package/dist/esm/utils/getGlobalObject.d.ts +1 -1
  201. package/dist/esm/utils/getPublicProxy.d.ts +2 -0
  202. package/dist/esm/utils/getPublicProxy.js +25 -0
  203. package/dist/esm/utils/isImportPath.d.ts +4 -0
  204. package/dist/esm/utils/isImportPath.js +19 -0
  205. package/dist/esm/utils/objectAssign.d.ts +1 -1
  206. package/dist/esm/utils/objectAssign.js +6 -10
  207. package/dist/esm/utils/objectReplace.d.ts +1 -1
  208. package/dist/esm/utils/objectReplace.js +4 -4
  209. package/dist/esm/utils/parseNpmPackage.d.ts +17 -0
  210. package/dist/esm/utils/{isNpmPackage.js → parseNpmPackage.js} +23 -23
  211. package/dist/esm/utils/path.d.ts +1 -1
  212. package/dist/esm/utils/path.js +12 -2
  213. package/dist/esm/utils/requireResolve.d.ts +20 -7
  214. package/dist/esm/utils/requireResolve.js +134 -53
  215. package/package.json +14 -13
  216. package/dist/cjs/node/runtime/index-common.js +0 -27
  217. package/dist/cjs/utils/makePublicCopy.js +0 -32
  218. package/dist/esm/client/server-routing-runtime/getPageContext.d.ts +0 -19
  219. package/dist/esm/client/server-routing-runtime/getPageContext.js +0 -44
  220. package/dist/esm/client/shared/getPageContextSerializedInHtml.js +0 -20
  221. package/dist/esm/node/runtime/index-common.d.ts +0 -8
  222. package/dist/esm/node/runtime/index-common.js +0 -10
  223. package/dist/esm/utils/isNpmPackage.d.ts +0 -17
  224. package/dist/esm/utils/makePublicCopy.d.ts +0 -3
  225. package/dist/esm/utils/makePublicCopy.js +0 -30
@@ -3,33 +3,55 @@ export type { VikePackages };
3
3
  declare global {
4
4
  /** Refine Vike types. */
5
5
  namespace Vike {
6
- /** Extend and/or refine the `Config` type (`import type { Config } from 'vike/types'`).
7
- *
8
- * For example:
9
- * - You can refine the type of `Config['Page']`.
10
- * - You can define the type of custom configurations created with `config.meta` (https://vike.dev/meta)
6
+ /** Extend the `Config` type (`import type { Config } from 'vike/types'`).
11
7
  *
12
8
  * https://vike.dev/meta#typescript
13
9
  */
14
10
  interface Config {
15
11
  }
16
- /** Extend and/or refine the `PageContext` type (`import type { PageContext } from 'vike/types'`).
12
+ /** Refine the `pageContext.config` type.
17
13
  *
18
- * For example:
19
- * - You can refine the type of `PageContext['Page']`.
20
- * - You can define the type of custom `pageContext` values such as `pageContext.user`, see https://vike.dev/pageContext#custom
14
+ * It's used for cumulative configs: the `pageContext.config[configName]` type is an `array` whereas `Config[configName]` isn't.
15
+ *
16
+ * https://vike.dev/meta#typescript
17
+ */
18
+ interface ConfigResolved {
19
+ }
20
+ /** Extend the `PageContext` type (`import type { PageContext } from 'vike/types'`).
21
21
  *
22
22
  * https://vike.dev/pageContext#typescript
23
23
  */
24
24
  interface PageContext {
25
25
  }
26
- /** Refine the `pageContext.config` type.
26
+ /** Extend the `PageContextClient` type (`import type { PageContextClient } from 'vike/types'`).
27
27
  *
28
- * It's used for cumulative configs: the `pageContext.config[configName]` type is an `array` whereas `Config[configName]` isn't.
28
+ * https://vike.dev/pageContext#typescript
29
+ */
30
+ interface PageContextClient {
31
+ }
32
+ /** Extend the `PageContextServer` type (`import type { PageContextServer } from 'vike/types'`).
29
33
  *
30
- * https://vike.dev/meta#typescript
34
+ * https://vike.dev/pageContext#typescript
31
35
  */
32
- interface ConfigResolved {
36
+ interface PageContextServer {
37
+ }
38
+ /** Extend the `GlobalContext` type (`import type { GlobalContext } from 'vike/types'`).
39
+ *
40
+ * https://vike.dev/globalContext#typescript
41
+ */
42
+ interface GlobalContext {
43
+ }
44
+ /** Extend the `GlobalContextClient` type (`import type { GlobalContextClient } from 'vike/types'`).
45
+ *
46
+ * https://vike.dev/globalContext#typescript
47
+ */
48
+ interface GlobalContextClient {
49
+ }
50
+ /** Extend the `GlobalContextServer` type (`import type { GlobalContextServer } from 'vike/types'`).
51
+ *
52
+ * https://vike.dev/globalContext#typescript
53
+ */
54
+ interface GlobalContextServer {
33
55
  }
34
56
  }
35
57
  /** This namespace is only used by:
@@ -7,7 +7,7 @@ function assertPageContextProvidedByUser(pageContextProvidedByUser, { hookName,
7
7
  assert(!hookName.endsWith(')'));
8
8
  const errPrefix = `The ${pc.cyan('pageContext')} object provided by the ${hookName}() hook defined by ${hookFilePath}`;
9
9
  assertUsage(isObject(pageContextProvidedByUser), `${errPrefix} should be an object (but it's ${pc.cyan(`typeof pageContext === ${JSON.stringify(typeof pageContextProvidedByUser)}`)} instead)`);
10
- assertUsage(!('_objectCreatedByVike' in pageContextProvidedByUser), `${errPrefix} shouldn't be the whole ${pc.cyan('pageContext')} object, see https://vike.dev/pageContext-manipulation#do-not-return-entire-pagecontext`);
10
+ assertUsage(!('isPageContext' in pageContextProvidedByUser), `${errPrefix} shouldn't be the whole ${pc.cyan('pageContext')} object, see https://vike.dev/pageContext-manipulation#do-not-return-entire-pagecontext`);
11
11
  // In principle, it's possible to use onBeforeRoute()` to override and define the whole routing.
12
12
  // Is that a good idea to allow users to do this? Beyond deep integration with Vue Router or React Router, is there a use case for this?
13
13
  assertWarning(!('pageId' in pageContextProvidedByUser), `${errPrefix} sets ${pc.cyan('pageContext.pageId')} which means that Vike's routing is overriden. This is an experimental feature: make sure to contact a vike maintainer before using this.`, { onlyOnce: true });
@@ -0,0 +1,39 @@
1
+ export { createGlobalContextShared };
2
+ export { getGlobalContextSyncErrMsg };
3
+ export type { GlobalContextShared };
4
+ export type { GlobalContextSharedPublic };
5
+ declare const getGlobalContextSyncErrMsg = "The global context isn't set yet, call getGlobalContextSync() later or use getGlobalContext() instead.";
6
+ declare function createGlobalContextShared<GlobalContextAddendum extends object>(virtualFileExports: unknown, globalObject: {
7
+ globalContext?: Record<string, unknown>;
8
+ }, addGlobalContext?: (globalContext: GlobalContextShared) => Promise<GlobalContextAddendum>): Promise<{
9
+ /**
10
+ * Useful for distinguishing `globalContext` from other objects and narrowing down TypeScript unions.
11
+ *
12
+ * https://vike.dev/globalContext#typescript
13
+ */
14
+ isGlobalContext: true;
15
+ _virtualFileExports: unknown;
16
+ _pageFilesAll: import("./getPageFiles.js").PageFile[];
17
+ _pageConfigs: import("./page-configs/PageConfig.js").PageConfigRuntime[];
18
+ _pageConfigGlobal: import("./page-configs/PageConfig.js").PageConfigGlobalRuntime;
19
+ _allPageIds: string[];
20
+ config: import("./page-configs/Config/PageContextConfig.js").ConfigResolved;
21
+ pages: import("./page-configs/getPageConfigUserFriendly.js").PageConfigsUserFriendly;
22
+ } & Awaited<GlobalContextAddendum>>;
23
+ type GlobalContextSharedPublic = Pick<GlobalContextShared, 'config' | 'pages' | 'isGlobalContext'>;
24
+ type GlobalContextShared = ReturnType<typeof createGlobalContextBase>;
25
+ declare function createGlobalContextBase(virtualFileExports: unknown): {
26
+ /**
27
+ * Useful for distinguishing `globalContext` from other objects and narrowing down TypeScript unions.
28
+ *
29
+ * https://vike.dev/globalContext#typescript
30
+ */
31
+ isGlobalContext: true;
32
+ _virtualFileExports: unknown;
33
+ _pageFilesAll: import("./getPageFiles.js").PageFile[];
34
+ _pageConfigs: import("./page-configs/PageConfig.js").PageConfigRuntime[];
35
+ _pageConfigGlobal: import("./page-configs/PageConfig.js").PageConfigGlobalRuntime;
36
+ _allPageIds: string[];
37
+ config: import("./page-configs/Config/PageContextConfig.js").ConfigResolved;
38
+ pages: import("./page-configs/getPageConfigUserFriendly.js").PageConfigsUserFriendly;
39
+ };
@@ -0,0 +1,51 @@
1
+ export { createGlobalContextShared };
2
+ export { getGlobalContextSyncErrMsg };
3
+ const getGlobalContextSyncErrMsg = "The global context isn't set yet, call getGlobalContextSync() later or use getGlobalContext() instead.";
4
+ import { getPageConfigsRuntime } from './getPageConfigsRuntime.js';
5
+ import { executeHookGenericGlobalCumulative } from './hooks/executeHookGeneric.js';
6
+ import { objectAssign } from './utils.js';
7
+ async function createGlobalContextShared(virtualFileExports, globalObject, addGlobalContext) {
8
+ const globalContext = createGlobalContextBase(virtualFileExports);
9
+ const globalContextAddendum = await addGlobalContext?.(globalContext);
10
+ objectAssign(globalContext, globalContextAddendum);
11
+ if (!globalObject.globalContext) {
12
+ globalObject.globalContext = globalContext;
13
+ // - We deliberately call onCreateGlobalContext() only at the beginning and only once per process.
14
+ // - TO-DO/eventually: HMR
15
+ // - Once Photon supports it: `server.hot.send({ type: 'full-server-reload' })`
16
+ // - Either use:
17
+ // - import.meta.hot
18
+ // - https://vite.dev/guide/api-hmr.html
19
+ // - Use a Vite transformer to inject import.meta.hot code into each user-land `+onCreateGlobalContext.js` file
20
+ // - Seems more idiomatic
21
+ // - globalContext._viteDevServer.hot.send()
22
+ // - Send 'full-server-reload' signal whenever a onCreateGlobalContext() function is modified => we need a globalObject to track all hooks and see if one of them is new/modified.
23
+ // - Seems less idiomatic
24
+ await executeHookGenericGlobalCumulative('onCreateGlobalContext', globalContext._pageConfigGlobal, null, globalContext);
25
+ }
26
+ else {
27
+ // Singleton: ensure all `globalContext` user-land references are preserved & updated.
28
+ // We don't use objectReplace() in order to keep user-land properties.
29
+ objectAssign(globalObject.globalContext, globalContext);
30
+ }
31
+ return globalObject.globalContext;
32
+ }
33
+ function createGlobalContextBase(virtualFileExports) {
34
+ const { pageFilesAll, allPageIds, pageConfigs, pageConfigGlobal, globalConfig, pageConfigsUserFriendly } = getPageConfigsRuntime(virtualFileExports);
35
+ const globalContext = {
36
+ /**
37
+ * Useful for distinguishing `globalContext` from other objects and narrowing down TypeScript unions.
38
+ *
39
+ * https://vike.dev/globalContext#typescript
40
+ */
41
+ isGlobalContext: true,
42
+ _virtualFileExports: virtualFileExports,
43
+ _pageFilesAll: pageFilesAll,
44
+ _pageConfigs: pageConfigs,
45
+ _pageConfigGlobal: pageConfigGlobal,
46
+ _allPageIds: allPageIds,
47
+ config: globalConfig.config,
48
+ pages: pageConfigsUserFriendly
49
+ };
50
+ return globalContext;
51
+ }
@@ -0,0 +1,9 @@
1
+ export { createPageContextShared };
2
+ import type { PageConfigGlobalRuntime } from './page-configs/PageConfig.js';
3
+ declare function createPageContextShared<T extends object>(pageContextCreated: T, pageConfigGlobal: PageConfigGlobalRuntime): Promise<T & {
4
+ config: import("./page-configs/Config/PageContextConfig.js").ConfigResolved;
5
+ _source: import("./page-configs/getPageConfigUserFriendly.js").Source;
6
+ _sources: import("./page-configs/getPageConfigUserFriendly.js").Sources;
7
+ _from: import("./page-configs/getPageConfigUserFriendly.js").From;
8
+ isPageContext: true;
9
+ }>;
@@ -0,0 +1,15 @@
1
+ export { createPageContextShared };
2
+ import { executeHookGenericGlobalCumulative } from './hooks/executeHookGeneric.js';
3
+ import { getPageConfigGlobalUserFriendly } from './page-configs/getPageConfigUserFriendly.js';
4
+ import { objectAssign } from './utils.js';
5
+ async function createPageContextShared(pageContextCreated, pageConfigGlobal) {
6
+ const pageConfigGlobalUserFriendly = getPageConfigGlobalUserFriendly({
7
+ pageConfigGlobalValues: pageConfigGlobal.configValues
8
+ });
9
+ objectAssign(pageContextCreated, {
10
+ isPageContext: true,
11
+ ...pageConfigGlobalUserFriendly
12
+ }, true);
13
+ await executeHookGenericGlobalCumulative('onCreatePageContext', pageConfigGlobal, pageContextCreated, pageContextCreated);
14
+ return pageContextCreated;
15
+ }
@@ -22,7 +22,7 @@ function determineFileType(filePath) {
22
22
  const isCSS = filePath.endsWith('.css');
23
23
  if (isCSS) {
24
24
  /* This assert() is skipped to reduce client-side bundle size
25
- assert(isNpmPackageImport(filePath), filePath) // `.css` page files are only supported for npm packages
25
+ assert(isImportPathNpmPackage(filePath), filePath) // `.css` page files are only supported for npm packages
26
26
  */
27
27
  return '.css';
28
28
  }
@@ -0,0 +1,8 @@
1
+ export { executeHookGeneric };
2
+ export { executeHookGenericGlobalCumulative };
3
+ import type { PageConfigUserFriendlyOld } from '../getPageFiles.js';
4
+ import { type HookName } from './getHook.js';
5
+ import type { HookNameGlobal } from '../page-configs/Config.js';
6
+ import type { PageConfigGlobalRuntime } from '../page-configs/PageConfig.js';
7
+ declare function executeHookGeneric(hookName: HookName, pageContext: PageConfigUserFriendlyOld): Promise<void>;
8
+ declare function executeHookGenericGlobalCumulative(hookName: HookNameGlobal, pageConfigGlobal: PageConfigGlobalRuntime, pageContext: object | null, arg: object): Promise<void>;
@@ -0,0 +1,16 @@
1
+ export { executeHookGeneric }; // TO-DO/refactor: start using executeHookGeneric() and, eventually, prominently use it
2
+ export { executeHookGenericGlobalCumulative };
3
+ import { executeHook } from './executeHook.js';
4
+ import { getHookFromPageContext, getHookFromPageConfigGlobalCumulative } from './getHook.js';
5
+ async function executeHookGeneric(hookName, pageContext) {
6
+ const hook = getHookFromPageContext(pageContext, hookName);
7
+ if (!hook)
8
+ return;
9
+ await executeHook(() => hook.hookFn(pageContext), hook, pageContext);
10
+ }
11
+ async function executeHookGenericGlobalCumulative(hookName, pageConfigGlobal, pageContext, arg) {
12
+ const hooks = getHookFromPageConfigGlobalCumulative(pageConfigGlobal, hookName);
13
+ await Promise.all(hooks.map(async (hook) => {
14
+ await executeHook(() => hook.hookFn(arg), hook, pageContext);
15
+ }));
16
+ }
@@ -1,6 +1,7 @@
1
- export { getHook };
1
+ export { getHookFromPageContext };
2
2
  export { getHookFromPageConfig };
3
3
  export { getHookFromPageConfigGlobal };
4
+ export { getHookFromPageConfigGlobalCumulative };
4
5
  export { assertHook };
5
6
  export { getHook_setIsPrerenderering };
6
7
  export type { Hook };
@@ -20,15 +21,16 @@ type HookLoc = {
20
21
  hookName: HookName;
21
22
  hookFilePath: string;
22
23
  };
23
- type HookFn = (arg: unknown) => unknown;
24
+ type HookFn = (arg: object) => unknown;
24
25
  type HookTimeout = {
25
26
  error: number | false;
26
27
  warning: number | false;
27
28
  };
28
29
  type HooksTimeoutProvidedByUser = false | Partial<Record<HookName, false | Partial<HookTimeout>>>;
29
- declare function getHook(pageContext: PageConfigUserFriendlyOld, hookName: HookName): null | Hook;
30
+ declare function getHookFromPageContext(pageContext: PageConfigUserFriendlyOld, hookName: HookName): null | Hook;
30
31
  declare function getHookFromPageConfig(pageConfig: PageConfigRuntime, hookName: HookNamePage): null | Hook;
31
32
  declare function getHookFromPageConfigGlobal(pageConfigGlobal: PageConfigGlobalRuntime, hookName: HookNameGlobal): null | Hook;
33
+ declare function getHookFromPageConfigGlobalCumulative(pageConfigGlobal: PageConfigGlobalRuntime, hookName: HookNameGlobal): Hook[];
32
34
  declare function assertHook<TPageContext extends PageConfigUserFriendlyOld, THookName extends PropertyKey & HookName>(pageContext: TPageContext, hookName: THookName): asserts pageContext is TPageContext & {
33
35
  exports: Record<THookName, Function | undefined>;
34
36
  };
@@ -1,70 +1,88 @@
1
- export { getHook };
1
+ export { getHookFromPageContext };
2
2
  export { getHookFromPageConfig };
3
3
  export { getHookFromPageConfigGlobal };
4
+ export { getHookFromPageConfigGlobalCumulative };
4
5
  export { assertHook };
5
6
  export { getHook_setIsPrerenderering };
6
7
  // TODO/v1-release: remove
7
- // We export for old V0.4 design which doesn't support configooksTimeout
8
+ // We export for old V0.4 design which doesn't support config.hooksTimeout
8
9
  export { getHookTimeoutDefault };
9
10
  import { getGlobalObject } from '../../utils/getGlobalObject.js';
10
11
  import { getHookFilePathToShowToUser } from '../page-configs/helpers.js';
11
12
  import { getConfigValueRuntime } from '../page-configs/getConfigValueRuntime.js';
12
- import { assert, assertUsage, checkType, isCallable, isObject } from '../utils.js';
13
+ import { assert, assertUsage, checkType, isArray, isCallable, isObject } from '../utils.js';
13
14
  import pc from '@brillout/picocolors';
14
15
  const globalObject = getGlobalObject('hooks/getHook.ts', {});
15
- function getHook(pageContext, hookName) {
16
+ function getHookFromPageContext(pageContext, hookName) {
16
17
  if (!(hookName in pageContext.exports)) {
17
18
  return null;
18
19
  }
19
20
  const { hooksTimeout } = pageContext.config;
20
21
  const hookTimeout = getHookTimeout(hooksTimeout, hookName);
21
22
  const hookFn = pageContext.exports[hookName];
22
- const file = pageContext.exportsAll[hookName][0];
23
- assert(file.exportValue === hookFn);
24
23
  if (hookFn === null)
25
24
  return null;
25
+ const file = pageContext.exportsAll[hookName][0];
26
+ assert(file.exportValue === hookFn);
26
27
  const hookFilePath = file.filePath;
27
28
  assert(hookFilePath);
28
- assert(!hookFilePath.endsWith(' '));
29
- assertHookFn(hookFn, { hookName, hookFilePath });
30
- return { hookFn, hookName, hookFilePath, hookTimeout };
29
+ return getHook(hookFn, hookName, hookFilePath, hookTimeout);
31
30
  }
32
31
  function getHookFromPageConfig(pageConfig, hookName) {
33
32
  const configValue = getConfigValueRuntime(pageConfig, hookName);
34
- const hooksTimeout = getConfigValueRuntime(pageConfig, 'hooksTimeout')?.value;
35
- if (!configValue)
33
+ if (!configValue?.value)
36
34
  return null;
37
- const hookFn = configValue.value;
38
- if (!hookFn)
39
- return null;
40
- const hookFilePath = getHookFilePathToShowToUser(configValue.definedAtData);
41
- // hook isn't a computed nor a cumulative config => hookFilePath should always be defined
42
- assert(hookFilePath);
43
- assertHookFn(hookFn, { hookName, hookFilePath });
35
+ const { hookFn, hookFilePath } = getHookFromConfigValue(configValue);
36
+ const hooksTimeout = getConfigValueRuntime(pageConfig, 'hooksTimeout')?.value;
44
37
  const hookTimeout = getHookTimeout(hooksTimeout, hookName);
45
- return { hookFn, hookName, hookFilePath, hookTimeout };
38
+ return getHook(hookFn, hookName, hookFilePath, hookTimeout);
46
39
  }
47
40
  function getHookFromPageConfigGlobal(pageConfigGlobal, hookName) {
48
41
  const configValue = pageConfigGlobal.configValues[hookName];
49
- if (!configValue)
50
- return null;
51
- const hookFn = configValue.value;
52
- if (!hookFn)
42
+ if (!configValue?.value)
53
43
  return null;
54
- const hookFilePath = getHookFilePathToShowToUser(configValue.definedAtData);
55
- // hook isn't a computed nor a cumulative config => hookFilePath should always be defined
44
+ const { hookFn, hookFilePath } = getHookFromConfigValue(configValue);
45
+ const hookTimeout = getHookTimeoutGlobal(hookName);
46
+ return getHook(hookFn, hookName, hookFilePath, hookTimeout);
47
+ }
48
+ function getHookFromPageConfigGlobalCumulative(pageConfigGlobal, hookName) {
49
+ const configValue = pageConfigGlobal.configValues[hookName];
50
+ if (!configValue?.value)
51
+ return [];
52
+ const val = configValue.value;
53
+ assert(isArray(val));
54
+ return val.map((v, i) => {
55
+ const hookFn = v;
56
+ const hookTimeout = getHookTimeoutGlobal(hookName);
57
+ assert(isArray(configValue.definedAtData));
58
+ const hookFilePath = getHookFilePathToShowToUser(configValue.definedAtData[i]);
59
+ return getHook(hookFn, hookName, hookFilePath, hookTimeout);
60
+ });
61
+ }
62
+ function getHookTimeoutGlobal(hookName) {
63
+ // TO-DO/perfection: we could use the global value of configooksTimeout but it requires some non-trivial refactoring
64
+ const hookTimeout = getHookTimeoutDefault(hookName);
65
+ return hookTimeout;
66
+ }
67
+ function getHook(hookFn, hookName, hookFilePath, hookTimeout) {
56
68
  assert(hookFilePath);
57
69
  assertHookFn(hookFn, { hookName, hookFilePath });
58
- // We could use the global value of configooksTimeout but it requires some non-trivial refactoring
59
- const hookTimeout = getHookTimeoutDefault(hookName);
60
- return { hookFn, hookName, hookFilePath, hookTimeout };
70
+ const hook = { hookFn, hookName, hookFilePath, hookTimeout };
71
+ return hook;
72
+ }
73
+ function getHookFromConfigValue(configValue) {
74
+ const hookFn = configValue.value;
75
+ assert(hookFn);
76
+ const hookFilePath = getHookFilePathToShowToUser(configValue.definedAtData);
77
+ return { hookFn, hookFilePath };
61
78
  }
62
79
  function assertHook(pageContext, hookName) {
63
- getHook(pageContext, hookName);
80
+ getHookFromPageContext(pageContext, hookName);
64
81
  }
65
82
  function assertHookFn(hookFn, { hookName, hookFilePath }) {
66
83
  assert(hookName && hookFilePath);
67
84
  assert(!hookName.endsWith(')'));
85
+ assert(!hookFilePath.endsWith(' '));
68
86
  assertUsage(isCallable(hookFn), `Hook ${hookName}() defined by ${hookFilePath} should be a function`);
69
87
  checkType(hookFn);
70
88
  }
@@ -0,0 +1,2 @@
1
+ export declare const htmlElementId_pageContext = "vike_pageContext";
2
+ export declare const htmlElementId_globalContext = "vike_globalContext";
@@ -0,0 +1,2 @@
1
+ export const htmlElementId_pageContext = 'vike_pageContext';
2
+ export const htmlElementId_globalContext = 'vike_globalContext';
@@ -41,11 +41,11 @@ import type { InjectFilterEntry } from '../../types/index.js';
41
41
  import type { VikeVitePluginOptions } from '../../node/plugin/index.js';
42
42
  import type { Vike, VikePackages } from '../VikeNamespace.js';
43
43
  import type { HooksTimeoutProvidedByUser } from '../hooks/getHook.js';
44
- import type { PageContextClient, PageContextServer } from '../types.js';
44
+ import type { GlobalContext, PageContextClient, PageContextServer } from '../types.js';
45
45
  import type { InlineConfig } from 'vite';
46
46
  type HookName = HookNamePage | HookNameGlobal | HookNameOldDesign;
47
47
  type HookNamePage = 'onHydrationEnd' | 'onBeforePrerenderStart' | 'onBeforeRender' | 'onPageTransitionStart' | 'onPageTransitionEnd' | 'onRenderHtml' | 'onRenderClient' | 'guard' | 'data';
48
- type HookNameGlobal = 'onBeforePrerender' | 'onBeforeRoute' | 'onPrerenderStart';
48
+ type HookNameGlobal = 'onBeforePrerender' | 'onBeforeRoute' | 'onPrerenderStart' | 'onCreatePageContext' | 'onCreateGlobalContext';
49
49
  type HookNameOldDesign = 'render' | 'prerender';
50
50
  type ConfigNameBuiltIn = Exclude<keyof Config, keyof VikeVitePluginOptions | 'onBeforeRoute' | 'onPrerenderStart' | 'vite' | 'redirects'> | 'prerender' | 'isClientRuntimeLoaded' | 'onBeforeRenderEnv' | 'dataEnv' | 'hooksTimeout' | 'clientHooks' | 'middleware';
51
51
  type ConfigNameGlobal = 'onPrerenderStart' | 'onBeforeRoute' | 'prerender' | 'disableAutoFullBuild' | 'includeAssetsImportedByServer' | 'baseAssets' | 'baseServer' | 'redirects' | 'trailingSlash' | 'disableUrlNormalization' | 'vite';
@@ -330,6 +330,16 @@ type ConfigBuiltIn = {
330
330
  * https://vike.dev/onBeforeRender
331
331
  */
332
332
  onBeforeRender?: OnBeforeRenderAsync | OnBeforeRenderSync | ImportString | null;
333
+ /** Hook called when a `pageContext` object is created.
334
+ *
335
+ * https://vike.dev/onCreatePageContext
336
+ */
337
+ onCreatePageContext?: ((pageContext: PageContextServer) => void) | ImportString | null;
338
+ /** Hook called when the `globalContext` object is created.
339
+ *
340
+ * https://vike.dev/onCreateGlobalContext
341
+ */
342
+ onCreateGlobalContext?: ((globalContext: GlobalContext) => void) | ImportString | null;
333
343
  /** Hook for fetching data.
334
344
  *
335
345
  * https://vike.dev/data
@@ -10,4 +10,4 @@ type ConfigDefinedAt = `Config ${string} defined at ${string}`;
10
10
  declare function getConfigDefinedAt<SentenceBegin extends 'Config' | 'config', ConfigName extends string>(sentenceBegin: SentenceBegin, configName: ConfigName, definedAtData: NonNullable<DefinedAtData>): `${SentenceBegin} ${ConfigName} defined at ${string}`;
11
11
  declare function getConfigDefinedAtOptional<SentenceBegin extends 'Config' | 'config', ConfigName extends string>(sentenceBegin: SentenceBegin, configName: ConfigName, definedAtData: DefinedAtData): `${SentenceBegin} ${ConfigName} defined ${'internally' | `at ${string}`}`;
12
12
  declare function getDefinedAtString(definedAtData: NonNullable<DefinedAtData>, configName: string): string;
13
- declare function getDefinedByString(definedAt: DefinedBy, configName: string): `API call dev({ vikeConfig: { ${string} } })` | `API call build({ vikeConfig: { ${string} } })` | `API call preview({ vikeConfig: { ${string} } })` | `API call prerender({ vikeConfig: { ${string} } })` | `CLI option --${string}` | `environment variable VIKE_CONFIG="{${string}}"`;
13
+ declare function getDefinedByString(definedAt: DefinedBy, configName: string): `API call ${string}({ vikeConfig: { ${string} } })` | `CLI option --${string}` | `environment variable VIKE_CONFIG="{${string}}"`;
@@ -2,8 +2,8 @@ export { serializeConfigValues };
2
2
  export { getConfigValuesBase };
3
3
  export { isJsonValue };
4
4
  import { assertIsNotProductionRuntime } from '../../../utils/assertSetup.js';
5
- import { assert, assertPosixPath, assertUsage, deepEqual, getPropAccessNotation } from '../../../node/plugin/utils.js';
6
- import { parsePointerImportData } from '../../../node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transformPointerImports.js';
5
+ import { assert, assertPosixPath, assertUsage, deepEqual, getPropAccessNotation, isImportPathRelative } from '../../../node/plugin/utils.js';
6
+ import { parsePointerImportData } from '../../../node/plugin/plugins/importUserCode/v1-design/getVikeConfig/pointerImports.js';
7
7
  import { getConfigValueFilePathToShowToUser } from '../helpers.js';
8
8
  import { stringify } from '@brillout/json-serializer/stringify';
9
9
  import pc from '@brillout/picocolors';
@@ -264,10 +264,10 @@ function addImportStatement(importStatements, importPath, exportName, filesEnv,
264
264
  return { importName };
265
265
  }
266
266
  function assertFileEnv(importPath, configEnv, configName, filesEnv) {
267
+ assert(!isImportPathRelative(importPath));
267
268
  const key = importPath;
268
269
  assert(key);
269
270
  assertPosixPath(key);
270
- assert(!isRelativeImportPath(key));
271
271
  if (!filesEnv.has(key)) {
272
272
  filesEnv.set(key, []);
273
273
  }
@@ -283,7 +283,3 @@ function assertFileEnv(importPath, configEnv, configName, filesEnv) {
283
283
  ].join('\n'));
284
284
  }
285
285
  }
286
- // TODO/now dedupe
287
- function isRelativeImportPath(importPath) {
288
- return importPath.startsWith('./') || importPath.startsWith('../');
289
- }
@@ -1,5 +1,5 @@
1
1
  export { executeGuardHook };
2
- import { getHook, getHookTimeoutDefault } from '../hooks/getHook.js';
2
+ import { getHookFromPageContext, getHookTimeoutDefault } from '../hooks/getHook.js';
3
3
  import { assert, assertUsage, isCallable } from './utils.js';
4
4
  import { executeHook } from '../hooks/executeHook.js';
5
5
  const errIntro = 'The guard() hook defined by';
@@ -12,7 +12,7 @@ async function executeGuardHook(pageContext, prepareForUserConsumption) {
12
12
  }
13
13
  else {
14
14
  // V1 design
15
- hook = getHook(pageContext, 'guard');
15
+ hook = getHookFromPageContext(pageContext, 'guard');
16
16
  }
17
17
  if (!hook)
18
18
  return;
@@ -8,7 +8,7 @@ import { getDefinedAtString } from '../page-configs/getConfigDefinedAt.js';
8
8
  import { warnDeprecatedAllowKey } from './resolveRouteFunction.js';
9
9
  import { getHookFromPageConfigGlobal, getHookTimeoutDefault } from '../hooks/getHook.js';
10
10
  async function loadPageRoutes(
11
- // Remove all arguments and use GlobalContextInternal instead?
11
+ // Remove all arguments and use GlobalContextServerInternal instead?
12
12
  pageFilesAll, pageConfigs, pageConfigGlobal, allPageIds) {
13
13
  // TODO/next-major: remove & make this function sync
14
14
  await Promise.all(pageFilesAll.filter((p) => p.fileType === '.page.route').map((p) => p.loadFile?.()));
@@ -45,6 +45,7 @@ function getPageRoutes(filesystemRoots, pageFilesAll, pageConfigs, allPageIds) {
45
45
  }
46
46
  else {
47
47
  assert(isCallable(route));
48
+ // TODO/next-major: remove
48
49
  if (getConfigValueRuntime(pageConfig, 'iKnowThePerformanceRisksOfAsyncRouteFunctions', 'boolean'))
49
50
  warnDeprecatedAllowKey();
50
51
  pageRoute = {