vike 0.4.171 → 0.4.172-commit-ea2b76c

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 (201) hide show
  1. package/dist/cjs/node/plugin/plugins/buildConfig.js +3 -4
  2. package/dist/cjs/node/plugin/plugins/devConfig/determineOptimizeDeps.js +18 -15
  3. package/dist/cjs/node/plugin/plugins/devConfig/index.js +2 -1
  4. package/dist/cjs/node/plugin/plugins/envVars.js +2 -1
  5. package/dist/cjs/node/plugin/plugins/extractAssetsPlugin.js +1 -1
  6. package/dist/cjs/node/plugin/plugins/importUserCode/{generateEagerImport.js → addImportStatement.js} +8 -10
  7. package/dist/cjs/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.js +0 -1
  8. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +3 -3
  9. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js +17 -6
  10. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.js +2 -2
  11. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +31 -75
  12. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js +4 -43
  13. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigs.js +9 -50
  14. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/isRuntimeEnvMatch.js +6 -0
  15. package/dist/cjs/node/plugin/shared/addSsrMiddleware.js +17 -2
  16. package/dist/cjs/node/prerender/runPrerender.js +35 -15
  17. package/dist/cjs/node/prerender/utils.js +1 -0
  18. package/dist/cjs/node/runtime/html/injectAssets/getHtmlTags.js +3 -3
  19. package/dist/cjs/node/runtime/html/injectAssets/getViteDevScripts.js +2 -1
  20. package/dist/cjs/node/runtime/html/injectAssets/mergeScriptTags.js +2 -8
  21. package/dist/cjs/node/runtime/html/renderHtml.js +19 -20
  22. package/dist/cjs/node/runtime/html/stream.js +9 -9
  23. package/dist/cjs/node/runtime/renderPage/analyzePage.js +9 -7
  24. package/dist/cjs/node/runtime/renderPage/createHttpResponseObject/getCacheControl.js +1 -1
  25. package/dist/cjs/node/runtime/renderPage/executeOnBeforeRenderAndDataHooks.js +2 -2
  26. package/dist/cjs/node/runtime/renderPage/executeOnRenderHtmlHook.js +8 -8
  27. package/dist/cjs/node/runtime/renderPage/getHttpResponseBody.js +2 -2
  28. package/dist/cjs/node/runtime/renderPage/loadUserFilesServerSide.js +4 -5
  29. package/dist/cjs/node/runtime/renderPage/logErrorHint.js +91 -282
  30. package/dist/cjs/node/runtime/renderPage/preparePageContextForUserConsumptionServerSide.js +2 -2
  31. package/dist/cjs/node/runtime/renderPage/renderPageAlreadyRouted.js +30 -10
  32. package/dist/cjs/node/runtime/renderPage.js +24 -17
  33. package/dist/cjs/node/runtime/utils.js +2 -0
  34. package/dist/cjs/node/shared/assertV1Design.js +3 -4
  35. package/dist/cjs/shared/getPageContext.js +5 -0
  36. package/dist/cjs/shared/{addUrlComputedProps.js → getPageContextUrlComputed.js} +52 -42
  37. package/dist/cjs/shared/getPageFiles/analyzeClientSide.js +2 -2
  38. package/dist/cjs/shared/getPageFiles/getExports.js +49 -1
  39. package/dist/cjs/shared/getPageFiles/parseGlobResults.js +15 -8
  40. package/dist/cjs/shared/hooks/executeHook.js +22 -3
  41. package/dist/cjs/shared/hooks/getHook.js +2 -2
  42. package/dist/cjs/shared/page-configs/getConfigValue.js +14 -17
  43. package/dist/cjs/shared/page-configs/getConfigValueBuildTime.js +70 -0
  44. package/dist/cjs/shared/page-configs/loadConfigValues.js +3 -12
  45. package/dist/cjs/shared/page-configs/serialize/assertPageConfigsSerialized.js +0 -18
  46. package/dist/cjs/shared/page-configs/serialize/parsePageConfigs.js +110 -16
  47. package/dist/cjs/shared/page-configs/serialize/serializeConfigValues.js +198 -0
  48. package/dist/cjs/shared/route/executeGuardHook.js +1 -1
  49. package/dist/cjs/shared/route/executeOnBeforeRouteHook.js +1 -1
  50. package/dist/cjs/shared/route/index.js +2 -2
  51. package/dist/cjs/shared/route/loadPageRoutes.js +2 -2
  52. package/dist/cjs/shared/route/resolveRouteFunction.js +2 -2
  53. package/dist/cjs/shared/sortPageContext.js +4 -8
  54. package/dist/cjs/shared/utils.js +2 -0
  55. package/dist/cjs/utils/assert.js +1 -1
  56. package/dist/cjs/utils/assertNodeVersion.js +1 -1
  57. package/dist/cjs/utils/changeEnumerable.js +9 -0
  58. package/dist/cjs/utils/escapeHtml.js +14 -0
  59. package/dist/cjs/utils/getPropAccessNotation.js +1 -4
  60. package/dist/cjs/utils/hasProp.js +5 -7
  61. package/dist/cjs/utils/normalizeHeaders.js +13 -0
  62. package/dist/cjs/utils/objectAssign.js +1 -1
  63. package/dist/cjs/utils/objectDefineProperty.js +8 -0
  64. package/dist/cjs/utils/objectKeys.js +8 -4
  65. package/dist/cjs/utils/projectInfo.js +1 -1
  66. package/dist/esm/client/client-routing-runtime/createPageContext.d.ts +6 -4
  67. package/dist/esm/client/client-routing-runtime/createPageContext.js +4 -3
  68. package/dist/esm/client/client-routing-runtime/getPageContextFromHooks.js +16 -12
  69. package/dist/esm/client/client-routing-runtime/installClientRouter.js +18 -10
  70. package/dist/esm/client/client-routing-runtime/renderPageClientSide.js +3 -3
  71. package/dist/esm/client/server-routing-runtime/getPageContext.d.ts +4 -4
  72. package/dist/esm/client/server-routing-runtime/utils.d.ts +1 -0
  73. package/dist/esm/client/server-routing-runtime/utils.js +1 -0
  74. package/dist/esm/client/shared/executeOnRenderClientHook.js +1 -1
  75. package/dist/esm/client/shared/getPageContextProxyForUser.d.ts +3 -2
  76. package/dist/esm/client/shared/getPageContextProxyForUser.js +35 -48
  77. package/dist/esm/client/shared/loadUserFilesClientSide.js +4 -4
  78. package/dist/esm/node/plugin/plugins/buildConfig.js +3 -4
  79. package/dist/esm/node/plugin/plugins/devConfig/determineOptimizeDeps.js +18 -15
  80. package/dist/esm/node/plugin/plugins/devConfig/index.js +2 -1
  81. package/dist/esm/node/plugin/plugins/envVars.js +2 -1
  82. package/dist/esm/node/plugin/plugins/extractAssetsPlugin.js +1 -1
  83. package/dist/esm/node/plugin/plugins/importUserCode/addImportStatement.d.ts +14 -0
  84. package/dist/esm/node/plugin/plugins/importUserCode/{generateEagerImport.js → addImportStatement.js} +7 -9
  85. package/dist/esm/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.js +0 -1
  86. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.d.ts +2 -1
  87. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +3 -3
  88. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js +18 -7
  89. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.js +2 -2
  90. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +31 -75
  91. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js +4 -43
  92. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigs.js +9 -50
  93. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/isRuntimeEnvMatch.d.ts +1 -0
  94. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/isRuntimeEnvMatch.js +6 -0
  95. package/dist/esm/node/plugin/shared/addSsrMiddleware.js +14 -2
  96. package/dist/esm/node/prerender/runPrerender.js +37 -17
  97. package/dist/esm/node/prerender/utils.d.ts +1 -0
  98. package/dist/esm/node/prerender/utils.js +1 -0
  99. package/dist/esm/node/runtime/html/injectAssets/getHtmlTags.js +3 -3
  100. package/dist/esm/node/runtime/html/injectAssets/getViteDevScripts.js +3 -2
  101. package/dist/esm/node/runtime/html/injectAssets/mergeScriptTags.d.ts +1 -1
  102. package/dist/esm/node/runtime/html/injectAssets/mergeScriptTags.js +2 -8
  103. package/dist/esm/node/runtime/html/renderHtml.js +19 -20
  104. package/dist/esm/node/runtime/html/stream.d.ts +1 -1
  105. package/dist/esm/node/runtime/html/stream.js +9 -9
  106. package/dist/esm/node/runtime/renderPage/analyzePage.js +9 -7
  107. package/dist/esm/node/runtime/renderPage/createHttpResponseObject/getCacheControl.js +2 -2
  108. package/dist/esm/node/runtime/renderPage/executeOnBeforeRenderAndDataHooks.js +2 -2
  109. package/dist/esm/node/runtime/renderPage/executeOnRenderHtmlHook.js +8 -8
  110. package/dist/esm/node/runtime/renderPage/getHttpResponseBody.js +2 -2
  111. package/dist/esm/node/runtime/renderPage/loadUserFilesServerSide.d.ts +1 -6
  112. package/dist/esm/node/runtime/renderPage/loadUserFilesServerSide.js +4 -5
  113. package/dist/esm/node/runtime/renderPage/logErrorHint.d.ts +2 -6
  114. package/dist/esm/node/runtime/renderPage/logErrorHint.js +92 -283
  115. package/dist/esm/node/runtime/renderPage/preparePageContextForUserConsumptionServerSide.d.ts +2 -2
  116. package/dist/esm/node/runtime/renderPage/preparePageContextForUserConsumptionServerSide.js +2 -2
  117. package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.d.ts +65 -39
  118. package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.js +31 -11
  119. package/dist/esm/node/runtime/renderPage.js +24 -17
  120. package/dist/esm/node/runtime/utils.d.ts +2 -0
  121. package/dist/esm/node/runtime/utils.js +2 -0
  122. package/dist/esm/node/shared/assertV1Design.d.ts +2 -2
  123. package/dist/esm/node/shared/assertV1Design.js +3 -4
  124. package/dist/esm/shared/VikeNamespace.d.ts +9 -0
  125. package/dist/esm/shared/getPageContext.d.ts +1 -0
  126. package/dist/esm/shared/getPageContext.js +1 -0
  127. package/dist/esm/shared/{addUrlComputedProps.d.ts → getPageContextUrlComputed.d.ts} +23 -21
  128. package/dist/esm/shared/{addUrlComputedProps.js → getPageContextUrlComputed.js} +52 -42
  129. package/dist/esm/shared/getPageFiles/analyzeClientSide.js +3 -3
  130. package/dist/esm/shared/getPageFiles/getExports.d.ts +36 -0
  131. package/dist/esm/shared/getPageFiles/getExports.js +50 -2
  132. package/dist/esm/shared/getPageFiles/parseGlobResults.js +14 -7
  133. package/dist/esm/shared/hooks/executeHook.d.ts +10 -1
  134. package/dist/esm/shared/hooks/executeHook.js +21 -2
  135. package/dist/esm/shared/hooks/getHook.d.ts +2 -2
  136. package/dist/esm/shared/hooks/getHook.js +3 -3
  137. package/dist/esm/shared/page-configs/Config/PageContextConfig.d.ts +2 -2
  138. package/dist/esm/shared/page-configs/PageConfig.d.ts +14 -8
  139. package/dist/esm/shared/page-configs/getConfigValue.d.ts +12 -12
  140. package/dist/esm/shared/page-configs/getConfigValue.js +13 -16
  141. package/dist/esm/shared/page-configs/getConfigValueBuildTime.d.ts +9 -0
  142. package/dist/esm/shared/page-configs/getConfigValueBuildTime.js +67 -0
  143. package/dist/esm/shared/page-configs/loadConfigValues.js +3 -12
  144. package/dist/esm/shared/page-configs/serialize/PageConfigSerialized.d.ts +17 -21
  145. package/dist/esm/shared/page-configs/serialize/assertPageConfigsSerialized.d.ts +1 -5
  146. package/dist/esm/shared/page-configs/serialize/assertPageConfigsSerialized.js +1 -16
  147. package/dist/esm/shared/page-configs/serialize/parsePageConfigs.d.ts +4 -1
  148. package/dist/esm/shared/page-configs/serialize/parsePageConfigs.js +109 -15
  149. package/dist/esm/shared/page-configs/serialize/serializeConfigValues.d.ts +5 -0
  150. package/dist/esm/shared/page-configs/serialize/serializeConfigValues.js +192 -0
  151. package/dist/esm/shared/route/executeGuardHook.js +1 -1
  152. package/dist/esm/shared/route/executeOnBeforeRouteHook.js +1 -1
  153. package/dist/esm/shared/route/index.d.ts +3 -3
  154. package/dist/esm/shared/route/index.js +2 -2
  155. package/dist/esm/shared/route/loadPageRoutes.js +3 -3
  156. package/dist/esm/shared/route/resolveRouteFunction.d.ts +2 -2
  157. package/dist/esm/shared/route/resolveRouteFunction.js +2 -2
  158. package/dist/esm/shared/sortPageContext.js +4 -8
  159. package/dist/esm/shared/types.d.ts +32 -6
  160. package/dist/esm/shared/utils.d.ts +2 -0
  161. package/dist/esm/shared/utils.js +2 -0
  162. package/dist/esm/types/index.d.ts +1 -1
  163. package/dist/esm/utils/assert.js +1 -1
  164. package/dist/esm/utils/assertNodeVersion.js +1 -1
  165. package/dist/esm/utils/changeEnumerable.d.ts +2 -0
  166. package/dist/esm/utils/changeEnumerable.js +5 -0
  167. package/dist/esm/utils/escapeHtml.d.ts +1 -0
  168. package/dist/esm/utils/escapeHtml.js +10 -0
  169. package/dist/esm/utils/getPropAccessNotation.d.ts +1 -2
  170. package/dist/esm/utils/getPropAccessNotation.js +2 -6
  171. package/dist/esm/utils/hasProp.d.ts +4 -13
  172. package/dist/esm/utils/hasProp.js +5 -7
  173. package/dist/esm/utils/normalizeHeaders.d.ts +1 -0
  174. package/dist/esm/utils/normalizeHeaders.js +9 -0
  175. package/dist/esm/utils/objectAssign.js +1 -1
  176. package/dist/esm/utils/objectDefineProperty.d.ts +4 -0
  177. package/dist/esm/utils/objectDefineProperty.js +4 -0
  178. package/dist/esm/utils/objectKeys.d.ts +1 -3
  179. package/dist/esm/utils/objectKeys.js +8 -4
  180. package/dist/esm/utils/projectInfo.d.ts +2 -2
  181. package/dist/esm/utils/projectInfo.js +1 -1
  182. package/package.json +21 -12
  183. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getConfigValuesSerialized.js +0 -76
  184. package/dist/cjs/node/plugin/shared/getConfigValueSourcesNotOverriden.js +0 -14
  185. package/dist/cjs/node/shared/getClientEntry.js +0 -12
  186. package/dist/cjs/shared/page-configs/serialize/parseConfigValuesImported.js +0 -85
  187. package/dist/cjs/shared/page-configs/serialize/parseConfigValuesSerialized.js +0 -24
  188. package/dist/cjs/shared/page-configs/serialize/serializeConfigValue.js +0 -50
  189. package/dist/esm/node/plugin/plugins/importUserCode/generateEagerImport.d.ts +0 -16
  190. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getConfigValuesSerialized.d.ts +0 -5
  191. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getConfigValuesSerialized.js +0 -70
  192. package/dist/esm/node/plugin/shared/getConfigValueSourcesNotOverriden.d.ts +0 -5
  193. package/dist/esm/node/plugin/shared/getConfigValueSourcesNotOverriden.js +0 -11
  194. package/dist/esm/node/shared/getClientEntry.d.ts +0 -3
  195. package/dist/esm/node/shared/getClientEntry.js +0 -9
  196. package/dist/esm/shared/page-configs/serialize/parseConfigValuesImported.d.ts +0 -4
  197. package/dist/esm/shared/page-configs/serialize/parseConfigValuesImported.js +0 -82
  198. package/dist/esm/shared/page-configs/serialize/parseConfigValuesSerialized.d.ts +0 -4
  199. package/dist/esm/shared/page-configs/serialize/parseConfigValuesSerialized.js +0 -21
  200. package/dist/esm/shared/page-configs/serialize/serializeConfigValue.d.ts +0 -8
  201. package/dist/esm/shared/page-configs/serialize/serializeConfigValue.js +0 -47
@@ -1,15 +1,6 @@
1
1
  export { hasProp };
2
- declare function hasProp<ObjectType, PropName extends PropertyKey>(obj: ObjectType, prop: PropName, type: 'boolean'): obj is ObjectType & Record<PropName, boolean>;
3
- declare function hasProp<ObjectType, PropName extends PropertyKey>(obj: ObjectType, prop: PropName, type: 'number'): obj is ObjectType & Record<PropName, number>;
4
- declare function hasProp<ObjectType, PropName extends PropertyKey>(obj: ObjectType, prop: PropName, type: 'string'): obj is ObjectType & Record<PropName, string>;
5
- declare function hasProp<ObjectType, PropName extends PropertyKey>(obj: ObjectType, prop: PropName, type: 'object'): obj is ObjectType & Record<PropName, Record<string, unknown>>;
6
- declare function hasProp<ObjectType, PropName extends PropertyKey>(obj: ObjectType, prop: PropName, type: 'array'): obj is ObjectType & Record<PropName, unknown[]>;
7
- declare function hasProp<ObjectType, PropName extends PropertyKey>(obj: ObjectType, prop: PropName, type: 'string[]'): obj is ObjectType & Record<PropName, string[]>;
8
- declare function hasProp<ObjectType, PropName extends PropertyKey>(obj: ObjectType, prop: PropName, type: 'string{}'): obj is ObjectType & Record<PropName, Record<string, string>>;
9
- declare function hasProp<ObjectType, PropName extends PropertyKey>(obj: ObjectType, prop: PropName, type: 'function'): obj is ObjectType & Record<PropName, (...args: any[]) => unknown>;
10
- declare function hasProp<ObjectType, PropName extends PropertyKey>(obj: ObjectType, prop: PropName, type: 'undefined'): obj is ObjectType & Record<PropName, undefined>;
11
- declare function hasProp<ObjectType, PropName extends PropertyKey>(obj: ObjectType, prop: PropName, type: 'null'): obj is ObjectType & Record<PropName, null>;
12
- declare function hasProp<ObjectType, PropName extends PropertyKey>(obj: ObjectType, prop: PropName, type: 'true'): obj is ObjectType & Record<PropName, true>;
13
- declare function hasProp<ObjectType, PropName extends PropertyKey>(obj: ObjectType, prop: PropName, type: 'false'): obj is ObjectType & Record<PropName, false>;
2
+ export type { ResolveTypeAsString };
3
+ type TypeAsString = 'object' | 'string{}' | 'string[]' | 'array' | 'function' | 'number' | 'string' | 'boolean' | 'true' | 'false' | 'null' | 'undefined' | undefined;
4
+ type ResolveTypeAsString<Type extends TypeAsString = undefined> = Type extends 'object' ? Record<string, unknown> : Type extends 'string{}' ? Record<string, string> : Type extends 'string[]' ? string[] : Type extends 'array' ? unknown[] : Type extends 'function' ? (...args: any[]) => unknown : Type extends 'number' ? number : Type extends 'string' ? string : Type extends 'boolean' ? boolean : Type extends 'true' ? true : Type extends 'false' ? false : Type extends 'null' ? null : Type extends 'undefined' ? undefined : Type extends undefined ? unknown : never;
5
+ declare function hasProp<ObjectType, PropName extends PropertyKey, Type extends TypeAsString = undefined>(obj: ObjectType, prop: PropName, type?: Type): obj is ObjectType & Record<PropName, ResolveTypeAsString<Type>>;
14
6
  declare function hasProp<ObjectType, PropName extends PropertyKey, Enum>(obj: ObjectType, prop: PropName, type: Enum[]): obj is ObjectType & Record<PropName, Enum>;
15
- declare function hasProp<ObjectType, PropName extends PropertyKey>(obj: ObjectType, prop: PropName): obj is ObjectType & Record<PropName, unknown>;
@@ -1,21 +1,22 @@
1
1
  export { hasProp };
2
- // - https://2ality.com/2020/06/type-guards-assertion-functions-typescript.html
3
- // - https://www.typescriptlang.org/play?#code/GYVwdgxgLglg9mABDAzgFQJ4AcCmdgAUAbgIYA2IOAXIiWBgDSJTbWIDkARnHGTnewCUNUhRzIUibr35gA3AFgAUKEiwEEzLnzFylGnUbNWNdmBABbTjgBOQkXvGpE5q7cUrw0eElRa8hKL6tPRMLLimKFA2MGAA5vaIQU6SUTHxHqreGn6sOskGocYRHOAA1mBwAO5gickSiOWVNZle6r7oeYGOhUbhbGmxcYgAvKVgFdW1wlI8fHSIAN7KiMiExeIjW+OTNeyIgksrq4g2OFAgNkjRlMcAvsdnF1cb+EmOo9v9Hg9KyhAIKK0GhNKajRAAFgATMplCQUChbFACLltIQSEwzJZrHZBIJ-oCZAA6MhwOIEEj4v6eNQ+WgIpEEAFgAAmMHaIImzTAM3hiJsUEkzLZ7SOShOa0QTIQIp8hyelzAx1WUAAFjZqi4cFVEABRGwamwEdgAQQZArpADESDAyEJlHcgA
4
2
  import { isCallable } from './isCallable.js';
5
3
  import { isObject } from './isObject.js';
6
4
  import { isArrayOfStrings } from './isArrayOfStrings.js';
7
5
  import { isObjectOfStrings } from './isObjectOfStrings.js';
8
6
  import { isArray } from './isArray.js';
9
- function hasProp(obj, prop, type = 'unknown') {
7
+ function hasProp(obj, prop, type) {
10
8
  if (!isObject(obj))
11
9
  return false;
12
10
  if (!(prop in obj)) {
13
11
  return type === 'undefined';
14
12
  }
15
- if (type === 'unknown') {
13
+ if (type === undefined) {
16
14
  return true;
17
15
  }
18
16
  const propValue = obj[prop];
17
+ if (type === 'undefined') {
18
+ return propValue === undefined;
19
+ }
19
20
  if (type === 'array') {
20
21
  return isArray(propValue);
21
22
  }
@@ -37,9 +38,6 @@ function hasProp(obj, prop, type = 'unknown') {
37
38
  if (type === 'null') {
38
39
  return propValue === null;
39
40
  }
40
- if (type === 'undefined') {
41
- return propValue === undefined;
42
- }
43
41
  if (type === 'true') {
44
42
  return propValue === true;
45
43
  }
@@ -0,0 +1 @@
1
+ export declare function normalizeHeaders(headersOriginal: unknown): Record<string, string>;
@@ -0,0 +1,9 @@
1
+ export function normalizeHeaders(
2
+ /* This type is precise, too precise which can be annoying: e.g. cannot pass a string[][] argument because it doesn't match the more precise [string,string][] type.
3
+ headersOriginal ConstructorParameters<typeof Headers>[0]
4
+ */
5
+ headersOriginal) {
6
+ const headersStandard = new Headers(headersOriginal);
7
+ const headers = Object.fromEntries(headersStandard.entries());
8
+ return headers;
9
+ }
@@ -1,7 +1,7 @@
1
1
  export { objectAssign };
2
2
  // Same as Object.assign() but:
3
3
  // - With type inference
4
- // - Preserves property descriptors, which we need for preserving the getters added by addUrlComputedProps()
4
+ // - Preserves property descriptors, which we need for preserving the getters added by getPageContextUrlComputed()
5
5
  function objectAssign(obj, objAddendum) {
6
6
  if (objAddendum) {
7
7
  Object.defineProperties(obj, Object.getOwnPropertyDescriptors(objAddendum));
@@ -0,0 +1,4 @@
1
+ /** Like Object.defineProperty() but with type inference */
2
+ export declare function objectDefineProperty<Obj extends object, Prop extends PropertyKey, PropertyType>(obj: Obj, prop: Prop, { get, ...args }: {
3
+ get: () => PropertyType;
4
+ } & Omit<PropertyDescriptor, 'set' | 'get'>): asserts obj is Obj & Record<Prop, PropertyType>;
@@ -0,0 +1,4 @@
1
+ /** Like Object.defineProperty() but with type inference */
2
+ export function objectDefineProperty(obj, prop, { get, ...args }) {
3
+ Object.defineProperty(obj, prop, { ...args, get });
4
+ }
@@ -1,10 +1,8 @@
1
1
  export { objectEntries };
2
2
  export { objectFromEntries };
3
3
  export { objectKeys };
4
- type ValueOf<T> = T[keyof T];
5
- type Entries<T> = [keyof T, ValueOf<T>][];
6
4
  /** Same as Object.entries() but with type inference */
7
- declare function objectEntries<T extends object>(obj: T): Entries<T>;
5
+ declare function objectEntries<T extends object>(obj: T): [keyof T, T[keyof T]][];
8
6
  /** Same as Object.fromEntries() but with type inference */
9
7
  declare function objectFromEntries<T extends [PropertyKey, unknown][]>(arr: T): Record<T[number][0], T[number][1]>;
10
8
  /** Same as Object.keys() but with type inference */
@@ -1,6 +1,7 @@
1
1
  export { objectEntries };
2
2
  export { objectFromEntries };
3
3
  export { objectKeys };
4
+ // export { forEach }
4
5
  // https://stackoverflow.com/questions/60141960/typescript-key-value-relation-preserving-object-entries-type/75337277#75337277
5
6
  /** Same as Object.entries() but with type inference */
6
7
  function objectEntries(obj) {
@@ -16,8 +17,11 @@ function objectFromEntries(arr) {
16
17
  function objectKeys(obj) {
17
18
  return Object.keys(obj);
18
19
  }
19
- /*
20
- function objectKeys2<T extends Record<string, unknown>>(obj: T): Array<keyof T> {
21
- return Object.keys(obj)
20
+ /* Not used yet, but can be quite useful.
21
+ function forEach<Obj extends object>(
22
+ obj: Obj,
23
+ iterator: <Key extends keyof Obj>(key: Key, val: Obj[Key]) => void
24
+ ): void {
25
+ Object.entries(obj).forEach(([key, val]) => iterator(key as keyof Obj, val))
22
26
  }
23
- */
27
+ //*/
@@ -1,7 +1,7 @@
1
1
  export { projectInfo };
2
2
  export { PROJECT_VERSION };
3
- declare const PROJECT_VERSION: "0.4.171";
3
+ declare const PROJECT_VERSION: "0.4.172-commit-ea2b76c";
4
4
  declare const projectInfo: {
5
5
  projectName: "Vike";
6
- projectVersion: "0.4.171";
6
+ projectVersion: "0.4.172-commit-ea2b76c";
7
7
  };
@@ -1,6 +1,6 @@
1
1
  export { projectInfo };
2
2
  export { PROJECT_VERSION };
3
- const PROJECT_VERSION = '0.4.171';
3
+ const PROJECT_VERSION = '0.4.172-commit-ea2b76c';
4
4
  const projectInfo = {
5
5
  projectName: 'Vike',
6
6
  projectVersion: PROJECT_VERSION
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vike",
3
- "version": "0.4.171",
3
+ "version": "0.4.172-commit-ea2b76c",
4
4
  "scripts": {
5
5
  "dev": "tsc --watch",
6
6
  "build": "rimraf dist/ && pnpm run build:esm && pnpm run build:cjs",
@@ -14,7 +14,7 @@
14
14
  },
15
15
  "dependencies": {
16
16
  "@brillout/import": "^0.2.3",
17
- "@brillout/json-serializer": "^0.5.8",
17
+ "@brillout/json-serializer": "^0.5.10",
18
18
  "@brillout/picocolors": "^1.0.10",
19
19
  "@brillout/require-shim": "^0.1.2",
20
20
  "@brillout/vite-plugin-server-entry": "^0.4.5",
@@ -106,6 +106,15 @@
106
106
  "types": "./dist/esm/shared/abort.d.ts",
107
107
  "default": "./dist/esm/shared/abort.js"
108
108
  },
109
+ "./getPageContext": {
110
+ "worker": "./dist/esm/shared/getPageContext.js",
111
+ "edge-light": "./dist/esm/shared/getPageContext.js",
112
+ "require": "./dist/cjs/shared/getPageContext.js",
113
+ "node": "./dist/esm/shared/getPageContext.js",
114
+ "browser": "./dist/esm/shared/getPageContext.js",
115
+ "types": "./dist/esm/shared/getPageContext.d.ts",
116
+ "default": "./dist/esm/shared/getPageContext.js"
117
+ },
109
118
  "./__internal": {
110
119
  "require": "./dist/cjs/__internal/index.js",
111
120
  "node": "./dist/esm/__internal/index.js",
@@ -186,28 +195,28 @@
186
195
  "@brillout/import": "^0.2.3",
187
196
  "@brillout/json-serializer": "^0.5.8",
188
197
  "@brillout/picocolors": "^1.0.10",
198
+ "@brillout/release-me": "^0.3.8",
189
199
  "@brillout/require-shim": "^0.1.2",
190
200
  "@brillout/vite-plugin-server-entry": "^0.4.0",
191
- "acorn": "^8.11.2",
192
- "cac": "^6.7.14",
193
- "es-module-lexer": "^1.4.1",
194
- "esbuild": "^0.19.10",
195
- "fast-glob": "^3.3.2",
196
- "sirv": "^2.0.4",
197
- "source-map-support": "^0.5.21",
198
- "@brillout/release-me": "^0.2.2",
199
201
  "@types/estree": "^1.0.5",
200
202
  "@types/jest": "^29.5.11",
201
203
  "@types/node": "^20.10.5",
202
204
  "@types/resolve": "^1.20.6",
203
205
  "@types/source-map-support": "^0.5.10",
206
+ "acorn": "^8.11.2",
207
+ "cac": "^6.7.14",
208
+ "es-module-lexer": "^1.4.1",
209
+ "esbuild": "^0.19.10",
210
+ "fast-glob": "^3.3.2",
204
211
  "react-streaming": "^0.3.24",
205
212
  "rimraf": "^5.0.5",
206
- "typescript": "^5.3.3",
213
+ "sirv": "^2.0.4",
214
+ "source-map-support": "^0.5.21",
215
+ "typescript": "^5.4.5",
207
216
  "vite": "npm:@brillout/vite@5.1.0-commit-3dc7abd"
208
217
  },
209
218
  "engines": {
210
- "node": ">=16.0.0"
219
+ "node": ">=18.0.0"
211
220
  },
212
221
  "description": "Like Next.js/Nuxt but as do-one-thing-do-it-well Vite plugin.",
213
222
  "repository": "https://github.com/vikejs/vike",
@@ -1,76 +0,0 @@
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.assertConfigValueIsSerializable = exports.getConfigValuesSerialized = void 0;
7
- const utils_js_1 = require("../../../utils.js");
8
- const stringify_1 = require("@brillout/json-serializer/stringify");
9
- const picocolors_1 = __importDefault(require("@brillout/picocolors"));
10
- const helpers_js_1 = require("../../../../../shared/page-configs/helpers.js");
11
- const serializeConfigValue_js_1 = require("../../../../../shared/page-configs/serialize/serializeConfigValue.js");
12
- const getConfigValueSourcesNotOverriden_js_1 = require("../../../shared/getConfigValueSourcesNotOverriden.js");
13
- function getConfigValuesSerialized(pageConfig, isEnvMatch) {
14
- const lines = [];
15
- Object.entries(pageConfig.configValuesComputed).forEach(([configName, configValuesComputed]) => {
16
- const { configEnv } = configValuesComputed;
17
- if (!isEnvMatch(configEnv))
18
- return;
19
- // configValeSources has higher precedence
20
- if (pageConfig.configValueSources[configName])
21
- return;
22
- const configValue = pageConfig.configValues[configName];
23
- (0, utils_js_1.assert)(configValue);
24
- const { value, ...common } = configValue;
25
- (0, utils_js_1.assert)(value === configValuesComputed.value);
26
- const valueSerialized = getConfigValueSerialized(value, configName, configValue.definedAtData);
27
- const configValueSerialized = { valueSerialized, ...common };
28
- (0, serializeConfigValue_js_1.serializeConfigValue)(lines, configName, configValueSerialized);
29
- });
30
- (0, getConfigValueSourcesNotOverriden_js_1.getConfigValueSourcesNotOverriden)(pageConfig).forEach((configValueSource) => {
31
- const { configName, configEnv } = configValueSource;
32
- const configValue = pageConfig.configValues[configName];
33
- if (!configValue)
34
- return;
35
- if (!isEnvMatch(configEnv, configValueSource)) {
36
- return;
37
- }
38
- const { value, ...common } = configValue;
39
- const valueSerialized = getConfigValueSerialized(value, configName, configValue.definedAtData);
40
- const configValueSerialized = { valueSerialized, ...common };
41
- (0, serializeConfigValue_js_1.serializeConfigValue)(lines, configName, configValueSerialized);
42
- });
43
- const code = lines.join('\n');
44
- return code;
45
- }
46
- exports.getConfigValuesSerialized = getConfigValuesSerialized;
47
- function assertConfigValueIsSerializable(value, configName, definedAtData) {
48
- // Contains asserts
49
- getConfigValueSerialized(value, configName, definedAtData);
50
- }
51
- exports.assertConfigValueIsSerializable = assertConfigValueIsSerializable;
52
- function getConfigValueSerialized(value, configName, definedAtData) {
53
- const valueName = `config${(0, utils_js_1.getPropAccessNotation)(configName)}`;
54
- let configValueSerialized;
55
- try {
56
- configValueSerialized = (0, stringify_1.stringify)(value, { valueName, forbidReactElements: true });
57
- }
58
- catch (err) {
59
- /*
60
- let serializationErrMsg = ''
61
- if (isJsonSerializerError(err)) {
62
- serializationErrMsg = err.messageCore
63
- } else {
64
- // When a property getter throws an error
65
- console.error('Serialization error:')
66
- console.error(err)
67
- serializationErrMsg = 'see serialization error printed above'
68
- }
69
- */
70
- const configValueFilePathToShowToUser = (0, helpers_js_1.getConfigValueFilePathToShowToUser)(definedAtData);
71
- (0, utils_js_1.assert)(configValueFilePathToShowToUser);
72
- (0, utils_js_1.assertUsage)(false, `${picocolors_1.default.cyan(configName)} defined by ${configValueFilePathToShowToUser} must be defined over a so-called "pointer import", see https://vike.dev/config#pointer-imports`);
73
- }
74
- configValueSerialized = JSON.stringify(configValueSerialized);
75
- return configValueSerialized;
76
- }
@@ -1,14 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getConfigValueSourcesNotOverriden = void 0;
4
- const utils_js_1 = require("../../shared/utils.js");
5
- (0, utils_js_1.assertIsNotBrowser)();
6
- function getConfigValueSourcesNotOverriden(pageConfig) {
7
- const configValueSourcesRelevant = Object.entries(pageConfig.configValueSources).map(([configName, sources]) => {
8
- const configValueSource = sources[0];
9
- (0, utils_js_1.assert)(configValueSource);
10
- return { configName, ...configValueSource };
11
- });
12
- return configValueSourcesRelevant;
13
- }
14
- exports.getConfigValueSourcesNotOverriden = getConfigValueSourcesNotOverriden;
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getClientEntry = void 0;
4
- const getConfigValue_js_1 = require("../../shared/page-configs/getConfigValue.js");
5
- function getClientEntry(pageConfig) {
6
- const configName = 'client';
7
- const configValue = (0, getConfigValue_js_1.getConfigValue)(pageConfig, configName, 'string');
8
- if (!configValue)
9
- return null;
10
- return configValue.value;
11
- }
12
- exports.getClientEntry = getClientEntry;
@@ -1,85 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parseConfigValuesImported = void 0;
4
- const utils_js_1 = require("../../utils.js");
5
- const assertPlusFileExport_js_1 = require("../assertPlusFileExport.js");
6
- function parseConfigValuesImported(configValuesImported) {
7
- const configValuesUnmerged = {};
8
- configValuesImported
9
- .filter((c) => c.configName !== 'client')
10
- .forEach((configValueLoaded) => {
11
- if (configValueLoaded.isValueFile) {
12
- const { exportValues, importPath, configName } = configValueLoaded;
13
- (0, assertPlusFileExport_js_1.assertPlusFileExport)(exportValues, importPath, configName);
14
- Object.entries(exportValues).forEach(([exportName, exportValue]) => {
15
- const isSideExport = exportName !== 'default'; // .md files may have "side-exports" such as `export { frontmatter }`
16
- const configName = isSideExport ? exportName : configValueLoaded.configName;
17
- configValuesUnmerged[configName] ?? (configValuesUnmerged[configName] = []);
18
- configValuesUnmerged[configName].push({
19
- value: exportValue,
20
- importPath,
21
- exportName,
22
- isSideExport
23
- });
24
- });
25
- }
26
- else {
27
- const { configName, importPath, exportValue, exportName } = configValueLoaded;
28
- configValuesUnmerged[configName] ?? (configValuesUnmerged[configName] = []);
29
- configValuesUnmerged[configName].push({
30
- value: exportValue,
31
- importPath,
32
- exportName,
33
- isSideExport: false
34
- });
35
- }
36
- });
37
- const configValues = {};
38
- Object.entries(configValuesUnmerged).forEach(([configName, values]) => {
39
- const valuesWithoutSideExports = values.filter((v) => !v.isSideExport);
40
- const isCumulative = valuesWithoutSideExports.length > 1;
41
- const noSideExports = valuesWithoutSideExports.length === values.length;
42
- if (isCumulative) {
43
- // Vike currently doesn't support side exports for cumulative configs
44
- (0, utils_js_1.assert)(noSideExports);
45
- // TODO: implement
46
- (0, utils_js_1.assert)(false);
47
- }
48
- else {
49
- const val = valuesWithoutSideExports[0] ??
50
- // We can't avoid side-export conflicts upstream. (We cannot know about side-exports at build-time.)
51
- // Side-exports have lower precedence.
52
- values[0];
53
- (0, utils_js_1.assert)(val);
54
- const { value, importPath, exportName } = val;
55
- configValues[configName] = {
56
- type: 'classic',
57
- value,
58
- definedAtData: {
59
- // importPath cannot be relative to the current file, since the current file is a virtual file
60
- filePathToShowToUser: importPath,
61
- fileExportPathToShowToUser: [configName, 'default'].includes(exportName)
62
- ? []
63
- : [
64
- // Side-export
65
- exportName
66
- ]
67
- }
68
- };
69
- assertIsNotNull(value, configName, importPath);
70
- }
71
- });
72
- return configValues;
73
- }
74
- exports.parseConfigValuesImported = parseConfigValuesImported;
75
- function assertIsNotNull(configValue, configName, importPath) {
76
- (0, utils_js_1.assert)(!importPath.includes('+config.'));
77
- /* Re-use this for:
78
- * - upcoming config.requestPageContextOnNavigation
79
- * - for cumulative values in the future: we don't need this for now because, currently, cumulative values are never imported.
80
- assertUsage(
81
- configValue !== null,
82
- `Set ${pc.cyan(configName)} to ${pc.cyan('null')} in a +config.js file instead of ${importPath}`
83
- )
84
- */
85
- }
@@ -1,24 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parseConfigValuesSerialized = void 0;
4
- const utils_js_1 = require("../../utils.js");
5
- const parse_1 = require("@brillout/json-serializer/parse");
6
- function parseConfigValuesSerialized(configValuesSerialized) {
7
- const configValues = {};
8
- Object.entries(configValuesSerialized).forEach(([configName, configValueSeriliazed]) => {
9
- (0, utils_js_1.assert)(!configValues[configName]);
10
- const { valueSerialized, ...common } = configValueSeriliazed;
11
- const value = (0, parse_1.parse)(valueSerialized);
12
- let configValue;
13
- if (common.type === 'cumulative') {
14
- (0, utils_js_1.assert)((0, utils_js_1.isArray)(value));
15
- configValue = { value, ...common };
16
- }
17
- else {
18
- configValue = { value, ...common };
19
- }
20
- configValues[configName] = configValue;
21
- });
22
- return configValues;
23
- }
24
- exports.parseConfigValuesSerialized = parseConfigValuesSerialized;
@@ -1,50 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.serializeConfigValueImported = exports.serializeConfigValue = void 0;
4
- // This file is never loaded on the client-side but we save it under the vike/shared/ directory in order to collocate it with:
5
- // - vike/shared/page-configs/serialize/parsePageConfigs.ts
6
- // - vike/shared/page-configs/serialize/parseConfigValuesImported.ts
7
- // Both parsePageConfigs() parseConfigValuesImported() and are loaded on the client-side and server-side
8
- const assertIsNotProductionRuntime_js_1 = require("../../../utils/assertIsNotProductionRuntime.js");
9
- (0, assertIsNotProductionRuntime_js_1.assertIsNotProductionRuntime)();
10
- const utils_js_1 = require("../../utils.js");
11
- const generateEagerImport_js_1 = require("../../../node/plugin/plugins/importUserCode/generateEagerImport.js");
12
- function serializeConfigValue(lines, configName, configValueSerialized) {
13
- let whitespace = ' ';
14
- lines.push(`${whitespace}['${configName}']: {`);
15
- whitespace += ' ';
16
- Object.entries(configValueSerialized).forEach(([key, val]) => {
17
- const valSerialized = key === 'valueSerialized' ? val : JSON.stringify(val);
18
- lines.push(`${whitespace} ${key}: ${valSerialized},`);
19
- });
20
- whitespace = whitespace.slice(2);
21
- lines.push(`${whitespace}},`);
22
- }
23
- exports.serializeConfigValue = serializeConfigValue;
24
- function serializeConfigValueImported(configValueSource, configName, whitespace, varCounterContainer, importStatements) {
25
- (0, utils_js_1.assert)(!configValueSource.valueIsFilePath);
26
- (0, utils_js_1.assert)(whitespace.replaceAll(' ', '').length === 0);
27
- const { valueIsImportedAtRuntime, valueIsDefinedByValueFile, definedAtFilePath } = configValueSource;
28
- (0, utils_js_1.assert)(valueIsImportedAtRuntime);
29
- const { filePathAbsoluteVite, fileExportName } = definedAtFilePath;
30
- if (valueIsDefinedByValueFile)
31
- (0, utils_js_1.assert)(fileExportName === undefined);
32
- const { importName, importStatement } = (0, generateEagerImport_js_1.generateEagerImport)(filePathAbsoluteVite, varCounterContainer.varCounter++, fileExportName);
33
- importStatements.push(importStatement);
34
- const lines = [];
35
- lines.push(` {`);
36
- lines.push(` configName: '${configName}',`);
37
- lines.push(` importPath: '${filePathAbsoluteVite}',`);
38
- lines.push(` isValueFile: ${JSON.stringify(valueIsDefinedByValueFile)},`);
39
- if (valueIsDefinedByValueFile) {
40
- lines.push(` exportValues: ${importName},`);
41
- }
42
- else {
43
- lines.push(` exportValue: ${importName},`);
44
- (0, utils_js_1.assert)(fileExportName);
45
- lines.push(` exportName: ${JSON.stringify(fileExportName)},`);
46
- }
47
- lines.push(` },`);
48
- return lines;
49
- }
50
- exports.serializeConfigValueImported = serializeConfigValueImported;
@@ -1,16 +0,0 @@
1
- export { generateEagerImport };
2
- /**
3
- * Naming:
4
- * `import { someExport as someImport } from './some-file'`
5
- * <=>
6
- * `{`
7
- * `importPath: './some-file',`
8
- * `exportName: 'someExport',`
9
- * `importName: 'someImport',`
10
- * `}`
11
- * We discard the information that the import variable is called `someImport` because we don't need it.
12
- */
13
- declare function generateEagerImport(importPath: string, varCounter?: number, exportName?: string): {
14
- importName: string;
15
- importStatement: string;
16
- };
@@ -1,5 +0,0 @@
1
- export { getConfigValuesSerialized };
2
- export { assertConfigValueIsSerializable };
3
- import type { ConfigEnvInternal, ConfigValueSource, DefinedAtData, PageConfigBuildTime } from '../../../../../shared/page-configs/PageConfig.js';
4
- declare function getConfigValuesSerialized(pageConfig: PageConfigBuildTime, isEnvMatch: (configEnv: ConfigEnvInternal, configValueSource?: ConfigValueSource) => boolean): string;
5
- declare function assertConfigValueIsSerializable(value: unknown, configName: string, definedAtData: DefinedAtData): void;
@@ -1,70 +0,0 @@
1
- export { getConfigValuesSerialized };
2
- export { assertConfigValueIsSerializable };
3
- import { assert, assertUsage, getPropAccessNotation } from '../../../utils.js';
4
- import { stringify } from '@brillout/json-serializer/stringify';
5
- import pc from '@brillout/picocolors';
6
- import { getConfigValueFilePathToShowToUser } from '../../../../../shared/page-configs/helpers.js';
7
- import { serializeConfigValue } from '../../../../../shared/page-configs/serialize/serializeConfigValue.js';
8
- import { getConfigValueSourcesNotOverriden } from '../../../shared/getConfigValueSourcesNotOverriden.js';
9
- function getConfigValuesSerialized(pageConfig, isEnvMatch) {
10
- const lines = [];
11
- Object.entries(pageConfig.configValuesComputed).forEach(([configName, configValuesComputed]) => {
12
- const { configEnv } = configValuesComputed;
13
- if (!isEnvMatch(configEnv))
14
- return;
15
- // configValeSources has higher precedence
16
- if (pageConfig.configValueSources[configName])
17
- return;
18
- const configValue = pageConfig.configValues[configName];
19
- assert(configValue);
20
- const { value, ...common } = configValue;
21
- assert(value === configValuesComputed.value);
22
- const valueSerialized = getConfigValueSerialized(value, configName, configValue.definedAtData);
23
- const configValueSerialized = { valueSerialized, ...common };
24
- serializeConfigValue(lines, configName, configValueSerialized);
25
- });
26
- getConfigValueSourcesNotOverriden(pageConfig).forEach((configValueSource) => {
27
- const { configName, configEnv } = configValueSource;
28
- const configValue = pageConfig.configValues[configName];
29
- if (!configValue)
30
- return;
31
- if (!isEnvMatch(configEnv, configValueSource)) {
32
- return;
33
- }
34
- const { value, ...common } = configValue;
35
- const valueSerialized = getConfigValueSerialized(value, configName, configValue.definedAtData);
36
- const configValueSerialized = { valueSerialized, ...common };
37
- serializeConfigValue(lines, configName, configValueSerialized);
38
- });
39
- const code = lines.join('\n');
40
- return code;
41
- }
42
- function assertConfigValueIsSerializable(value, configName, definedAtData) {
43
- // Contains asserts
44
- getConfigValueSerialized(value, configName, definedAtData);
45
- }
46
- function getConfigValueSerialized(value, configName, definedAtData) {
47
- const valueName = `config${getPropAccessNotation(configName)}`;
48
- let configValueSerialized;
49
- try {
50
- configValueSerialized = stringify(value, { valueName, forbidReactElements: true });
51
- }
52
- catch (err) {
53
- /*
54
- let serializationErrMsg = ''
55
- if (isJsonSerializerError(err)) {
56
- serializationErrMsg = err.messageCore
57
- } else {
58
- // When a property getter throws an error
59
- console.error('Serialization error:')
60
- console.error(err)
61
- serializationErrMsg = 'see serialization error printed above'
62
- }
63
- */
64
- const configValueFilePathToShowToUser = getConfigValueFilePathToShowToUser(definedAtData);
65
- assert(configValueFilePathToShowToUser);
66
- assertUsage(false, `${pc.cyan(configName)} defined by ${configValueFilePathToShowToUser} must be defined over a so-called "pointer import", see https://vike.dev/config#pointer-imports`);
67
- }
68
- configValueSerialized = JSON.stringify(configValueSerialized);
69
- return configValueSerialized;
70
- }
@@ -1,5 +0,0 @@
1
- export { getConfigValueSourcesNotOverriden };
2
- import type { ConfigValueSource, PageConfigBuildTime } from '../../../shared/page-configs/PageConfig.js';
3
- declare function getConfigValueSourcesNotOverriden(pageConfig: PageConfigBuildTime): (ConfigValueSource & {
4
- configName: string;
5
- })[];
@@ -1,11 +0,0 @@
1
- export { getConfigValueSourcesNotOverriden };
2
- import { assert, assertIsNotBrowser } from '../../shared/utils.js';
3
- assertIsNotBrowser();
4
- function getConfigValueSourcesNotOverriden(pageConfig) {
5
- const configValueSourcesRelevant = Object.entries(pageConfig.configValueSources).map(([configName, sources]) => {
6
- const configValueSource = sources[0];
7
- assert(configValueSource);
8
- return { configName, ...configValueSource };
9
- });
10
- return configValueSourcesRelevant;
11
- }
@@ -1,3 +0,0 @@
1
- export { getClientEntry };
2
- import type { PageConfigRuntime, PageConfigBuildTime } from '../../shared/page-configs/PageConfig.js';
3
- declare function getClientEntry(pageConfig: PageConfigRuntime | PageConfigBuildTime): null | string;
@@ -1,9 +0,0 @@
1
- export { getClientEntry };
2
- import { getConfigValue } from '../../shared/page-configs/getConfigValue.js';
3
- function getClientEntry(pageConfig) {
4
- const configName = 'client';
5
- const configValue = getConfigValue(pageConfig, configName, 'string');
6
- if (!configValue)
7
- return null;
8
- return configValue.value;
9
- }
@@ -1,4 +0,0 @@
1
- export { parseConfigValuesImported };
2
- import type { ConfigValues } from '../PageConfig.js';
3
- import type { ConfigValueImported } from './PageConfigSerialized.js';
4
- declare function parseConfigValuesImported(configValuesImported: ConfigValueImported[]): ConfigValues;