vike 0.4.170 → 0.4.171-commit-4e9d13c

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.
@@ -271,7 +271,6 @@ async function loadVikeConfig(userRootDir, outDirRoot, isDev) {
271
271
  if (isGlobalConfig(configName))
272
272
  return;
273
273
  const configDef = getConfigDefinition(configDefinitions, configName, interfaceFile.filePath.filePathToShowToUser);
274
- configDef.env = deriveConfigEnvFromFileName(configDef.env, interfaceFile.filePath.fileName);
275
274
  if (!isConfigEnv(configDef, configName))
276
275
  return;
277
276
  const isAlreadyLoaded = interfacefileIsAlreaydLoaded(interfaceFile);
@@ -502,7 +501,7 @@ function isInterfaceFileUserLand(interfaceFile) {
502
501
  async function getConfigValueSource(configName, interfaceFile, configDef, userRootDir, importedFilesLoaded) {
503
502
  const conf = interfaceFile.fileExportsByConfigName[configName];
504
503
  (0, utils_js_1.assert)(conf);
505
- const configEnv = configDef.env;
504
+ const configEnv = deriveConfigEnvFromFileName(configDef.env, interfaceFile.filePath.fileName);
506
505
  const { locationId } = interfaceFile;
507
506
  const definedAtFilePath_ = {
508
507
  ...interfaceFile.filePath,
@@ -939,6 +938,7 @@ function mergeCumulative(configName, configValueSources) {
939
938
  function getConfigEnvValue(val, errMsgIntro) {
940
939
  const errInvalidValue = `${errMsgIntro} an invalid value ${picocolors_1.default.cyan(JSON.stringify(val))}`;
941
940
  // Legacy outdated values
941
+ // TODO/v1-release: remove
942
942
  if (typeof val === 'string') {
943
943
  const valConverted = (() => {
944
944
  if (val === 'client-only')
@@ -32,6 +32,18 @@ function getPageContextExports(pageFiles, pageConfig) {
32
32
  });
33
33
  });
34
34
  // V1 design
35
+ const source = {};
36
+ const sources = {};
37
+ const addSrc = (src, configName) => {
38
+ source[configName] = src;
39
+ sources[configName] ?? (sources[configName] = []);
40
+ sources[configName].push(src);
41
+ };
42
+ const from = {
43
+ configsOverridable: {},
44
+ configsCumulative: {},
45
+ configsComputed: {}
46
+ };
35
47
  if (pageConfig) {
36
48
  Object.entries(pageConfig.configValues).forEach(([configName, configValue]) => {
37
49
  const { value } = configValue;
@@ -46,6 +58,39 @@ function getPageContextExports(pageFiles, pageConfig) {
46
58
  configDefinedAt,
47
59
  configDefinedByFile: configValueFilePathToShowToUser
48
60
  });
61
+ if (configValue.type === 'cumulative') {
62
+ const src = {
63
+ type: 'configsCumulative',
64
+ values: configValue.value.map((value, i) => {
65
+ const definedAtFile = configValue.definedAtData[i];
66
+ (0, utils_js_1.assert)(definedAtFile);
67
+ const definedAt = (0, getConfigDefinedAt_js_1.getDefinedAtString)(definedAtFile, configName);
68
+ return {
69
+ value,
70
+ definedAt
71
+ };
72
+ })
73
+ };
74
+ addSrc(src, configName);
75
+ from.configsCumulative[configName] = src;
76
+ }
77
+ if (configValue.type === 'classic') {
78
+ const src = {
79
+ type: 'configsOverridable',
80
+ value: configValue.value,
81
+ definedAt: (0, getConfigDefinedAt_js_1.getDefinedAtString)(configValue.definedAtData, configName)
82
+ };
83
+ addSrc(src, configName);
84
+ from.configsOverridable[configName] = src;
85
+ }
86
+ if (configValue.type === 'computed') {
87
+ const src = {
88
+ type: 'configsComputed',
89
+ value: configValue.value
90
+ };
91
+ addSrc(src, configName);
92
+ from.configsComputed[configName] = src;
93
+ }
49
94
  // TODO/v1-release: remove
50
95
  const exportName = configName;
51
96
  exportsAll[exportName] = exportsAll[exportName] ?? [];
@@ -75,9 +120,12 @@ function getPageContextExports(pageFiles, pageConfig) {
75
120
  (0, utils_js_1.assert)(!('default' in exports));
76
121
  (0, utils_js_1.assert)(!('default' in exportsAll));
77
122
  const pageContextExports = {
123
+ from,
124
+ source,
125
+ sources,
126
+ // TODO/eventually: deprecate/remove every prop below
78
127
  config,
79
128
  configEntries,
80
- // TODO/v1-release: remove
81
129
  exports,
82
130
  exportsAll,
83
131
  pageExports
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PROJECT_VERSION = exports.projectInfo = void 0;
4
- const PROJECT_VERSION = '0.4.170';
4
+ const PROJECT_VERSION = '0.4.171-commit-4e9d13c';
5
5
  exports.PROJECT_VERSION = PROJECT_VERSION;
6
6
  const projectInfo = {
7
7
  projectName: 'Vike',
@@ -266,7 +266,6 @@ async function loadVikeConfig(userRootDir, outDirRoot, isDev) {
266
266
  if (isGlobalConfig(configName))
267
267
  return;
268
268
  const configDef = getConfigDefinition(configDefinitions, configName, interfaceFile.filePath.filePathToShowToUser);
269
- configDef.env = deriveConfigEnvFromFileName(configDef.env, interfaceFile.filePath.fileName);
270
269
  if (!isConfigEnv(configDef, configName))
271
270
  return;
272
271
  const isAlreadyLoaded = interfacefileIsAlreaydLoaded(interfaceFile);
@@ -497,7 +496,7 @@ function isInterfaceFileUserLand(interfaceFile) {
497
496
  async function getConfigValueSource(configName, interfaceFile, configDef, userRootDir, importedFilesLoaded) {
498
497
  const conf = interfaceFile.fileExportsByConfigName[configName];
499
498
  assert(conf);
500
- const configEnv = configDef.env;
499
+ const configEnv = deriveConfigEnvFromFileName(configDef.env, interfaceFile.filePath.fileName);
501
500
  const { locationId } = interfaceFile;
502
501
  const definedAtFilePath_ = {
503
502
  ...interfaceFile.filePath,
@@ -933,6 +932,7 @@ function mergeCumulative(configName, configValueSources) {
933
932
  function getConfigEnvValue(val, errMsgIntro) {
934
933
  const errInvalidValue = `${errMsgIntro} an invalid value ${pc.cyan(JSON.stringify(val))}`;
935
934
  // Legacy outdated values
935
+ // TODO/v1-release: remove
936
936
  if (typeof val === 'string') {
937
937
  const valConverted = (() => {
938
938
  if (val === 'client-only')
@@ -19,6 +19,9 @@ declare function loadUserFilesServerSide(pageContext: {
19
19
  _isHtmlOnly: boolean;
20
20
  _passToClient: string[];
21
21
  _pageFilePathsLoaded: string[];
22
+ source: import("../../../shared/getPageFiles/getExports.js").Source;
23
+ sources: import("../../../shared/getPageFiles/getExports.js").Sources;
24
+ from: import("../../../shared/getPageFiles/getExports.js").From;
22
25
  config: Record<string, unknown>;
23
26
  configEntries: import("../../../shared/getPageFiles/getExports.js").ConfigEntries;
24
27
  exports: Record<string, unknown>;
@@ -61,6 +61,9 @@ declare function prerenderPage(pageContext: PageContextInitEnhanced & PageFiles
61
61
  _isHtmlOnly: boolean;
62
62
  _passToClient: string[];
63
63
  _pageFilePathsLoaded: string[];
64
+ source: import("../../../shared/getPageFiles/getExports.js").Source;
65
+ sources: import("../../../shared/getPageFiles/getExports.js").Sources;
66
+ from: import("../../../shared/getPageFiles/getExports.js").From;
64
67
  config: Record<string, unknown>;
65
68
  configEntries: import("../../../shared/getPageFiles/getExports.js").ConfigEntries;
66
69
  exports: Record<string, unknown>;
@@ -108,6 +111,9 @@ declare function prerenderPage(pageContext: PageContextInitEnhanced & PageFiles
108
111
  _isHtmlOnly: boolean;
109
112
  _passToClient: string[];
110
113
  _pageFilePathsLoaded: string[];
114
+ source: import("../../../shared/getPageFiles/getExports.js").Source;
115
+ sources: import("../../../shared/getPageFiles/getExports.js").Sources;
116
+ from: import("../../../shared/getPageFiles/getExports.js").From;
111
117
  config: Record<string, unknown>;
112
118
  configEntries: import("../../../shared/getPageFiles/getExports.js").ConfigEntries;
113
119
  exports: Record<string, unknown>;
@@ -156,6 +162,9 @@ declare function prerender404Page(renderContext: RenderContext, pageContextInit_
156
162
  _isHtmlOnly: boolean;
157
163
  _passToClient: string[];
158
164
  _pageFilePathsLoaded: string[];
165
+ source: import("../../../shared/getPageFiles/getExports.js").Source;
166
+ sources: import("../../../shared/getPageFiles/getExports.js").Sources;
167
+ from: import("../../../shared/getPageFiles/getExports.js").From;
159
168
  config: Record<string, unknown>;
160
169
  configEntries: import("../../../shared/getPageFiles/getExports.js").ConfigEntries;
161
170
  exports: Record<string, unknown>;
@@ -203,6 +212,9 @@ declare function prerender404Page(renderContext: RenderContext, pageContextInit_
203
212
  _isHtmlOnly: boolean;
204
213
  _passToClient: string[];
205
214
  _pageFilePathsLoaded: string[];
215
+ source: import("../../../shared/getPageFiles/getExports.js").Source;
216
+ sources: import("../../../shared/getPageFiles/getExports.js").Sources;
217
+ from: import("../../../shared/getPageFiles/getExports.js").From;
206
218
  config: Record<string, unknown>;
207
219
  configEntries: import("../../../shared/getPageFiles/getExports.js").ConfigEntries;
208
220
  exports: Record<string, unknown>;
@@ -2,6 +2,9 @@ export { getPageContextExports };
2
2
  export type { ExportsAll };
3
3
  export type { PageContextExports };
4
4
  export type { ConfigEntries };
5
+ export type { From };
6
+ export type { Sources };
7
+ export type { Source };
5
8
  import type { FileType } from './fileTypes.js';
6
9
  import type { PageConfigRuntimeLoaded } from './../page-configs/PageConfig.js';
7
10
  import type { PageFile } from './getPageFileObject.js';
@@ -27,6 +30,9 @@ type ConfigEntries = Record<string, {
27
30
  configDefinedByFile: string | null;
28
31
  }[]>;
29
32
  type PageContextExports = {
33
+ source: Source;
34
+ sources: Sources;
35
+ from: From;
30
36
  config: Record<string, unknown>;
31
37
  configEntries: ConfigEntries;
32
38
  exports: Record<string, unknown>;
@@ -34,4 +40,34 @@ type PageContextExports = {
34
40
  /** @deprecated */
35
41
  pageExports: Record<string, unknown>;
36
42
  };
43
+ type From = {
44
+ configsOverridable: Record<string, // configName
45
+ SourceConfigsOverridable>;
46
+ configsCumulative: Record<string, // configName
47
+ SourceConfigsCumulative>;
48
+ configsComputed: Record<string, // configName
49
+ SourceConfigsComputed>;
50
+ };
51
+ type Source = Record<string, // configName
52
+ SourceAny>;
53
+ type Sources = Record<string, // configName
54
+ SourceAny[]>;
55
+ type SourceAny = SourceConfigs;
56
+ type SourceConfigs = SourceConfigsOverridable | SourceConfigsCumulative | SourceConfigsComputed;
57
+ type SourceConfigsOverridable = {
58
+ type: 'configsOverridable';
59
+ value: unknown;
60
+ definedAt: string;
61
+ };
62
+ type SourceConfigsCumulative = {
63
+ type: 'configsCumulative';
64
+ values: {
65
+ value: unknown;
66
+ definedAt: string;
67
+ }[];
68
+ };
69
+ type SourceConfigsComputed = {
70
+ type: 'configsComputed';
71
+ value: unknown;
72
+ };
37
73
  declare function getPageContextExports(pageFiles: PageFile[], pageConfig: PageConfigRuntimeLoaded | null): PageContextExports;
@@ -2,7 +2,7 @@ export { getPageContextExports };
2
2
  import { isScriptFile, isTemplateFile } from '../../utils/isScriptFile.js';
3
3
  import { assert, isObject, assertWarning, assertUsage, makeLast, isBrowser } from '../utils.js';
4
4
  import { assertDefaultExports, forbiddenDefaultExports } from './assert_exports_old_design.js';
5
- import { getConfigDefinedAtOptional } from '../page-configs/getConfigDefinedAt.js';
5
+ import { getConfigDefinedAtOptional, getDefinedAtString } from '../page-configs/getConfigDefinedAt.js';
6
6
  import { getConfigValueFilePathToShowToUser } from '../page-configs/helpers.js';
7
7
  import pc from '@brillout/picocolors';
8
8
  function getPageContextExports(pageFiles, pageConfig) {
@@ -27,6 +27,18 @@ function getPageContextExports(pageFiles, pageConfig) {
27
27
  });
28
28
  });
29
29
  // V1 design
30
+ const source = {};
31
+ const sources = {};
32
+ const addSrc = (src, configName) => {
33
+ source[configName] = src;
34
+ sources[configName] ?? (sources[configName] = []);
35
+ sources[configName].push(src);
36
+ };
37
+ const from = {
38
+ configsOverridable: {},
39
+ configsCumulative: {},
40
+ configsComputed: {}
41
+ };
30
42
  if (pageConfig) {
31
43
  Object.entries(pageConfig.configValues).forEach(([configName, configValue]) => {
32
44
  const { value } = configValue;
@@ -41,6 +53,39 @@ function getPageContextExports(pageFiles, pageConfig) {
41
53
  configDefinedAt,
42
54
  configDefinedByFile: configValueFilePathToShowToUser
43
55
  });
56
+ if (configValue.type === 'cumulative') {
57
+ const src = {
58
+ type: 'configsCumulative',
59
+ values: configValue.value.map((value, i) => {
60
+ const definedAtFile = configValue.definedAtData[i];
61
+ assert(definedAtFile);
62
+ const definedAt = getDefinedAtString(definedAtFile, configName);
63
+ return {
64
+ value,
65
+ definedAt
66
+ };
67
+ })
68
+ };
69
+ addSrc(src, configName);
70
+ from.configsCumulative[configName] = src;
71
+ }
72
+ if (configValue.type === 'classic') {
73
+ const src = {
74
+ type: 'configsOverridable',
75
+ value: configValue.value,
76
+ definedAt: getDefinedAtString(configValue.definedAtData, configName)
77
+ };
78
+ addSrc(src, configName);
79
+ from.configsOverridable[configName] = src;
80
+ }
81
+ if (configValue.type === 'computed') {
82
+ const src = {
83
+ type: 'configsComputed',
84
+ value: configValue.value
85
+ };
86
+ addSrc(src, configName);
87
+ from.configsComputed[configName] = src;
88
+ }
44
89
  // TODO/v1-release: remove
45
90
  const exportName = configName;
46
91
  exportsAll[exportName] = exportsAll[exportName] ?? [];
@@ -70,9 +115,12 @@ function getPageContextExports(pageFiles, pageConfig) {
70
115
  assert(!('default' in exports));
71
116
  assert(!('default' in exportsAll));
72
117
  const pageContextExports = {
118
+ from,
119
+ source,
120
+ sources,
121
+ // TODO/eventually: deprecate/remove every prop below
73
122
  config,
74
123
  configEntries,
75
- // TODO/v1-release: remove
76
124
  exports,
77
125
  exportsAll,
78
126
  pageExports
@@ -8,7 +8,7 @@ export { PageContextBuiltInServer_deprecated as PageContextBuiltInServer };
8
8
  export { PageContextBuiltInClientWithClientRouting_deprecated as PageContextBuiltInClientWithClientRouting };
9
9
  export { PageContextBuiltInClientWithServerRouting_deprecated as PageContextBuiltInClientWithServerRouting };
10
10
  import type { PageContextUrlComputedPropsInternal, PageContextUrlComputedPropsClient, PageContextUrlComputedPropsServer } from './addUrlComputedProps.js';
11
- import type { ConfigEntries, ExportsAll } from './getPageFiles/getExports.js';
11
+ import type { ConfigEntries, ExportsAll, From, Source, Sources } from './getPageFiles/getExports.js';
12
12
  import type { Config } from './page-configs/Config.js';
13
13
  import type { PageContextConfig } from './page-configs/Config/PageContextConfig.js';
14
14
  import type { AbortStatusCode } from './route/abort.js';
@@ -88,6 +88,12 @@ type PageContextBuiltInCommon<Data> = {
88
88
  * https://vike.dev/errors
89
89
  */
90
90
  errorWhileRendering?: unknown;
91
+ /** @experimental https://github.com/vikejs/vike/issues/1268 */
92
+ from: From;
93
+ /** @experimental https://github.com/vikejs/vike/issues/1268 */
94
+ source: Source;
95
+ /** @experimental https://github.com/vikejs/vike/issues/1268 */
96
+ sources: Sources;
91
97
  /** @deprecated */
92
98
  url: string;
93
99
  /** @deprecated */
@@ -1,7 +1,7 @@
1
1
  export { projectInfo };
2
2
  export { PROJECT_VERSION };
3
- declare const PROJECT_VERSION: "0.4.170";
3
+ declare const PROJECT_VERSION: "0.4.171-commit-4e9d13c";
4
4
  declare const projectInfo: {
5
5
  projectName: "Vike";
6
- projectVersion: "0.4.170";
6
+ projectVersion: "0.4.171-commit-4e9d13c";
7
7
  };
@@ -1,6 +1,6 @@
1
1
  export { projectInfo };
2
2
  export { PROJECT_VERSION };
3
- const PROJECT_VERSION = '0.4.170';
3
+ const PROJECT_VERSION = '0.4.171-commit-4e9d13c';
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.170",
3
+ "version": "0.4.171-commit-4e9d13c",
4
4
  "scripts": {
5
5
  "dev": "tsc --watch",
6
6
  "build": "rimraf dist/ && pnpm run build:esm && pnpm run build:cjs",
@@ -195,7 +195,7 @@
195
195
  "fast-glob": "^3.3.2",
196
196
  "sirv": "^2.0.4",
197
197
  "source-map-support": "^0.5.21",
198
- "@brillout/release-me": "^0.2.2",
198
+ "@brillout/release-me": "^0.3.4",
199
199
  "@types/estree": "^1.0.5",
200
200
  "@types/jest": "^29.5.11",
201
201
  "@types/node": "^20.10.5",