vike 0.4.207 → 0.4.208-commit-8d0a7ba

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.
@@ -81,37 +81,35 @@ function processHookReturnValue(hookReturnValue, renderHook) {
81
81
  let pageContextPromise = null;
82
82
  let pageContextProvidedByRenderHook = null;
83
83
  let injectFilter = null;
84
- const ret = () => ({ documentHtml, pageContextProvidedByRenderHook, pageContextPromise, injectFilter });
85
- if (hookReturnValue === null)
86
- return ret();
87
84
  if ((0, renderHtml_js_1.isDocumentHtml)(hookReturnValue)) {
88
85
  documentHtml = hookReturnValue;
89
- return ret();
86
+ return { documentHtml, pageContextProvidedByRenderHook, pageContextPromise, injectFilter };
90
87
  }
91
88
  const errPrefix = `The ${renderHook.hookName}() hook defined at ${renderHook.hookFilePath}`;
92
- const errSuffix = `a string generated with the ${picocolors_1.default.cyan('escapeInject`<html>...</html>`')} template tag or a string returned by ${picocolors_1.default.cyan('dangerouslySkipEscape()')}, see https://vike.dev/escapeInject`;
89
+ const errSuffix = `a string generated with ${picocolors_1.default.cyan('escapeInject`<html>...</html>`')} or the value returned by ${picocolors_1.default.cyan('dangerouslySkipEscape()')}, see https://vike.dev/escapeInject`;
93
90
  if (typeof hookReturnValue === 'string') {
94
- (0, utils_js_1.assertWarning)(false, [errPrefix, 'returned a plain JavaScript string which is dangerous: it should instead return', errSuffix].join(' '), { onlyOnce: true });
91
+ (0, utils_js_1.assertWarning)(false, [
92
+ errPrefix,
93
+ `returned a plain JavaScript string which is ${picocolors_1.default.red(picocolors_1.default.bold('dangerous'))}: it should instead return`,
94
+ errSuffix
95
+ ].join(' '), { onlyOnce: true });
95
96
  hookReturnValue = (0, renderHtml_js_1.dangerouslySkipEscape)(hookReturnValue);
96
97
  }
97
- (0, utils_js_1.assertUsage)((0, utils_js_1.isObject)(hookReturnValue), [
98
- errPrefix,
99
- `should return ${picocolors_1.default.cyan('null')}, the value ${picocolors_1.default.cyan('documentHtml')}, or an object ${picocolors_1.default.cyan('{ documentHtml, pageContext }')} where ${picocolors_1.default.cyan('pageContext')} is ${picocolors_1.default.cyan('undefined')} or an object holding additional pageContext values, and where ${picocolors_1.default.cyan('documentHtml')} is`,
100
- errSuffix
101
- ].join(' '));
98
+ const wrongReturnValue = `should return the value ${picocolors_1.default.cyan('documentHtml')} or an object ${picocolors_1.default.cyan('{ documentHtml }')} where ${picocolors_1.default.cyan('documentHtml')} is ${errSuffix}`;
99
+ (0, utils_js_1.assertUsage)((0, utils_js_1.isObject)(hookReturnValue), `${errPrefix} ${wrongReturnValue}`);
102
100
  (0, assertHookReturnedObject_js_1.assertHookReturnedObject)(hookReturnValue, ['documentHtml', 'pageContext', 'injectFilter'], errPrefix);
101
+ (0, utils_js_1.assertUsage)(hookReturnValue.documentHtml, `${errPrefix} returned an object that is missing the ${picocolors_1.default.code('documentHtml')} property: it ${wrongReturnValue}`);
103
102
  if (hookReturnValue.injectFilter) {
104
103
  (0, utils_js_1.assertUsage)((0, utils_js_1.isCallable)(hookReturnValue.injectFilter), 'injectFilter should be a function');
105
104
  injectFilter = hookReturnValue.injectFilter;
106
105
  }
107
- (0, utils_js_1.assertUsage)(hookReturnValue.documentHtml, `${errPrefix} returned an object that is missing the ${picocolors_1.default.code('documentHtml')} property.`);
108
106
  {
109
107
  let val = hookReturnValue.documentHtml;
110
108
  const errBegin = `${errPrefix} returned ${picocolors_1.default.cyan('{ documentHtml }')}, but ${picocolors_1.default.cyan('documentHtml')}`;
111
109
  if (typeof val === 'string') {
112
110
  (0, utils_js_1.assertWarning)(false, [
113
111
  errBegin,
114
- `is a plain JavaScript string which is dangerous: ${picocolors_1.default.cyan('documentHtml')} should be`,
112
+ `is a plain JavaScript string which is ${picocolors_1.default.bold(picocolors_1.default.red('dangerous'))}: ${picocolors_1.default.cyan('documentHtml')} should be`,
115
113
  errSuffix
116
114
  ].join(' '), { onlyOnce: true });
117
115
  val = (0, renderHtml_js_1.dangerouslySkipEscape)(val);
@@ -132,5 +130,5 @@ function processHookReturnValue(hookReturnValue, renderHook) {
132
130
  pageContextProvidedByRenderHook = val;
133
131
  }
134
132
  }
135
- return ret();
133
+ return { documentHtml, pageContextProvidedByRenderHook, pageContextPromise, injectFilter };
136
134
  }
@@ -6,34 +6,35 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.assertPlusFileExport = assertPlusFileExport;
7
7
  const utils_js_1 = require("../utils.js");
8
8
  const picocolors_1 = __importDefault(require("@brillout/picocolors"));
9
- const EXPORTS_IGNORE = [
9
+ const SIDE_EXPORTS_TOLERATE = [
10
10
  // vite-plugin-solid adds `export { $$registrations }`
11
11
  '$$registrations',
12
12
  // @vitejs/plugin-vue adds `export { _rerender_only }`
13
13
  '_rerender_only'
14
14
  ];
15
15
  // Tolerate `export { frontmatter }` in .mdx files
16
- const TOLERATE_SIDE_EXPORTS = ['.md', '.mdx'];
16
+ const SIDE_EXPORTS_DO_NOT_CHECK = ['.md', '.mdx'];
17
17
  function assertPlusFileExport(fileExports, filePathToShowToUser, configName) {
18
- const exportNames = Object.keys(fileExports).filter((exportName) => !EXPORTS_IGNORE.includes(exportName));
18
+ const exportNames = Object.keys(fileExports);
19
19
  const isValid = (exportName) => exportName === 'default' || exportName === configName;
20
+ // Error upon missing/ambiguous export
20
21
  const exportNamesValid = exportNames.filter(isValid);
21
- const exportNamesInvalid = exportNames.filter((e) => !isValid(e));
22
- if (exportNamesValid.length === 1 && exportNamesInvalid.length === 0) {
23
- return;
24
- }
25
22
  const exportDefault = picocolors_1.default.code('export default');
26
23
  const exportNamed = picocolors_1.default.code(`export { ${configName} }`);
27
- (0, utils_js_1.assert)(exportNamesValid.length <= 2);
28
24
  if (exportNamesValid.length === 0) {
29
25
  (0, utils_js_1.assertUsage)(false, `${filePathToShowToUser} should have ${exportNamed} or ${exportDefault}`);
30
26
  }
31
27
  if (exportNamesValid.length === 2) {
32
28
  (0, utils_js_1.assertUsage)(false, `${filePathToShowToUser} is ambiguous: remove ${exportDefault} or ${exportNamed}`);
33
29
  }
34
- if (!TOLERATE_SIDE_EXPORTS.some((ext) => filePathToShowToUser.endsWith(ext))) {
30
+ (0, utils_js_1.assert)(exportNamesValid.length === 1);
31
+ // Warn upon side exports
32
+ const exportNamesInvalid = exportNames
33
+ .filter((e) => !isValid(e))
34
+ .filter((exportName) => !SIDE_EXPORTS_TOLERATE.includes(exportName));
35
+ if (!SIDE_EXPORTS_DO_NOT_CHECK.some((ext) => filePathToShowToUser.endsWith(ext))) {
35
36
  exportNamesInvalid.forEach((exportInvalid) => {
36
- (0, utils_js_1.assertWarning)(false, `${filePathToShowToUser} unexpected ${picocolors_1.default.cyan(`export { ${exportInvalid} }`)}`, {
37
+ (0, utils_js_1.assertWarning)(false, `${filePathToShowToUser} unexpected ${picocolors_1.default.cyan(`export { ${exportInvalid} }`)}, see https://vike.dev/no-side-exports`, {
37
38
  onlyOnce: true
38
39
  });
39
40
  });
@@ -2,4 +2,4 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PROJECT_VERSION = void 0;
4
4
  // Automatically updated by @brillout/release-me
5
- exports.PROJECT_VERSION = '0.4.207';
5
+ exports.PROJECT_VERSION = '0.4.208-commit-8d0a7ba';
@@ -48,7 +48,7 @@ function assert(condition, debugInfo) {
48
48
  })();
49
49
  const link = picocolors_1.default.blue('https://github.com/vikejs/vike/issues/new');
50
50
  let errMsg = [
51
- `You stumbled upon a Vike bug. Go to ${link} and copy-paste this error. A maintainer will fix the bug (usually under 24 hours).`,
51
+ `You stumbled upon a Vike bug. Go to ${link} and copy-paste this error. A maintainer will fix the bug (usually within 24 hours).`,
52
52
  debugStr
53
53
  ]
54
54
  .filter(Boolean)
@@ -76,37 +76,35 @@ function processHookReturnValue(hookReturnValue, renderHook) {
76
76
  let pageContextPromise = null;
77
77
  let pageContextProvidedByRenderHook = null;
78
78
  let injectFilter = null;
79
- const ret = () => ({ documentHtml, pageContextProvidedByRenderHook, pageContextPromise, injectFilter });
80
- if (hookReturnValue === null)
81
- return ret();
82
79
  if (isDocumentHtml(hookReturnValue)) {
83
80
  documentHtml = hookReturnValue;
84
- return ret();
81
+ return { documentHtml, pageContextProvidedByRenderHook, pageContextPromise, injectFilter };
85
82
  }
86
83
  const errPrefix = `The ${renderHook.hookName}() hook defined at ${renderHook.hookFilePath}`;
87
- const errSuffix = `a string generated with the ${pc.cyan('escapeInject`<html>...</html>`')} template tag or a string returned by ${pc.cyan('dangerouslySkipEscape()')}, see https://vike.dev/escapeInject`;
84
+ const errSuffix = `a string generated with ${pc.cyan('escapeInject`<html>...</html>`')} or the value returned by ${pc.cyan('dangerouslySkipEscape()')}, see https://vike.dev/escapeInject`;
88
85
  if (typeof hookReturnValue === 'string') {
89
- assertWarning(false, [errPrefix, 'returned a plain JavaScript string which is dangerous: it should instead return', errSuffix].join(' '), { onlyOnce: true });
86
+ assertWarning(false, [
87
+ errPrefix,
88
+ `returned a plain JavaScript string which is ${pc.red(pc.bold('dangerous'))}: it should instead return`,
89
+ errSuffix
90
+ ].join(' '), { onlyOnce: true });
90
91
  hookReturnValue = dangerouslySkipEscape(hookReturnValue);
91
92
  }
92
- assertUsage(isObject(hookReturnValue), [
93
- errPrefix,
94
- `should return ${pc.cyan('null')}, the value ${pc.cyan('documentHtml')}, or an object ${pc.cyan('{ documentHtml, pageContext }')} where ${pc.cyan('pageContext')} is ${pc.cyan('undefined')} or an object holding additional pageContext values, and where ${pc.cyan('documentHtml')} is`,
95
- errSuffix
96
- ].join(' '));
93
+ const wrongReturnValue = `should return the value ${pc.cyan('documentHtml')} or an object ${pc.cyan('{ documentHtml }')} where ${pc.cyan('documentHtml')} is ${errSuffix}`;
94
+ assertUsage(isObject(hookReturnValue), `${errPrefix} ${wrongReturnValue}`);
97
95
  assertHookReturnedObject(hookReturnValue, ['documentHtml', 'pageContext', 'injectFilter'], errPrefix);
96
+ assertUsage(hookReturnValue.documentHtml, `${errPrefix} returned an object that is missing the ${pc.code('documentHtml')} property: it ${wrongReturnValue}`);
98
97
  if (hookReturnValue.injectFilter) {
99
98
  assertUsage(isCallable(hookReturnValue.injectFilter), 'injectFilter should be a function');
100
99
  injectFilter = hookReturnValue.injectFilter;
101
100
  }
102
- assertUsage(hookReturnValue.documentHtml, `${errPrefix} returned an object that is missing the ${pc.code('documentHtml')} property.`);
103
101
  {
104
102
  let val = hookReturnValue.documentHtml;
105
103
  const errBegin = `${errPrefix} returned ${pc.cyan('{ documentHtml }')}, but ${pc.cyan('documentHtml')}`;
106
104
  if (typeof val === 'string') {
107
105
  assertWarning(false, [
108
106
  errBegin,
109
- `is a plain JavaScript string which is dangerous: ${pc.cyan('documentHtml')} should be`,
107
+ `is a plain JavaScript string which is ${pc.bold(pc.red('dangerous'))}: ${pc.cyan('documentHtml')} should be`,
110
108
  errSuffix
111
109
  ].join(' '), { onlyOnce: true });
112
110
  val = dangerouslySkipEscape(val);
@@ -127,5 +125,5 @@ function processHookReturnValue(hookReturnValue, renderHook) {
127
125
  pageContextProvidedByRenderHook = val;
128
126
  }
129
127
  }
130
- return ret();
128
+ return { documentHtml, pageContextProvidedByRenderHook, pageContextPromise, injectFilter };
131
129
  }
@@ -1,34 +1,35 @@
1
1
  export { assertPlusFileExport };
2
2
  import { assert, assertUsage, assertWarning } from '../utils.js';
3
3
  import pc from '@brillout/picocolors';
4
- const EXPORTS_IGNORE = [
4
+ const SIDE_EXPORTS_TOLERATE = [
5
5
  // vite-plugin-solid adds `export { $$registrations }`
6
6
  '$$registrations',
7
7
  // @vitejs/plugin-vue adds `export { _rerender_only }`
8
8
  '_rerender_only'
9
9
  ];
10
10
  // Tolerate `export { frontmatter }` in .mdx files
11
- const TOLERATE_SIDE_EXPORTS = ['.md', '.mdx'];
11
+ const SIDE_EXPORTS_DO_NOT_CHECK = ['.md', '.mdx'];
12
12
  function assertPlusFileExport(fileExports, filePathToShowToUser, configName) {
13
- const exportNames = Object.keys(fileExports).filter((exportName) => !EXPORTS_IGNORE.includes(exportName));
13
+ const exportNames = Object.keys(fileExports);
14
14
  const isValid = (exportName) => exportName === 'default' || exportName === configName;
15
+ // Error upon missing/ambiguous export
15
16
  const exportNamesValid = exportNames.filter(isValid);
16
- const exportNamesInvalid = exportNames.filter((e) => !isValid(e));
17
- if (exportNamesValid.length === 1 && exportNamesInvalid.length === 0) {
18
- return;
19
- }
20
17
  const exportDefault = pc.code('export default');
21
18
  const exportNamed = pc.code(`export { ${configName} }`);
22
- assert(exportNamesValid.length <= 2);
23
19
  if (exportNamesValid.length === 0) {
24
20
  assertUsage(false, `${filePathToShowToUser} should have ${exportNamed} or ${exportDefault}`);
25
21
  }
26
22
  if (exportNamesValid.length === 2) {
27
23
  assertUsage(false, `${filePathToShowToUser} is ambiguous: remove ${exportDefault} or ${exportNamed}`);
28
24
  }
29
- if (!TOLERATE_SIDE_EXPORTS.some((ext) => filePathToShowToUser.endsWith(ext))) {
25
+ assert(exportNamesValid.length === 1);
26
+ // Warn upon side exports
27
+ const exportNamesInvalid = exportNames
28
+ .filter((e) => !isValid(e))
29
+ .filter((exportName) => !SIDE_EXPORTS_TOLERATE.includes(exportName));
30
+ if (!SIDE_EXPORTS_DO_NOT_CHECK.some((ext) => filePathToShowToUser.endsWith(ext))) {
30
31
  exportNamesInvalid.forEach((exportInvalid) => {
31
- assertWarning(false, `${filePathToShowToUser} unexpected ${pc.cyan(`export { ${exportInvalid} }`)}`, {
32
+ assertWarning(false, `${filePathToShowToUser} unexpected ${pc.cyan(`export { ${exportInvalid} }`)}, see https://vike.dev/no-side-exports`, {
32
33
  onlyOnce: true
33
34
  });
34
35
  });
@@ -1 +1 @@
1
- export declare const PROJECT_VERSION: "0.4.207";
1
+ export declare const PROJECT_VERSION: "0.4.208-commit-8d0a7ba";
@@ -1,2 +1,2 @@
1
1
  // Automatically updated by @brillout/release-me
2
- export const PROJECT_VERSION = '0.4.207';
2
+ export const PROJECT_VERSION = '0.4.208-commit-8d0a7ba';
@@ -43,7 +43,7 @@ function assert(condition, debugInfo) {
43
43
  })();
44
44
  const link = pc.blue('https://github.com/vikejs/vike/issues/new');
45
45
  let errMsg = [
46
- `You stumbled upon a Vike bug. Go to ${link} and copy-paste this error. A maintainer will fix the bug (usually under 24 hours).`,
46
+ `You stumbled upon a Vike bug. Go to ${link} and copy-paste this error. A maintainer will fix the bug (usually within 24 hours).`,
47
47
  debugStr
48
48
  ]
49
49
  .filter(Boolean)
@@ -1,4 +1,4 @@
1
1
  export declare const projectInfo: {
2
2
  projectName: "Vike";
3
- projectVersion: "0.4.207";
3
+ projectVersion: "0.4.208-commit-8d0a7ba";
4
4
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vike",
3
- "version": "0.4.207",
3
+ "version": "0.4.208-commit-8d0a7ba",
4
4
  "repository": "https://github.com/vikejs/vike",
5
5
  "exports": {
6
6
  "./server": {
@@ -122,10 +122,10 @@
122
122
  },
123
123
  "dependencies": {
124
124
  "@brillout/import": "^0.2.3",
125
- "@brillout/json-serializer": "^0.5.13",
125
+ "@brillout/json-serializer": "^0.5.15",
126
126
  "@brillout/picocolors": "^1.0.15",
127
127
  "@brillout/require-shim": "^0.1.2",
128
- "@brillout/vite-plugin-server-entry": "^0.5.0",
128
+ "@brillout/vite-plugin-server-entry": "^0.5.5",
129
129
  "acorn": "^8.0.0",
130
130
  "cac": "^6.0.0",
131
131
  "es-module-lexer": "^1.0.0",