vike 0.4.191 → 0.4.193-commit-38002cb
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/__internal/index.js +14 -6
- package/dist/cjs/node/plugin/plugins/autoFullBuild.js +9 -5
- package/dist/cjs/node/plugin/plugins/buildConfig.js +2 -2
- package/dist/cjs/node/plugin/plugins/config/assertVikeConfig.js +4 -2
- package/dist/cjs/node/plugin/plugins/importBuild/index.js +24 -14
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +12 -6
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js +1 -1
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigs.js +2 -2
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/isRuntimeEnvMatch.js +0 -3
- package/dist/cjs/node/plugin/plugins/setGlobalContext.js +5 -0
- package/dist/cjs/node/prerender/runPrerender.js +4 -5
- package/dist/cjs/node/runtime/globalContext/loadImportBuild.js +2 -2
- package/dist/cjs/node/runtime/globalContext.js +83 -26
- package/dist/cjs/node/runtime/html/stream.js +37 -24
- package/dist/cjs/node/runtime/page-files/getPageFilesExports.js +23 -0
- package/dist/cjs/node/runtime/page-files/setup.js +2 -20
- package/dist/cjs/node/runtime/renderPage/inferMediaType.js +3 -0
- package/dist/cjs/node/runtime/renderPage.js +3 -3
- package/dist/cjs/node/runtime/utils.js +1 -0
- package/dist/cjs/shared/hooks/getHook.js +4 -6
- package/dist/cjs/shared/page-configs/assertPlusFileExport.js +1 -2
- package/dist/cjs/shared/page-configs/serialize/serializeConfigValues.js +3 -1
- package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
- package/dist/cjs/utils/genPromise.js +9 -0
- package/dist/cjs/utils/isArray.js +1 -1
- package/dist/esm/__internal/index.d.ts +7 -0
- package/dist/esm/__internal/index.js +15 -6
- package/dist/esm/node/plugin/plugins/autoFullBuild.js +9 -5
- package/dist/esm/node/plugin/plugins/buildConfig.js +3 -3
- package/dist/esm/node/plugin/plugins/config/assertVikeConfig.js +4 -2
- package/dist/esm/node/plugin/plugins/importBuild/index.d.ts +2 -2
- package/dist/esm/node/plugin/plugins/importBuild/index.js +22 -12
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.d.ts +8 -0
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +12 -6
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigs.js +2 -2
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/isRuntimeEnvMatch.d.ts +0 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/isRuntimeEnvMatch.js +0 -3
- package/dist/esm/node/plugin/plugins/setGlobalContext.js +7 -2
- package/dist/esm/node/prerender/runPrerender.js +7 -8
- package/dist/esm/node/runtime/globalContext/loadImportBuild.js +1 -1
- package/dist/esm/node/runtime/globalContext.d.ts +12 -6
- package/dist/esm/node/runtime/globalContext.js +83 -26
- package/dist/esm/node/runtime/html/stream.js +37 -24
- package/dist/esm/node/runtime/page-files/getPageFilesExports.d.ts +2 -0
- package/dist/esm/node/runtime/page-files/getPageFilesExports.js +20 -0
- package/dist/esm/node/runtime/page-files/setup.js +1 -19
- package/dist/esm/node/runtime/renderPage/inferMediaType.d.ts +1 -1
- package/dist/esm/node/runtime/renderPage/inferMediaType.js +3 -0
- package/dist/esm/node/runtime/renderPage.js +4 -4
- package/dist/esm/node/runtime/utils.d.ts +1 -0
- package/dist/esm/node/runtime/utils.js +1 -0
- package/dist/esm/shared/ConfigVike.d.ts +3 -3
- package/dist/esm/shared/hooks/executeHook.d.ts +1 -1
- package/dist/esm/shared/hooks/getHook.d.ts +2 -2
- package/dist/esm/shared/hooks/getHook.js +3 -5
- package/dist/esm/shared/page-configs/PageConfig.d.ts +0 -2
- package/dist/esm/shared/page-configs/assertPlusFileExport.js +1 -2
- package/dist/esm/shared/page-configs/serialize/serializeConfigValues.d.ts +3 -1
- package/dist/esm/shared/page-configs/serialize/serializeConfigValues.js +3 -1
- package/dist/esm/types/index.d.ts +1 -0
- package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
- package/dist/esm/utils/PROJECT_VERSION.js +1 -1
- package/dist/esm/utils/genPromise.d.ts +4 -0
- package/dist/esm/utils/genPromise.js +5 -0
- package/dist/esm/utils/isArray.js +1 -1
- package/dist/esm/utils/projectInfo.d.ts +1 -1
- package/package.json +67 -67
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getPagesAndRoutes = exports.route = void 0;
|
|
3
|
+
exports.getPageFilesAllSafe = exports.getPagesAndRoutes = exports.route = void 0;
|
|
4
4
|
const index_js_1 = require("../shared/route/index.js");
|
|
5
|
+
const getPageFiles_js_1 = require("../shared/getPageFiles.js");
|
|
5
6
|
const globalContext_js_1 = require("../node/runtime/globalContext.js");
|
|
6
7
|
const assertNodeEnv_js_1 = require("../utils/assertNodeEnv.js");
|
|
7
|
-
const assert_js_1 = require("../utils/assert.js");
|
|
8
8
|
const renderPageAlreadyRouted_js_1 = require("../node/runtime/renderPage/renderPageAlreadyRouted.js");
|
|
9
9
|
/**
|
|
10
10
|
* Used by {@link https://github.com/magne4000/vite-plugin-vercel|vite-plugin-vercel}
|
|
@@ -14,11 +14,10 @@ const renderPageAlreadyRouted_js_1 = require("../node/runtime/renderPage/renderP
|
|
|
14
14
|
*/
|
|
15
15
|
async function getPagesAndRoutes() {
|
|
16
16
|
(0, assertNodeEnv_js_1.handleNodeEnv_vitePluginVercel)();
|
|
17
|
-
await (0, globalContext_js_1.initGlobalContext)(true);
|
|
18
|
-
const globalContext = (0, globalContext_js_1.getGlobalContext)();
|
|
19
|
-
(0, assert_js_1.assert)(globalContext.isProduction === true);
|
|
20
17
|
const renderContext = await (0, renderPageAlreadyRouted_js_1.getRenderContext)();
|
|
21
|
-
const {
|
|
18
|
+
const {
|
|
19
|
+
//
|
|
20
|
+
pageRoutes, pageFilesAll, pageConfigs, allPageIds } = renderContext;
|
|
22
21
|
return {
|
|
23
22
|
pageRoutes,
|
|
24
23
|
pageFilesAll,
|
|
@@ -27,6 +26,15 @@ async function getPagesAndRoutes() {
|
|
|
27
26
|
};
|
|
28
27
|
}
|
|
29
28
|
exports.getPagesAndRoutes = getPagesAndRoutes;
|
|
29
|
+
// TODO: make it cleaner once the internal refactoring about global configs is done.
|
|
30
|
+
// Demo usage: https://github.com/vikejs/vike/pull/1823
|
|
31
|
+
async function getPageFilesAllSafe(isProduction) {
|
|
32
|
+
await (0, globalContext_js_1.initGlobalContext_getGlobalContextAsync)(isProduction);
|
|
33
|
+
const globalContext = (0, globalContext_js_1.getGlobalContext)();
|
|
34
|
+
const pageFilesAll = await (0, getPageFiles_js_1.getPageFilesAll)(false, globalContext.isProduction);
|
|
35
|
+
return pageFilesAll;
|
|
36
|
+
}
|
|
37
|
+
exports.getPageFilesAllSafe = getPageFilesAllSafe;
|
|
30
38
|
async function route(pageContext) {
|
|
31
39
|
const pageContextFromRoute = await (0, index_js_1.route)(pageContext);
|
|
32
40
|
// Old interface
|
|
@@ -94,23 +94,27 @@ async function triggerFullBuild(config, configVike, bundle) {
|
|
|
94
94
|
(0, logErrorHint_js_1.logErrorHint)(err);
|
|
95
95
|
process.exit(1);
|
|
96
96
|
}
|
|
97
|
-
if (configVike.prerender && !configVike.prerender.disableAutoRun) {
|
|
97
|
+
if (configVike.prerender && !configVike.prerender.disableAutoRun && configVike.disableAutoFullBuild !== 'prerender') {
|
|
98
98
|
await (0, runPrerender_js_1.runPrerenderFromAutoFullBuild)({ viteConfig: configInline });
|
|
99
99
|
forceExit = true;
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
102
|
function abortViteBuildSsr(configVike) {
|
|
103
|
-
if (
|
|
103
|
+
if (configVike.disableAutoFullBuild !== true && (0, isViteCliCall_js_1.isViteCliCall)() && (0, isViteCliCall_js_1.getViteConfigFromCli)()?.build.ssr) {
|
|
104
104
|
(0, utils_js_1.assertWarning)(false, `The CLI call ${picocolors_1.default.cyan('$ vite build --ssr')} is superfluous since ${picocolors_1.default.cyan('$ vite build')} also builds the server-side. If you want two separate build steps then use https://vike.dev/disableAutoFullBuild or use Vite's ${picocolors_1.default.cyan('build()')} API.`, { onlyOnce: true });
|
|
105
105
|
process.exit(0);
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
108
|
function isDisabled(configVike) {
|
|
109
|
-
|
|
110
|
-
|
|
109
|
+
const { disableAutoFullBuild } = configVike;
|
|
110
|
+
if (disableAutoFullBuild === null || disableAutoFullBuild === 'prerender') {
|
|
111
|
+
// TODO/v1-release: remove autoFullBuild for both Vite's build() API and Vite's CLI
|
|
112
|
+
// - Tell users to use `$ vike build` instead of `$ vite build`
|
|
113
|
+
// - Remove the whole writeBundle() hook logic
|
|
114
|
+
// - make `$ vite build` only build the client-side
|
|
111
115
|
return !(0, isViteCliCall_js_1.isViteCliCall)();
|
|
112
116
|
}
|
|
113
117
|
else {
|
|
114
|
-
return
|
|
118
|
+
return disableAutoFullBuild;
|
|
115
119
|
}
|
|
116
120
|
}
|
|
@@ -74,7 +74,7 @@ function buildConfig() {
|
|
|
74
74
|
name: 'vike:buildConfig:writeBundle',
|
|
75
75
|
apply: 'build',
|
|
76
76
|
// Make sure other writeBundle() hooks are called after this writeBundle() hook.
|
|
77
|
-
// -
|
|
77
|
+
// - set_ASSETS_MAP() needs to be called before dist/server/ code is executed.
|
|
78
78
|
// - For example, the writeBundle() hook of vite-plugin-vercel needs to be called after this writeBundle() hook, otherwise: https://github.com/vikejs/vike/issues/1527
|
|
79
79
|
enforce: 'pre',
|
|
80
80
|
writeBundle: {
|
|
@@ -97,7 +97,7 @@ function buildConfig() {
|
|
|
97
97
|
}
|
|
98
98
|
await promises_1.default.rm(clientManifestFilePath);
|
|
99
99
|
await promises_1.default.rm(serverManifestFilePath);
|
|
100
|
-
await (0, index_js_1.
|
|
100
|
+
await (0, index_js_1.set_ASSETS_MAP)(options, bundle);
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
103
|
}
|
|
@@ -30,8 +30,10 @@ function checkConfigVike(configVike) {
|
|
|
30
30
|
}
|
|
31
31
|
{
|
|
32
32
|
const prop = 'disableAutoFullBuild';
|
|
33
|
-
if (!(0, utils_js_1.hasProp)(configVike, prop, 'boolean') &&
|
|
34
|
-
|
|
33
|
+
if (!(0, utils_js_1.hasProp)(configVike, prop, 'boolean') &&
|
|
34
|
+
!(0, utils_js_1.hasProp)(configVike, prop, 'undefined') &&
|
|
35
|
+
!(configVike[prop] === 'prerender'))
|
|
36
|
+
return { prop, errMsg: "should be a boolean or 'prerender'" };
|
|
35
37
|
}
|
|
36
38
|
{
|
|
37
39
|
const prop = 'includeAssetsImportedByServer';
|
|
@@ -3,8 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
7
|
-
const
|
|
6
|
+
exports.set_ASSETS_MAP = exports.importBuild = void 0;
|
|
7
|
+
const plugin_1 = require("@brillout/vite-plugin-server-entry/plugin");
|
|
8
8
|
const utils_js_1 = require("../../utils.js");
|
|
9
9
|
const path_1 = __importDefault(require("path"));
|
|
10
10
|
const module_1 = require("module");
|
|
@@ -28,7 +28,7 @@ function importBuild() {
|
|
|
28
28
|
configVike = await (0, getConfigVike_js_1.getConfigVike)(config);
|
|
29
29
|
}
|
|
30
30
|
},
|
|
31
|
-
...(0,
|
|
31
|
+
...(0, plugin_1.serverEntryPlugin)({
|
|
32
32
|
getImporterCode: () => {
|
|
33
33
|
return getEntryCode(config, configVike);
|
|
34
34
|
},
|
|
@@ -59,23 +59,33 @@ function getEntryCode(config, configVike) {
|
|
|
59
59
|
return importerCode;
|
|
60
60
|
}
|
|
61
61
|
/** Set the value of the ASSETS_MAP constant inside dist/server/entry.js (or dist/server/index.js) */
|
|
62
|
-
async function
|
|
62
|
+
async function set_ASSETS_MAP(options, bundle) {
|
|
63
63
|
const { dir } = options;
|
|
64
64
|
(0, utils_js_1.assert)(dir);
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
const serverEntry = (0, plugin_js_1.findServerEntry)(bundle);
|
|
68
|
-
const serverEntryFilePath = path_1.default.join(dir, serverEntry.fileName);
|
|
65
|
+
const chunkPath = find_ASSETS_MAP(bundle);
|
|
66
|
+
const chunkFilePath = path_1.default.join(dir, chunkPath);
|
|
69
67
|
const assetsJsonFilePath = path_1.default.join(dir, '..', 'assets.json');
|
|
70
|
-
const [assetsJsonString,
|
|
68
|
+
const [assetsJsonString, chunkFileContent] = await Promise.all([
|
|
71
69
|
await promises_1.default.readFile(assetsJsonFilePath, 'utf8'),
|
|
72
|
-
await promises_1.default.readFile(
|
|
70
|
+
await promises_1.default.readFile(chunkFilePath, 'utf8')
|
|
73
71
|
]);
|
|
74
|
-
const serverEntryFileContentPatched =
|
|
75
|
-
(0, utils_js_1.assert)(serverEntryFileContentPatched !==
|
|
76
|
-
await promises_1.default.writeFile(
|
|
72
|
+
const serverEntryFileContentPatched = chunkFileContent.replace(ASSETS_MAP, assetsJsonString);
|
|
73
|
+
(0, utils_js_1.assert)(serverEntryFileContentPatched !== chunkFileContent);
|
|
74
|
+
await promises_1.default.writeFile(chunkFilePath, serverEntryFileContentPatched);
|
|
75
|
+
}
|
|
76
|
+
exports.set_ASSETS_MAP = set_ASSETS_MAP;
|
|
77
|
+
function find_ASSETS_MAP(bundle) {
|
|
78
|
+
let chunkPath;
|
|
79
|
+
for (const filePath in bundle) {
|
|
80
|
+
const chunk = bundle[filePath];
|
|
81
|
+
if ('code' in chunk && chunk.code.includes(ASSETS_MAP)) {
|
|
82
|
+
(0, utils_js_1.assert)(!chunkPath);
|
|
83
|
+
chunkPath = filePath;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
(0, utils_js_1.assert)(chunkPath);
|
|
87
|
+
return chunkPath;
|
|
77
88
|
}
|
|
78
|
-
exports.set_constant_ASSETS_MAP = set_constant_ASSETS_MAP;
|
|
79
89
|
function getImportPath(config) {
|
|
80
90
|
// We resolve filePathAbsolute even if we don't use it: we use require.resolve() as an assertion that the relative path is correct
|
|
81
91
|
const filePathAbsolute = (0, utils_js_1.toPosixPath)(
|
|
@@ -33,7 +33,8 @@ const configDefinitionsBuiltIn = {
|
|
|
33
33
|
cumulative: true
|
|
34
34
|
},
|
|
35
35
|
route: {
|
|
36
|
-
env: { server: true, client: 'if-client-routing'
|
|
36
|
+
env: { server: true, client: 'if-client-routing' },
|
|
37
|
+
eager: true
|
|
37
38
|
},
|
|
38
39
|
guard: {
|
|
39
40
|
env: { server: true, client: 'if-client-routing' }
|
|
@@ -42,7 +43,8 @@ const configDefinitionsBuiltIn = {
|
|
|
42
43
|
env: { server: true }
|
|
43
44
|
},
|
|
44
45
|
iKnowThePerformanceRisksOfAsyncRouteFunctions: {
|
|
45
|
-
env: { server: true, client: 'if-client-routing'
|
|
46
|
+
env: { server: true, client: 'if-client-routing' },
|
|
47
|
+
eager: true
|
|
46
48
|
},
|
|
47
49
|
filesystemRoutingRoot: {
|
|
48
50
|
env: { config: true }
|
|
@@ -54,7 +56,8 @@ const configDefinitionsBuiltIn = {
|
|
|
54
56
|
},
|
|
55
57
|
clientRouting: {
|
|
56
58
|
// We could make it { client: false } but we don't yet because of some legacy V0.4 design code
|
|
57
|
-
env: { server: true, client: true, config: true
|
|
59
|
+
env: { server: true, client: true, config: true },
|
|
60
|
+
eager: true
|
|
58
61
|
},
|
|
59
62
|
clientHooks: {
|
|
60
63
|
env: { config: true }
|
|
@@ -75,7 +78,8 @@ const configDefinitionsBuiltIn = {
|
|
|
75
78
|
env: { config: true }
|
|
76
79
|
},
|
|
77
80
|
clientEntryLoaded: {
|
|
78
|
-
env: { server: true, client: true
|
|
81
|
+
env: { server: true, client: true },
|
|
82
|
+
eager: true,
|
|
79
83
|
_computed: (configValueSources) => {
|
|
80
84
|
{
|
|
81
85
|
const source = getConfigValueSource(configValueSources, 'clientHooks');
|
|
@@ -118,10 +122,12 @@ const configDefinitionsBuiltIn = {
|
|
|
118
122
|
exports.configDefinitionsBuiltIn = configDefinitionsBuiltIn;
|
|
119
123
|
const configDefinitionsBuiltInGlobal = {
|
|
120
124
|
onPrerenderStart: {
|
|
121
|
-
env: { server: true, production: true
|
|
125
|
+
env: { server: true, production: true },
|
|
126
|
+
eager: true
|
|
122
127
|
},
|
|
123
128
|
onBeforeRoute: {
|
|
124
|
-
env: { server: true, client: 'if-client-routing'
|
|
129
|
+
env: { server: true, client: 'if-client-routing' },
|
|
130
|
+
eager: true
|
|
125
131
|
},
|
|
126
132
|
prerender: {
|
|
127
133
|
env: { config: true }
|
package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js
CHANGED
|
@@ -35,7 +35,7 @@ function getLoadConfigValuesAll(pageConfig, isForClientSide, pageId, includeAsse
|
|
|
35
35
|
const importStatements = [];
|
|
36
36
|
const isClientRouting = (0, getConfigValueBuildTime_js_1.getConfigValueBuildTime)(pageConfig, 'clientRouting', 'boolean')?.value ?? false;
|
|
37
37
|
lines.push('export const configValuesSerialized = {');
|
|
38
|
-
lines.push(...(0, serializeConfigValues_js_1.serializeConfigValues)(pageConfig, importStatements, (configEnv) => (0, isRuntimeEnvMatch_js_1.isRuntimeEnvMatch)(configEnv, { isForClientSide, isClientRouting, isEager: false
|
|
38
|
+
lines.push(...(0, serializeConfigValues_js_1.serializeConfigValues)(pageConfig, importStatements, (configEnv) => (0, isRuntimeEnvMatch_js_1.isRuntimeEnvMatch)(configEnv, { isForClientSide, isClientRouting, isDev }), { isEager: false }, ''));
|
|
39
39
|
lines.push('};');
|
|
40
40
|
if (!(0, fixServerAssets_js_1.fixServerAssets_isEnabled)() && includeAssetsImportedByServer && isForClientSide && !isDev) {
|
|
41
41
|
importStatements.push(`import '${(0, extractAssetsQuery_js_1.extractAssetsAddQuery)((0, virtualFilePageConfigValuesAll_js_1.getVirtualFileIdPageConfigValuesAll)(pageId, false))}'`);
|
|
@@ -35,7 +35,7 @@ function getCodePageConfigsSerialized(pageConfigs, isForClientSide, isClientRout
|
|
|
35
35
|
lines.push(` routeFilesystem: ${JSON.stringify(routeFilesystem)},`);
|
|
36
36
|
lines.push(` loadConfigValuesAll: () => import(${JSON.stringify(virtualFileIdPageConfigValuesAll)}),`);
|
|
37
37
|
lines.push(` configValuesSerialized: {`);
|
|
38
|
-
lines.push(...(0, serializeConfigValues_js_1.serializeConfigValues)(pageConfig, importStatements, (configEnv) => (0, isRuntimeEnvMatch_js_1.isRuntimeEnvMatch)(configEnv, { isForClientSide, isClientRouting, isEager: true
|
|
38
|
+
lines.push(...(0, serializeConfigValues_js_1.serializeConfigValues)(pageConfig, importStatements, (configEnv) => (0, isRuntimeEnvMatch_js_1.isRuntimeEnvMatch)(configEnv, { isForClientSide, isClientRouting, isDev }), { isEager: true }, ' '));
|
|
39
39
|
lines.push(` },`);
|
|
40
40
|
lines.push(` },`);
|
|
41
41
|
});
|
|
@@ -45,7 +45,7 @@ function getCodePageConfigsSerialized(pageConfigs, isForClientSide, isClientRout
|
|
|
45
45
|
function getCodePageConfigGlobalSerialized(pageConfigGlobal, isForClientSide, isClientRouting, isDev, importStatements) {
|
|
46
46
|
const lines = [];
|
|
47
47
|
lines.push(` configValuesSerialized: {`);
|
|
48
|
-
lines.push(...(0, serializeConfigValues_js_1.serializeConfigValues)(pageConfigGlobal, importStatements, (configEnv) => (0, isRuntimeEnvMatch_js_1.isRuntimeEnvMatch)(configEnv, { isForClientSide, isClientRouting, isEager: true
|
|
48
|
+
lines.push(...(0, serializeConfigValues_js_1.serializeConfigValues)(pageConfigGlobal, importStatements, (configEnv) => (0, isRuntimeEnvMatch_js_1.isRuntimeEnvMatch)(configEnv, { isForClientSide, isClientRouting, isDev }), { isEager: true }, ' '));
|
|
49
49
|
lines.push(` },`);
|
|
50
50
|
const code = lines.join('\n');
|
|
51
51
|
return code;
|
|
@@ -13,9 +13,6 @@ function isRuntimeEnvMatch(configEnv, runtime) {
|
|
|
13
13
|
if (configEnv.client === 'if-client-routing' && !runtime.isClientRouting)
|
|
14
14
|
return false;
|
|
15
15
|
}
|
|
16
|
-
// Eager
|
|
17
|
-
if (runtime.isEager !== !!configEnv.eager)
|
|
18
|
-
return false;
|
|
19
16
|
// Production/development
|
|
20
17
|
if (
|
|
21
18
|
//
|
|
@@ -18,6 +18,11 @@ function setGlobalContext() {
|
|
|
18
18
|
const isDev = (0, utils_js_1.isDev3)(env);
|
|
19
19
|
(0, globalContext_js_1.setGlobalContext_isDev)(isDev);
|
|
20
20
|
}
|
|
21
|
+
},
|
|
22
|
+
configResolved(config) {
|
|
23
|
+
const { outDirRoot } = (0, utils_js_1.getOutDirs)(config);
|
|
24
|
+
(0, utils_js_1.assertFilePathAbsoluteFilesystem)(outDirRoot); // Needed for loadImportBuild(outDir) of @brillout/vite-plugin-server-entry
|
|
25
|
+
(0, globalContext_js_1.setGlobalContext_viteConfig)(config, outDirRoot);
|
|
21
26
|
}
|
|
22
27
|
};
|
|
23
28
|
}
|
|
@@ -83,7 +83,8 @@ async function runPrerenderFromAutoFullBuild(options) {
|
|
|
83
83
|
exports.runPrerenderFromAutoFullBuild = runPrerenderFromAutoFullBuild;
|
|
84
84
|
async function runPrerender(options, manuallyTriggered) {
|
|
85
85
|
checkOutdatedOptions(options);
|
|
86
|
-
(0,
|
|
86
|
+
(0, globalContext_js_1.setGlobalContext_isPrerendering)();
|
|
87
|
+
(0, getHook_js_1.getHook_setIsPrerenderering)();
|
|
87
88
|
const logLevel = !!options.onPagePrerender ? 'warn' : 'info';
|
|
88
89
|
if (logLevel === 'info') {
|
|
89
90
|
console.log(`${picocolors_1.default.cyan(`vike v${utils_js_1.projectInfo.projectVersion}`)} ${picocolors_1.default.green('pre-rendering HTML...')}`);
|
|
@@ -91,10 +92,9 @@ async function runPrerender(options, manuallyTriggered) {
|
|
|
91
92
|
(0, utils_js_1.handleNodeEnv_prerender)();
|
|
92
93
|
await disableReactStreaming();
|
|
93
94
|
const viteConfig = await (0, vite_1.resolveConfig)(options.viteConfig || {}, 'vike pre-rendering', 'production');
|
|
94
|
-
(0, globalContext_js_1.setGlobalContext_prerender)(viteConfig);
|
|
95
95
|
assertLoadedConfig(viteConfig, options);
|
|
96
96
|
const configVike = await (0, getConfigVike_js_1.getConfigVike)(viteConfig);
|
|
97
|
-
const { outDirClient
|
|
97
|
+
const { outDirClient } = (0, utils_js_1.getOutDirs)(viteConfig);
|
|
98
98
|
const { root } = viteConfig;
|
|
99
99
|
const prerenderConfig = configVike.prerender;
|
|
100
100
|
if (!prerenderConfig) {
|
|
@@ -105,8 +105,7 @@ async function runPrerender(options, manuallyTriggered) {
|
|
|
105
105
|
}
|
|
106
106
|
const { partial = false, noExtraDir = false, parallel = true } = prerenderConfig || {};
|
|
107
107
|
const concurrencyLimit = (0, utils_js_1.pLimit)(parallel === false || parallel === 0 ? 1 : parallel === true || parallel === undefined ? (0, os_1.cpus)().length : parallel);
|
|
108
|
-
(0,
|
|
109
|
-
await (0, globalContext_js_1.initGlobalContext)(true, outDirRoot);
|
|
108
|
+
await (0, globalContext_js_1.initGlobalContext_runPrerender)();
|
|
110
109
|
const renderContext = await (0, renderPageAlreadyRouted_js_1.getRenderContext)();
|
|
111
110
|
renderContext.pageFilesAll.forEach(assertExportNames);
|
|
112
111
|
const prerenderContext = {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.setImportBuildGetters = exports.loadImportBuild = void 0;
|
|
4
|
-
const
|
|
4
|
+
const runtime_1 = require("@brillout/vite-plugin-server-entry/runtime");
|
|
5
5
|
const utils_js_1 = require("../utils.js");
|
|
6
6
|
const buildGetters = (globalThis.__vike_buildGetters = globalThis.__vike_buildGetters || {
|
|
7
7
|
getters: null
|
|
@@ -12,7 +12,7 @@ function setImportBuildGetters(getters) {
|
|
|
12
12
|
exports.setImportBuildGetters = setImportBuildGetters;
|
|
13
13
|
async function loadImportBuild(outDir) {
|
|
14
14
|
if (!buildGetters.getters) {
|
|
15
|
-
await (0,
|
|
15
|
+
await (0, runtime_1.importServerEntry)(outDir);
|
|
16
16
|
(0, utils_js_1.assert)(buildGetters.getters);
|
|
17
17
|
}
|
|
18
18
|
const [pageFiles, assetsManifest, pluginManifest] = await Promise.all([
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.setGlobalContext_isPrerendering = exports.setGlobalContext_isDev = exports.setGlobalContext_viteConfig = exports.setGlobalContext_viteDevServer = exports.initGlobalContext_getGlobalContextAsync = exports.initGlobalContext_runPrerender = exports.initGlobalContext_renderPage = exports.getRuntimeManifest = exports.getViteConfig = exports.getViteDevServer = exports.getGlobalContext = exports.getGlobalContextAsync = exports.getGlobalContextSync = void 0;
|
|
7
7
|
const utils_js_1 = require("./utils.js");
|
|
8
8
|
const loadImportBuild_js_1 = require("./globalContext/loadImportBuild.js");
|
|
9
9
|
const getPageFiles_js_1 = require("../../shared/getPageFiles.js");
|
|
@@ -11,10 +11,14 @@ const assertPluginManifest_js_1 = require("../shared/assertPluginManifest.js");
|
|
|
11
11
|
const getConfigVike_js_1 = require("../shared/getConfigVike.js");
|
|
12
12
|
const assertRuntimeManifest_js_1 = require("../shared/assertRuntimeManifest.js");
|
|
13
13
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
14
|
-
|
|
15
|
-
const globalObject = (0, utils_js_1.getGlobalObject)('globalContext.ts', {
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
const getPageFilesExports_js_1 = require("./page-files/getPageFilesExports.js");
|
|
15
|
+
const globalObject = (0, utils_js_1.getGlobalObject)('globalContext.ts', (() => {
|
|
16
|
+
const { promise: viteDevServerPromise, resolve: viteDevServerPromiseResolve } = (0, utils_js_1.genPromise)();
|
|
17
|
+
return {
|
|
18
|
+
viteDevServerPromise,
|
|
19
|
+
viteDevServerPromiseResolve
|
|
20
|
+
};
|
|
21
|
+
})());
|
|
18
22
|
function getGlobalContext() {
|
|
19
23
|
(0, utils_js_1.assert)(globalObject.globalContext);
|
|
20
24
|
return globalObject.globalContext;
|
|
@@ -27,10 +31,12 @@ function getGlobalContextSync() {
|
|
|
27
31
|
}
|
|
28
32
|
exports.getGlobalContextSync = getGlobalContextSync;
|
|
29
33
|
/** @experimental https://vike.dev/getGlobalContext */
|
|
30
|
-
async function getGlobalContextAsync() {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
+
async function getGlobalContextAsync(isProduction) {
|
|
35
|
+
(0, utils_js_1.assertUsage)(typeof isProduction === 'boolean', `[getGlobalContextAsync(isProduction)] Argument ${picocolors_1.default.cyan('isProduction')} ${isProduction === undefined ? 'is missing' : `should be ${picocolors_1.default.cyan('true')} or ${picocolors_1.default.cyan('false')}`}`);
|
|
36
|
+
await initGlobalContext_getGlobalContextAsync(isProduction);
|
|
37
|
+
const { globalContext } = globalObject;
|
|
38
|
+
(0, utils_js_1.assert)(globalContext);
|
|
39
|
+
return makePublic(globalContext);
|
|
34
40
|
}
|
|
35
41
|
exports.getGlobalContextAsync = getGlobalContextAsync;
|
|
36
42
|
function makePublic(globalContext) {
|
|
@@ -60,39 +66,87 @@ function makePublic(globalContext) {
|
|
|
60
66
|
function setGlobalContext_viteDevServer(viteDevServer) {
|
|
61
67
|
if (globalObject.viteDevServer)
|
|
62
68
|
return;
|
|
63
|
-
(
|
|
64
|
-
globalObject.viteConfig
|
|
69
|
+
assertIsNotInitilizedYet();
|
|
70
|
+
(0, utils_js_1.assert)(globalObject.viteConfig);
|
|
65
71
|
globalObject.viteDevServer = viteDevServer;
|
|
72
|
+
globalObject.viteDevServerPromiseResolve(viteDevServer);
|
|
73
|
+
eagerlyLoadUserFiles();
|
|
66
74
|
}
|
|
67
75
|
exports.setGlobalContext_viteDevServer = setGlobalContext_viteDevServer;
|
|
76
|
+
function setGlobalContext_viteConfig(viteConfig, outDirRoot) {
|
|
77
|
+
if (globalObject.viteConfig)
|
|
78
|
+
return;
|
|
79
|
+
assertIsNotInitilizedYet();
|
|
80
|
+
globalObject.viteConfig = viteConfig;
|
|
81
|
+
globalObject.outDirRoot = outDirRoot;
|
|
82
|
+
}
|
|
83
|
+
exports.setGlobalContext_viteConfig = setGlobalContext_viteConfig;
|
|
84
|
+
function assertIsNotInitilizedYet() {
|
|
85
|
+
// In develpoment, globalObject.viteDevServer always needs to be awaited for before initializing globalObject.globalContext
|
|
86
|
+
(0, utils_js_1.assert)(!globalObject.globalContext);
|
|
87
|
+
}
|
|
68
88
|
function setGlobalContext_isDev(isDev) {
|
|
69
89
|
globalObject.isDev = isDev;
|
|
70
90
|
}
|
|
71
91
|
exports.setGlobalContext_isDev = setGlobalContext_isDev;
|
|
92
|
+
function setGlobalContext_isPrerendering() {
|
|
93
|
+
globalObject.isPrerendering = true;
|
|
94
|
+
}
|
|
95
|
+
exports.setGlobalContext_isPrerendering = setGlobalContext_isPrerendering;
|
|
72
96
|
function getViteDevServer() {
|
|
73
97
|
return globalObject.viteDevServer ?? null;
|
|
74
98
|
}
|
|
75
99
|
exports.getViteDevServer = getViteDevServer;
|
|
76
|
-
function setGlobalContext_prerender(viteConfig) {
|
|
77
|
-
if (globalObject.viteConfig)
|
|
78
|
-
return;
|
|
79
|
-
(0, utils_js_1.assert)(!globalObject.globalContext);
|
|
80
|
-
globalObject.viteConfig = viteConfig;
|
|
81
|
-
}
|
|
82
|
-
exports.setGlobalContext_prerender = setGlobalContext_prerender;
|
|
83
100
|
function getViteConfig() {
|
|
84
101
|
return globalObject.viteConfig ?? null;
|
|
85
102
|
}
|
|
86
103
|
exports.getViteConfig = getViteConfig;
|
|
87
|
-
async function
|
|
88
|
-
|
|
104
|
+
async function initGlobalContext_renderPage() {
|
|
105
|
+
await initGlobalContext(!globalObject.isDev);
|
|
106
|
+
}
|
|
107
|
+
exports.initGlobalContext_renderPage = initGlobalContext_renderPage;
|
|
108
|
+
async function initGlobalContext_runPrerender() {
|
|
109
|
+
if (globalObject.initGlobalContext_runPrerender_alreadyCalled)
|
|
89
110
|
return;
|
|
90
|
-
|
|
111
|
+
globalObject.initGlobalContext_runPrerender_alreadyCalled = true;
|
|
112
|
+
(0, utils_js_1.assert)(globalObject.isPrerendering);
|
|
113
|
+
(0, utils_js_1.assert)(globalObject.viteConfig);
|
|
114
|
+
(0, utils_js_1.assert)(globalObject.outDirRoot);
|
|
115
|
+
// We assume initGlobalContext_runPrerender() to be called before:
|
|
116
|
+
// - initGlobalContext_renderPage()
|
|
117
|
+
// - initGlobalContext_getGlobalContextAsync()
|
|
118
|
+
(0, utils_js_1.assert)(!globalObject.globalContext);
|
|
119
|
+
await initGlobalContext(true);
|
|
120
|
+
}
|
|
121
|
+
exports.initGlobalContext_runPrerender = initGlobalContext_runPrerender;
|
|
122
|
+
async function initGlobalContext_getGlobalContextAsync(isProduction) {
|
|
123
|
+
if (!isProduction) {
|
|
124
|
+
const waitFor = 20;
|
|
125
|
+
const timeout = setTimeout(() => {
|
|
126
|
+
(0, utils_js_1.assertWarning)(false, `Vite's development server still not created after ${waitFor} seconds.`, {
|
|
127
|
+
onlyOnce: false,
|
|
128
|
+
showStackTrace: true
|
|
129
|
+
});
|
|
130
|
+
}, waitFor * 1000);
|
|
131
|
+
await globalObject.viteDevServerPromise;
|
|
132
|
+
clearTimeout(timeout);
|
|
133
|
+
}
|
|
134
|
+
await initGlobalContext(isProduction);
|
|
135
|
+
}
|
|
136
|
+
exports.initGlobalContext_getGlobalContextAsync = initGlobalContext_getGlobalContextAsync;
|
|
137
|
+
async function initGlobalContext(isProduction) {
|
|
138
|
+
if (globalObject.globalContext) {
|
|
139
|
+
(0, utils_js_1.assert)(globalObject.globalContext.isProduction === isProduction);
|
|
140
|
+
// We assume setGlobalContext_isPrerendering() is called before initGlobalContext()
|
|
141
|
+
(0, utils_js_1.assert)(globalObject.globalContext.isPrerendering === (globalObject.isPrerendering ?? false));
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
const { viteDevServer, viteConfig, isDev, isPrerendering } = globalObject;
|
|
91
145
|
(0, utils_js_1.assertNodeEnv_runtime)(isDev ?? false);
|
|
92
|
-
if (
|
|
146
|
+
if (!isProduction) {
|
|
93
147
|
(0, utils_js_1.assert)(viteConfig);
|
|
94
|
-
(0, utils_js_1.assert)(!isPrerendering);
|
|
95
148
|
(0, utils_js_1.assert)(viteDevServer);
|
|
149
|
+
(0, utils_js_1.assert)(!isPrerendering);
|
|
96
150
|
const configVike = await (0, getConfigVike_js_1.getConfigVike)(viteConfig);
|
|
97
151
|
const pluginManifest = getRuntimeManifest(configVike);
|
|
98
152
|
globalObject.globalContext = {
|
|
@@ -111,7 +165,7 @@ async function initGlobalContext(isPrerendering = false, outDir) {
|
|
|
111
165
|
};
|
|
112
166
|
}
|
|
113
167
|
else {
|
|
114
|
-
const buildEntries = await (0, loadImportBuild_js_1.loadImportBuild)(
|
|
168
|
+
const buildEntries = await (0, loadImportBuild_js_1.loadImportBuild)(globalObject.outDirRoot);
|
|
115
169
|
assertBuildEntries(buildEntries, isPrerendering ?? false);
|
|
116
170
|
const { pageFiles, assetsManifest, pluginManifest } = buildEntries;
|
|
117
171
|
(0, getPageFiles_js_1.setPageFiles)(pageFiles);
|
|
@@ -147,9 +201,7 @@ async function initGlobalContext(isPrerendering = false, outDir) {
|
|
|
147
201
|
globalObject.globalContext = globalContext;
|
|
148
202
|
}
|
|
149
203
|
}
|
|
150
|
-
resolveGlobalContext(globalObject.globalContext);
|
|
151
204
|
}
|
|
152
|
-
exports.initGlobalContext = initGlobalContext;
|
|
153
205
|
function getRuntimeManifest(configVike) {
|
|
154
206
|
const { includeAssetsImportedByServer, baseServer, baseAssets, redirects, trailingSlash, disableUrlNormalization } = configVike;
|
|
155
207
|
const manifest = {
|
|
@@ -186,3 +238,8 @@ function assertViteManifest(manifest) {
|
|
|
186
238
|
})
|
|
187
239
|
*/
|
|
188
240
|
}
|
|
241
|
+
function eagerlyLoadUserFiles() {
|
|
242
|
+
// Other than here, the getPageFilesExports() function is only called only upon calling the renderPage() function.
|
|
243
|
+
// We call it as early as possible here for better performance.
|
|
244
|
+
(0, getPageFilesExports_js_1.getPageFilesExports)();
|
|
245
|
+
}
|
|
@@ -44,16 +44,15 @@ async function streamReadableNodeToString(readableNode) {
|
|
|
44
44
|
}
|
|
45
45
|
async function streamReadableWebToString(readableWeb) {
|
|
46
46
|
const reader = readableWeb.getReader();
|
|
47
|
-
const
|
|
47
|
+
const { decode, getClosingChunk } = decodeChunks();
|
|
48
48
|
let str = '';
|
|
49
49
|
while (true) {
|
|
50
50
|
const { done, value } = await reader.read();
|
|
51
51
|
if (done)
|
|
52
52
|
break;
|
|
53
|
-
str +=
|
|
53
|
+
str += decode(value);
|
|
54
54
|
}
|
|
55
|
-
|
|
56
|
-
str += decoder.decode();
|
|
55
|
+
str += getClosingChunk();
|
|
57
56
|
return str;
|
|
58
57
|
}
|
|
59
58
|
exports.streamReadableWebToString = streamReadableWebToString;
|
|
@@ -119,15 +118,16 @@ async function streamPipeNodeToString(streamPipeNode) {
|
|
|
119
118
|
}
|
|
120
119
|
exports.streamPipeNodeToString = streamPipeNodeToString;
|
|
121
120
|
function streamPipeWebToString(streamPipeWeb) {
|
|
121
|
+
const { decode, getClosingChunk } = decodeChunks();
|
|
122
122
|
let str = '';
|
|
123
123
|
let resolve;
|
|
124
124
|
const promise = new Promise((r) => (resolve = r));
|
|
125
125
|
const writable = new WritableStream({
|
|
126
126
|
write(chunk) {
|
|
127
|
-
|
|
128
|
-
str += chunk;
|
|
127
|
+
str += decode(chunk);
|
|
129
128
|
},
|
|
130
129
|
close() {
|
|
130
|
+
str += getClosingChunk();
|
|
131
131
|
resolve(str);
|
|
132
132
|
}
|
|
133
133
|
});
|
|
@@ -384,9 +384,7 @@ async function createStreamWrapper({ streamOriginal, onError, onData, onEnd, onF
|
|
|
384
384
|
const writeChunk = (chunk) => {
|
|
385
385
|
(0, utils_js_1.assert)(writableOriginal);
|
|
386
386
|
writableOriginal.write(chunk);
|
|
387
|
-
|
|
388
|
-
debug('data written (Node.js Writable)', getChunkAsString(chunk));
|
|
389
|
-
}
|
|
387
|
+
debugWithChunk('data written (Node.js Writable)', chunk);
|
|
390
388
|
};
|
|
391
389
|
// For libraries such as https://www.npmjs.com/package/compression
|
|
392
390
|
// - React calls writable.flush() when available
|
|
@@ -457,9 +455,7 @@ async function createStreamWrapper({ streamOriginal, onError, onData, onEnd, onF
|
|
|
457
455
|
const writeChunk = (chunk) => {
|
|
458
456
|
(0, utils_js_1.assert)(writerOriginal);
|
|
459
457
|
writerOriginal.write(encodeForWebStream(chunk));
|
|
460
|
-
|
|
461
|
-
debug('data written (Web Writable)', getChunkAsString(chunk));
|
|
462
|
-
}
|
|
458
|
+
debugWithChunk('data written (Web Writable)', chunk);
|
|
463
459
|
};
|
|
464
460
|
// Web Streams have compression built-in
|
|
465
461
|
// - https://developer.mozilla.org/en-US/docs/Web/API/Compression_Streams_API
|
|
@@ -550,14 +546,10 @@ async function createStreamWrapper({ streamOriginal, onError, onData, onEnd, onF
|
|
|
550
546
|
// If readableOriginal doesn't implement readableOriginal.cancel() then it may still emit data after we close the stream. We therefore need to check whether we closed `controllerProxy`.
|
|
551
547
|
!controllerProxyIsClosed) {
|
|
552
548
|
controllerProxy.enqueue(encodeForWebStream(chunk));
|
|
553
|
-
|
|
554
|
-
debug('data written (Web Readable)', getChunkAsString(chunk));
|
|
555
|
-
}
|
|
549
|
+
debugWithChunk('data written (Web Readable)', chunk);
|
|
556
550
|
}
|
|
557
551
|
else {
|
|
558
|
-
|
|
559
|
-
debug('data emitted but not written (Web Readable)', getChunkAsString(chunk));
|
|
560
|
-
}
|
|
552
|
+
debugWithChunk('data emitted but not written (Web Readable)', chunk);
|
|
561
553
|
}
|
|
562
554
|
};
|
|
563
555
|
// Readables don't have the notion of flushing
|
|
@@ -577,9 +569,7 @@ async function createStreamWrapper({ streamOriginal, onError, onData, onEnd, onF
|
|
|
577
569
|
}
|
|
578
570
|
const writeChunk = (chunk) => {
|
|
579
571
|
readableProxy.push(chunk);
|
|
580
|
-
|
|
581
|
-
debug('data written (Node.js Readable)', getChunkAsString(chunk));
|
|
582
|
-
}
|
|
572
|
+
debugWithChunk('data written (Node.js Readable)', chunk);
|
|
583
573
|
};
|
|
584
574
|
// Readables don't have the notion of flushing
|
|
585
575
|
const flushStream = null;
|
|
@@ -802,11 +792,34 @@ function inferStreamName(stream) {
|
|
|
802
792
|
(0, utils_js_1.assert)(false);
|
|
803
793
|
}
|
|
804
794
|
exports.inferStreamName = inferStreamName;
|
|
805
|
-
function
|
|
795
|
+
function decodeChunks() {
|
|
796
|
+
const decoder = new TextDecoder();
|
|
797
|
+
const decode = (chunk) => {
|
|
798
|
+
if (typeof chunk === 'string') {
|
|
799
|
+
return chunk;
|
|
800
|
+
}
|
|
801
|
+
else if (chunk instanceof Uint8Array) {
|
|
802
|
+
return decoder.decode(chunk, { stream: true });
|
|
803
|
+
}
|
|
804
|
+
else {
|
|
805
|
+
(0, utils_js_1.assert)(false);
|
|
806
|
+
}
|
|
807
|
+
};
|
|
808
|
+
// https://github.com/vikejs/vike/pull/1799#discussion_r1713554096
|
|
809
|
+
const getClosingChunk = () => {
|
|
810
|
+
return decoder.decode();
|
|
811
|
+
};
|
|
812
|
+
return { decode, getClosingChunk };
|
|
813
|
+
}
|
|
814
|
+
function debugWithChunk(msg, chunk) {
|
|
815
|
+
if (!debug.isActivated)
|
|
816
|
+
return;
|
|
817
|
+
let chunkStr;
|
|
806
818
|
try {
|
|
807
|
-
|
|
819
|
+
chunkStr = new TextDecoder().decode(chunk);
|
|
808
820
|
}
|
|
809
821
|
catch (err) {
|
|
810
|
-
|
|
822
|
+
chunkStr = String(chunk);
|
|
811
823
|
}
|
|
824
|
+
debug(msg, chunkStr);
|
|
812
825
|
}
|