vike 0.4.170 → 0.4.171-commit-d60a550

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-d60a550';
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,56 @@ declare function loadUserFilesServerSide(pageContext: {
19
19
  _isHtmlOnly: boolean;
20
20
  _passToClient: string[];
21
21
  _pageFilePathsLoaded: string[];
22
+ source: {
23
+ [x: string]: {
24
+ type: "configsOverridable";
25
+ value: unknown;
26
+ definedAt: string;
27
+ } | {
28
+ type: "configsCumulative";
29
+ values: {
30
+ value: unknown;
31
+ definedAt: string;
32
+ }[];
33
+ } | {
34
+ type: "configsComputed";
35
+ value: unknown;
36
+ };
37
+ };
38
+ sources: {
39
+ [x: string]: ({
40
+ type: "configsOverridable";
41
+ value: unknown;
42
+ definedAt: string;
43
+ } | {
44
+ type: "configsCumulative";
45
+ values: {
46
+ value: unknown;
47
+ definedAt: string;
48
+ }[];
49
+ } | {
50
+ type: "configsComputed";
51
+ value: unknown;
52
+ })[];
53
+ };
54
+ from: {
55
+ configsOverridable: Record<string, {
56
+ type: "configsOverridable";
57
+ value: unknown;
58
+ definedAt: string;
59
+ }>;
60
+ configsCumulative: Record<string, {
61
+ type: "configsCumulative";
62
+ values: {
63
+ value: unknown;
64
+ definedAt: string;
65
+ }[];
66
+ }>;
67
+ configsComputed: Record<string, {
68
+ type: "configsComputed";
69
+ value: unknown;
70
+ }>;
71
+ };
22
72
  config: Record<string, unknown>;
23
73
  configEntries: import("../../../shared/getPageFiles/getExports.js").ConfigEntries;
24
74
  exports: Record<string, unknown>;
@@ -61,6 +61,56 @@ declare function prerenderPage(pageContext: PageContextInitEnhanced & PageFiles
61
61
  _isHtmlOnly: boolean;
62
62
  _passToClient: string[];
63
63
  _pageFilePathsLoaded: string[];
64
+ source: {
65
+ [x: string]: {
66
+ type: "configsOverridable";
67
+ value: unknown;
68
+ definedAt: string;
69
+ } | {
70
+ type: "configsCumulative";
71
+ values: {
72
+ value: unknown;
73
+ definedAt: string;
74
+ }[];
75
+ } | {
76
+ type: "configsComputed";
77
+ value: unknown;
78
+ };
79
+ };
80
+ sources: {
81
+ [x: string]: ({
82
+ type: "configsOverridable";
83
+ value: unknown;
84
+ definedAt: string;
85
+ } | {
86
+ type: "configsCumulative";
87
+ values: {
88
+ value: unknown;
89
+ definedAt: string;
90
+ }[];
91
+ } | {
92
+ type: "configsComputed";
93
+ value: unknown;
94
+ })[];
95
+ };
96
+ from: {
97
+ configsOverridable: Record<string, {
98
+ type: "configsOverridable";
99
+ value: unknown;
100
+ definedAt: string;
101
+ }>;
102
+ configsCumulative: Record<string, {
103
+ type: "configsCumulative";
104
+ values: {
105
+ value: unknown;
106
+ definedAt: string;
107
+ }[];
108
+ }>;
109
+ configsComputed: Record<string, {
110
+ type: "configsComputed";
111
+ value: unknown;
112
+ }>;
113
+ };
64
114
  config: Record<string, unknown>;
65
115
  configEntries: import("../../../shared/getPageFiles/getExports.js").ConfigEntries;
66
116
  exports: Record<string, unknown>;
@@ -108,6 +158,56 @@ declare function prerenderPage(pageContext: PageContextInitEnhanced & PageFiles
108
158
  _isHtmlOnly: boolean;
109
159
  _passToClient: string[];
110
160
  _pageFilePathsLoaded: string[];
161
+ source: {
162
+ [x: string]: {
163
+ type: "configsOverridable";
164
+ value: unknown;
165
+ definedAt: string;
166
+ } | {
167
+ type: "configsCumulative";
168
+ values: {
169
+ value: unknown;
170
+ definedAt: string;
171
+ }[];
172
+ } | {
173
+ type: "configsComputed";
174
+ value: unknown;
175
+ };
176
+ };
177
+ sources: {
178
+ [x: string]: ({
179
+ type: "configsOverridable";
180
+ value: unknown;
181
+ definedAt: string;
182
+ } | {
183
+ type: "configsCumulative";
184
+ values: {
185
+ value: unknown;
186
+ definedAt: string;
187
+ }[];
188
+ } | {
189
+ type: "configsComputed";
190
+ value: unknown;
191
+ })[];
192
+ };
193
+ from: {
194
+ configsOverridable: Record<string, {
195
+ type: "configsOverridable";
196
+ value: unknown;
197
+ definedAt: string;
198
+ }>;
199
+ configsCumulative: Record<string, {
200
+ type: "configsCumulative";
201
+ values: {
202
+ value: unknown;
203
+ definedAt: string;
204
+ }[];
205
+ }>;
206
+ configsComputed: Record<string, {
207
+ type: "configsComputed";
208
+ value: unknown;
209
+ }>;
210
+ };
111
211
  config: Record<string, unknown>;
112
212
  configEntries: import("../../../shared/getPageFiles/getExports.js").ConfigEntries;
113
213
  exports: Record<string, unknown>;
@@ -156,6 +256,56 @@ declare function prerender404Page(renderContext: RenderContext, pageContextInit_
156
256
  _isHtmlOnly: boolean;
157
257
  _passToClient: string[];
158
258
  _pageFilePathsLoaded: string[];
259
+ source: {
260
+ [x: string]: {
261
+ type: "configsOverridable";
262
+ value: unknown;
263
+ definedAt: string;
264
+ } | {
265
+ type: "configsCumulative";
266
+ values: {
267
+ value: unknown;
268
+ definedAt: string;
269
+ }[];
270
+ } | {
271
+ type: "configsComputed";
272
+ value: unknown;
273
+ };
274
+ };
275
+ sources: {
276
+ [x: string]: ({
277
+ type: "configsOverridable";
278
+ value: unknown;
279
+ definedAt: string;
280
+ } | {
281
+ type: "configsCumulative";
282
+ values: {
283
+ value: unknown;
284
+ definedAt: string;
285
+ }[];
286
+ } | {
287
+ type: "configsComputed";
288
+ value: unknown;
289
+ })[];
290
+ };
291
+ from: {
292
+ configsOverridable: Record<string, {
293
+ type: "configsOverridable";
294
+ value: unknown;
295
+ definedAt: string;
296
+ }>;
297
+ configsCumulative: Record<string, {
298
+ type: "configsCumulative";
299
+ values: {
300
+ value: unknown;
301
+ definedAt: string;
302
+ }[];
303
+ }>;
304
+ configsComputed: Record<string, {
305
+ type: "configsComputed";
306
+ value: unknown;
307
+ }>;
308
+ };
159
309
  config: Record<string, unknown>;
160
310
  configEntries: import("../../../shared/getPageFiles/getExports.js").ConfigEntries;
161
311
  exports: Record<string, unknown>;
@@ -203,6 +353,56 @@ declare function prerender404Page(renderContext: RenderContext, pageContextInit_
203
353
  _isHtmlOnly: boolean;
204
354
  _passToClient: string[];
205
355
  _pageFilePathsLoaded: string[];
356
+ source: {
357
+ [x: string]: {
358
+ type: "configsOverridable";
359
+ value: unknown;
360
+ definedAt: string;
361
+ } | {
362
+ type: "configsCumulative";
363
+ values: {
364
+ value: unknown;
365
+ definedAt: string;
366
+ }[];
367
+ } | {
368
+ type: "configsComputed";
369
+ value: unknown;
370
+ };
371
+ };
372
+ sources: {
373
+ [x: string]: ({
374
+ type: "configsOverridable";
375
+ value: unknown;
376
+ definedAt: string;
377
+ } | {
378
+ type: "configsCumulative";
379
+ values: {
380
+ value: unknown;
381
+ definedAt: string;
382
+ }[];
383
+ } | {
384
+ type: "configsComputed";
385
+ value: unknown;
386
+ })[];
387
+ };
388
+ from: {
389
+ configsOverridable: Record<string, {
390
+ type: "configsOverridable";
391
+ value: unknown;
392
+ definedAt: string;
393
+ }>;
394
+ configsCumulative: Record<string, {
395
+ type: "configsCumulative";
396
+ values: {
397
+ value: unknown;
398
+ definedAt: string;
399
+ }[];
400
+ }>;
401
+ configsComputed: Record<string, {
402
+ type: "configsComputed";
403
+ value: unknown;
404
+ }>;
405
+ };
206
406
  config: Record<string, unknown>;
207
407
  configEntries: import("../../../shared/getPageFiles/getExports.js").ConfigEntries;
208
408
  exports: Record<string, unknown>;
@@ -27,6 +27,9 @@ type ConfigEntries = Record<string, {
27
27
  configDefinedByFile: string | null;
28
28
  }[]>;
29
29
  type PageContextExports = {
30
+ source: Source;
31
+ sources: Sources;
32
+ from: From;
30
33
  config: Record<string, unknown>;
31
34
  configEntries: ConfigEntries;
32
35
  exports: Record<string, unknown>;
@@ -34,4 +37,34 @@ type PageContextExports = {
34
37
  /** @deprecated */
35
38
  pageExports: Record<string, unknown>;
36
39
  };
40
+ type From = {
41
+ configsOverridable: Record<string, // configName
42
+ SourceConfigsOverridable>;
43
+ configsCumulative: Record<string, // configName
44
+ SourceConfigsCumulative>;
45
+ configsComputed: Record<string, // configName
46
+ SourceConfigsComputed>;
47
+ };
48
+ type Source = Record<string, // configName
49
+ SourceAny>;
50
+ type Sources = Record<string, // configName
51
+ SourceAny[]>;
52
+ type SourceAny = SourceConfigs;
53
+ type SourceConfigs = SourceConfigsOverridable | SourceConfigsCumulative | SourceConfigsComputed;
54
+ type SourceConfigsOverridable = {
55
+ type: 'configsOverridable';
56
+ value: unknown;
57
+ definedAt: string;
58
+ };
59
+ type SourceConfigsCumulative = {
60
+ type: 'configsCumulative';
61
+ values: {
62
+ value: unknown;
63
+ definedAt: string;
64
+ }[];
65
+ };
66
+ type SourceConfigsComputed = {
67
+ type: 'configsComputed';
68
+ value: unknown;
69
+ };
37
70
  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
@@ -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-d60a550";
4
4
  declare const projectInfo: {
5
5
  projectName: "Vike";
6
- projectVersion: "0.4.170";
6
+ projectVersion: "0.4.171-commit-d60a550";
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-d60a550';
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-d60a550",
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",