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.
- package/dist/cjs/node/runtime/renderPage/executeOnRenderHtmlHook.js +12 -14
- package/dist/cjs/shared/page-configs/assertPlusFileExport.js +11 -10
- package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
- package/dist/cjs/utils/assert.js +1 -1
- package/dist/esm/node/runtime/renderPage/executeOnRenderHtmlHook.js +12 -14
- package/dist/esm/shared/page-configs/assertPlusFileExport.js +11 -10
- package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
- package/dist/esm/utils/PROJECT_VERSION.js +1 -1
- package/dist/esm/utils/assert.js +1 -1
- package/dist/esm/utils/projectInfo.d.ts +1 -1
- package/package.json +3 -3
|
@@ -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
|
|
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
|
|
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, [
|
|
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
|
-
(
|
|
98
|
-
|
|
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
|
|
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
|
|
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
|
|
16
|
+
const SIDE_EXPORTS_DO_NOT_CHECK = ['.md', '.mdx'];
|
|
17
17
|
function assertPlusFileExport(fileExports, filePathToShowToUser, configName) {
|
|
18
|
-
const exportNames = Object.keys(fileExports)
|
|
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
|
-
|
|
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
|
});
|
package/dist/cjs/utils/assert.js
CHANGED
|
@@ -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
|
|
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
|
|
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
|
|
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, [
|
|
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
|
-
|
|
93
|
-
|
|
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
|
|
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
|
|
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
|
|
11
|
+
const SIDE_EXPORTS_DO_NOT_CHECK = ['.md', '.mdx'];
|
|
12
12
|
function assertPlusFileExport(fileExports, filePathToShowToUser, configName) {
|
|
13
|
-
const exportNames = Object.keys(fileExports)
|
|
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
|
-
|
|
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.
|
|
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.
|
|
2
|
+
export const PROJECT_VERSION = '0.4.208-commit-8d0a7ba';
|
package/dist/esm/utils/assert.js
CHANGED
|
@@ -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
|
|
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)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vike",
|
|
3
|
-
"version": "0.4.
|
|
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.
|
|
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.
|
|
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",
|