vike 0.4.228-commit-c2f6e1f → 0.4.228-commit-8d90991
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 +2 -2
- package/dist/cjs/client/client-routing-runtime/globalContext.js +49 -0
- package/dist/cjs/client/server-routing-runtime/globalContext.js +41 -0
- package/dist/cjs/client/shared/createGetGlobalContext.js +31 -0
- package/dist/cjs/client/shared/getJsonSerializedInHtml.js +31 -0
- package/dist/cjs/client/shared/utils.js +21 -0
- package/dist/cjs/node/plugin/plugins/build/pluginModuleBanner.js +1 -0
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +5 -0
- package/dist/cjs/node/prerender/runPrerender.js +42 -40
- package/dist/cjs/node/prerender/utils.js +1 -1
- package/dist/cjs/node/runtime/globalContext.js +87 -119
- package/dist/cjs/node/runtime/html/injectAssets/getHtmlTags.js +18 -5
- package/dist/cjs/node/runtime/html/injectAssets/getViteDevScript.js +2 -2
- package/dist/cjs/node/runtime/html/propKeys.js +47 -0
- package/dist/cjs/node/runtime/html/renderHtml.js +1 -1
- package/dist/cjs/node/runtime/html/{serializePageContextClientSide.js → serializeContext.js} +37 -67
- package/dist/cjs/node/runtime/renderPage/analyzePage.js +1 -1
- package/dist/cjs/node/runtime/renderPage/createPageContextServerSide.js +14 -13
- package/dist/cjs/node/runtime/renderPage/getPageAssets.js +2 -2
- package/dist/cjs/node/runtime/renderPage/handleErrorWithoutErrorPage.js +1 -1
- package/dist/cjs/node/runtime/renderPage/loadUserFilesServerSide.js +1 -1
- package/dist/cjs/node/runtime/renderPage/log404/index.js +1 -1
- package/dist/cjs/node/runtime/renderPage/renderPageAlreadyRouted.js +3 -3
- package/dist/cjs/node/runtime/renderPage.js +10 -10
- package/dist/cjs/node/runtime/utils.js +1 -1
- package/dist/cjs/shared/createGlobalContextShared.js +45 -0
- package/dist/cjs/shared/createPageContextShared.js +2 -2
- package/dist/cjs/{node/runtime/renderPage → shared/hooks}/executeHookGeneric.js +4 -4
- package/dist/cjs/shared/htmlElementIds.js +5 -0
- package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
- package/dist/cjs/utils/catchInfiniteLoop.js +3 -3
- package/dist/cjs/utils/getPublicProxy.js +27 -0
- package/dist/cjs/utils/objectAssign.js +5 -5
- package/dist/cjs/utils/objectReplace.js +4 -4
- package/dist/esm/__internal/index.js +2 -2
- package/dist/esm/client/client-routing-runtime/{createPageContextClientSide.d.ts → createPageContext.d.ts} +17 -8
- package/dist/esm/client/client-routing-runtime/{createPageContextClientSide.js → createPageContext.js} +14 -16
- package/dist/esm/client/client-routing-runtime/getPageContextFromHooks.js +1 -1
- package/dist/esm/client/client-routing-runtime/globalContext.d.ts +16 -0
- package/dist/esm/client/client-routing-runtime/globalContext.js +13 -0
- package/dist/esm/client/client-routing-runtime/prefetch.js +1 -1
- package/dist/esm/client/client-routing-runtime/renderPageClientSide.js +2 -3
- package/dist/esm/client/server-routing-runtime/createPageContextClientSide.d.ts +13 -4
- package/dist/esm/client/server-routing-runtime/createPageContextClientSide.js +16 -15
- package/dist/esm/client/server-routing-runtime/globalContext.d.ts +13 -0
- package/dist/esm/client/server-routing-runtime/globalContext.js +5 -0
- package/dist/esm/client/shared/createGetGlobalContext.d.ts +11 -0
- package/dist/esm/client/shared/createGetGlobalContext.js +29 -0
- package/dist/esm/client/shared/{getPageContextSerializedInHtml.d.ts → getJsonSerializedInHtml.d.ts} +2 -0
- package/dist/esm/client/shared/getJsonSerializedInHtml.js +29 -0
- package/dist/esm/client/shared/utils.d.ts +3 -0
- package/dist/esm/client/shared/utils.js +3 -0
- package/dist/esm/node/plugin/plugins/build/pluginModuleBanner.js +1 -0
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +5 -0
- package/dist/esm/node/prerender/runPrerender.d.ts +300 -5
- package/dist/esm/node/prerender/runPrerender.js +43 -41
- package/dist/esm/node/prerender/utils.d.ts +1 -1
- package/dist/esm/node/prerender/utils.js +1 -1
- package/dist/esm/node/runtime/globalContext.d.ts +393 -46
- package/dist/esm/node/runtime/globalContext.js +88 -120
- package/dist/esm/node/runtime/html/injectAssets/getHtmlTags.js +18 -5
- package/dist/esm/node/runtime/html/injectAssets/getViteDevScript.js +2 -2
- package/dist/esm/node/runtime/html/injectAssets.d.ts +1 -1
- package/dist/esm/node/runtime/html/propKeys.d.ts +8 -0
- package/dist/esm/node/runtime/html/propKeys.js +45 -0
- package/dist/esm/node/runtime/html/renderHtml.js +1 -1
- package/dist/esm/node/runtime/html/{serializePageContextClientSide.d.ts → serializeContext.d.ts} +7 -6
- package/dist/esm/node/runtime/html/{serializePageContextClientSide.js → serializeContext.js} +36 -67
- package/dist/esm/node/runtime/renderPage/analyzePage.js +1 -1
- package/dist/esm/node/runtime/renderPage/createPageContextServerSide.d.ts +95 -35
- package/dist/esm/node/runtime/renderPage/createPageContextServerSide.js +14 -13
- package/dist/esm/node/runtime/renderPage/executeOnRenderHtmlHook.d.ts +1 -1
- package/dist/esm/node/runtime/renderPage/getPageAssets.js +2 -2
- package/dist/esm/node/runtime/renderPage/handleErrorWithoutErrorPage.js +1 -1
- package/dist/esm/node/runtime/renderPage/loadUserFilesServerSide.js +1 -1
- package/dist/esm/node/runtime/renderPage/log404/index.js +1 -1
- package/dist/esm/node/runtime/renderPage/preparePageContextForUserConsumptionServerSide.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.d.ts +186 -64
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.js +3 -3
- package/dist/esm/node/runtime/renderPage.d.ts +95 -34
- package/dist/esm/node/runtime/renderPage.js +10 -10
- package/dist/esm/node/runtime/utils.d.ts +1 -1
- package/dist/esm/node/runtime/utils.js +1 -1
- package/dist/esm/shared/VikeNamespace.d.ts +32 -10
- package/dist/esm/shared/createGlobalContextShared.d.ts +25 -0
- package/dist/esm/shared/createGlobalContextShared.js +43 -0
- package/dist/esm/shared/createPageContextShared.js +2 -2
- package/dist/esm/shared/hooks/executeHookGeneric.d.ts +8 -0
- package/dist/esm/{node/runtime/renderPage → shared/hooks}/executeHookGeneric.js +4 -4
- package/dist/esm/shared/htmlElementIds.d.ts +2 -0
- package/dist/esm/shared/htmlElementIds.js +2 -0
- package/dist/esm/shared/page-configs/Config.d.ts +7 -2
- package/dist/esm/shared/types.d.ts +20 -13
- package/dist/esm/types/index.d.ts +1 -5
- package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
- package/dist/esm/utils/PROJECT_VERSION.js +1 -1
- package/dist/esm/utils/catchInfiniteLoop.js +4 -4
- package/dist/esm/utils/getGlobalObject.d.ts +1 -1
- package/dist/esm/utils/getPublicProxy.d.ts +2 -0
- package/dist/esm/utils/getPublicProxy.js +25 -0
- package/dist/esm/utils/objectAssign.d.ts +1 -1
- package/dist/esm/utils/objectAssign.js +5 -5
- package/dist/esm/utils/objectReplace.d.ts +1 -1
- package/dist/esm/utils/objectReplace.js +4 -4
- package/package.json +2 -2
- package/dist/cjs/client/client-routing-runtime/globalContextClientSide.js +0 -10
- package/dist/cjs/client/client-routing-runtime/onLoad.js +0 -10
- package/dist/cjs/client/client-routing-runtime/utils.js +0 -43
- package/dist/cjs/utils/makePublicCopy.js +0 -32
- package/dist/esm/client/client-routing-runtime/globalContextClientSide.d.ts +0 -5
- package/dist/esm/client/client-routing-runtime/globalContextClientSide.js +0 -8
- package/dist/esm/client/shared/getPageContextSerializedInHtml.js +0 -20
- package/dist/esm/node/runtime/renderPage/executeHookGeneric.d.ts +0 -8
- package/dist/esm/utils/makePublicCopy.d.ts +0 -3
- package/dist/esm/utils/makePublicCopy.js +0 -30
|
@@ -21,32 +21,36 @@ exports.clearGlobalContext = clearGlobalContext;
|
|
|
21
21
|
exports.assertBuildInfo = assertBuildInfo;
|
|
22
22
|
exports.updateUserFiles = updateUserFiles;
|
|
23
23
|
// The core logic revolves around:
|
|
24
|
-
// -
|
|
24
|
+
// - virtualFileExports is the main requirement
|
|
25
25
|
// - In production: globalObject.buildEntry which is the production entry set by @brillout/vite-plugin-server-entry
|
|
26
|
-
// - loadBuildEntry() sets globalObject.buildEntry and then sets
|
|
26
|
+
// - loadBuildEntry() sets globalObject.buildEntry and then sets virtualFileExports
|
|
27
27
|
// - With vike-server it's set at server start: @brillout/vite-plugin-server-entry injects `import './entry.mjs'` (the production entry generated by @brillout/vite-plugin-server-entry) as first line of code of dist/server/index.mjs while dist/server/entry.mjs calls setGlobalContext_buildEntry()
|
|
28
28
|
// - Without vike-server it's manually loaded here using importServerProductionEntry() which uses @brillout/vite-plugin-server-entry's autoImporter or crawler
|
|
29
29
|
// - In development: globalObject.viteDevServer which is Vite's development server
|
|
30
|
-
// - globalObject.viteDevServer is used by updateUserFiles() which then sets
|
|
30
|
+
// - globalObject.viteDevServer is used by updateUserFiles() which then sets virtualFileExports
|
|
31
31
|
const utils_js_1 = require("./utils.js");
|
|
32
32
|
const runtime_1 = require("@brillout/vite-plugin-server-entry/runtime");
|
|
33
33
|
const virtualFileImportUserCode_js_1 = require("../shared/virtual-files/virtualFileImportUserCode.js");
|
|
34
34
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
35
35
|
const loadPageRoutes_js_1 = require("../../shared/route/loadPageRoutes.js");
|
|
36
36
|
const assertV1Design_js_1 = require("../shared/assertV1Design.js");
|
|
37
|
-
const getPageConfigsRuntime_js_1 = require("../../shared/getPageConfigsRuntime.js");
|
|
38
37
|
const resolveBase_js_1 = require("../shared/resolveBase.js");
|
|
38
|
+
const createGlobalContextShared_js_1 = require("../../shared/createGlobalContextShared.js");
|
|
39
39
|
const debug = (0, utils_js_1.createDebugger)('vike:globalContext');
|
|
40
40
|
const globalObject = (0, utils_js_1.getGlobalObject)('runtime/globalContext.ts', getInitialGlobalContext());
|
|
41
|
+
// Trick to break down TypeScript circular dependency
|
|
42
|
+
// https://chat.deepseek.com/a/chat/s/d7e9f90a-c7f3-4108-9cd5-4ad6caed3539
|
|
43
|
+
const globalObjectTyped = globalObject;
|
|
41
44
|
async function getGlobalContextInternal() {
|
|
42
45
|
// getGlobalContextInternal() should always be called after initGlobalContext()
|
|
43
46
|
(0, utils_js_1.assert)(globalObject.isInitialized);
|
|
44
47
|
assertGlobalContextIsDefined();
|
|
45
48
|
if (globalObject.isProduction !== true)
|
|
46
49
|
await globalObject.waitForUserFilesUpdate;
|
|
47
|
-
const { globalContext } =
|
|
50
|
+
const { globalContext, globalContext_public } = globalObjectTyped;
|
|
48
51
|
assertIsDefined(globalContext);
|
|
49
|
-
|
|
52
|
+
(0, utils_js_1.assert)(globalContext_public);
|
|
53
|
+
return { globalContext, globalContext_public };
|
|
50
54
|
}
|
|
51
55
|
function assertIsDefined(globalContext) {
|
|
52
56
|
if (!globalContext) {
|
|
@@ -56,7 +60,8 @@ function assertIsDefined(globalContext) {
|
|
|
56
60
|
}
|
|
57
61
|
}
|
|
58
62
|
function assertGlobalContextIsDefined() {
|
|
59
|
-
assertIsDefined(
|
|
63
|
+
assertIsDefined(globalObjectTyped.globalContext);
|
|
64
|
+
(0, utils_js_1.assert)(globalObject.globalContext);
|
|
60
65
|
(0, utils_js_1.assert)(globalObject.globalContext_public);
|
|
61
66
|
}
|
|
62
67
|
/**
|
|
@@ -86,7 +91,7 @@ async function getGlobalContextAsync(isProduction) {
|
|
|
86
91
|
if (!isProduction)
|
|
87
92
|
await globalObject.waitForUserFilesUpdate;
|
|
88
93
|
assertGlobalContextIsDefined();
|
|
89
|
-
const { globalContext_public } =
|
|
94
|
+
const { globalContext_public } = globalObjectTyped;
|
|
90
95
|
(0, utils_js_1.assert)(globalContext_public);
|
|
91
96
|
return globalContext_public;
|
|
92
97
|
}
|
|
@@ -99,7 +104,7 @@ async function getGlobalContextAsync(isProduction) {
|
|
|
99
104
|
*/
|
|
100
105
|
function getGlobalContextSync() {
|
|
101
106
|
debug('getGlobalContextSync()');
|
|
102
|
-
const { globalContext_public } =
|
|
107
|
+
const { globalContext_public } = globalObjectTyped;
|
|
103
108
|
(0, utils_js_1.assertUsage)(globalContext_public, "The global context isn't set yet, call getGlobalContextSync() later or use getGlobalContext() instead.");
|
|
104
109
|
(0, utils_js_1.assertWarning)(false,
|
|
105
110
|
// We discourage users from using it because using `pageContext.globalContext` is better: it doesn't have the race condition issue that `getGlobalContextSync()` would have when called inside React/Vue components.
|
|
@@ -108,15 +113,7 @@ function getGlobalContextSync() {
|
|
|
108
113
|
return globalContext_public;
|
|
109
114
|
}
|
|
110
115
|
function makePublic(globalContext) {
|
|
111
|
-
const globalContextPublic = (0, utils_js_1.
|
|
112
|
-
'assetsManifest',
|
|
113
|
-
'config',
|
|
114
|
-
'viteConfig',
|
|
115
|
-
'viteConfigRuntime',
|
|
116
|
-
'pages',
|
|
117
|
-
'baseServer',
|
|
118
|
-
'baseAssets'
|
|
119
|
-
]);
|
|
116
|
+
const globalContextPublic = (0, utils_js_1.getPublicProxy)(globalContext, 'globalContext', ['assetsManifest', 'config', 'viteConfig', 'viteConfigRuntime', 'pages', 'baseServer', 'baseAssets'], true);
|
|
120
117
|
return globalContextPublic;
|
|
121
118
|
}
|
|
122
119
|
async function setGlobalContext_viteDevServer(viteDevServer) {
|
|
@@ -224,96 +221,6 @@ function setIsProduction(isProduction) {
|
|
|
224
221
|
(0, utils_js_1.assert)(globalObject.isProduction === isProduction);
|
|
225
222
|
globalObject.isProduction = isProduction;
|
|
226
223
|
}
|
|
227
|
-
function defineGlobalContext() {
|
|
228
|
-
const globalContext = resolveGlobalContext();
|
|
229
|
-
assertIsDefined(globalContext);
|
|
230
|
-
const globalContext_public = makePublic(globalContext);
|
|
231
|
-
(0, utils_js_1.objectAssign)(globalContext, { globalContext_public });
|
|
232
|
-
globalObject.globalContext = globalContext;
|
|
233
|
-
globalObject.globalContext_public = globalContext_public;
|
|
234
|
-
assertGlobalContextIsDefined();
|
|
235
|
-
(0, utils_js_1.onSetupRuntime)();
|
|
236
|
-
}
|
|
237
|
-
function resolveGlobalContext() {
|
|
238
|
-
const { viteDevServer, viteConfig, viteConfigRuntime, isPrerendering, isProduction, userFiles } = globalObject;
|
|
239
|
-
(0, utils_js_1.assert)(typeof isProduction === 'boolean');
|
|
240
|
-
let globalContext;
|
|
241
|
-
if (!isProduction) {
|
|
242
|
-
// Requires globalObject.viteDevServer
|
|
243
|
-
if (!viteDevServer)
|
|
244
|
-
return null;
|
|
245
|
-
(0, utils_js_1.assert)(userFiles); // main common requiement
|
|
246
|
-
(0, utils_js_1.assert)(viteConfig);
|
|
247
|
-
(0, utils_js_1.assert)(viteConfigRuntime);
|
|
248
|
-
(0, utils_js_1.assert)(!isPrerendering);
|
|
249
|
-
globalContext = {
|
|
250
|
-
isProduction: false,
|
|
251
|
-
isPrerendering: false,
|
|
252
|
-
assetsManifest: null,
|
|
253
|
-
viteDevServer,
|
|
254
|
-
viteConfig,
|
|
255
|
-
...userFiles,
|
|
256
|
-
viteConfigRuntime,
|
|
257
|
-
...resolveBaseRuntime(viteConfigRuntime, userFiles.config)
|
|
258
|
-
};
|
|
259
|
-
}
|
|
260
|
-
else {
|
|
261
|
-
// Requires globalObject.buildEntry
|
|
262
|
-
if (!globalObject.buildEntry)
|
|
263
|
-
return null;
|
|
264
|
-
(0, utils_js_1.assert)(userFiles); // main common requiement
|
|
265
|
-
const { buildInfo, assetsManifest } = globalObject;
|
|
266
|
-
(0, utils_js_1.assert)(buildInfo);
|
|
267
|
-
(0, utils_js_1.assert)(assetsManifest);
|
|
268
|
-
const globalContext_ = {
|
|
269
|
-
isProduction: true,
|
|
270
|
-
assetsManifest,
|
|
271
|
-
...userFiles,
|
|
272
|
-
viteDevServer: null,
|
|
273
|
-
viteConfigRuntime: buildInfo.viteConfigRuntime,
|
|
274
|
-
usesClientRouter: buildInfo.usesClientRouter,
|
|
275
|
-
...resolveBaseRuntime(buildInfo.viteConfigRuntime, userFiles.config)
|
|
276
|
-
};
|
|
277
|
-
if (isPrerendering) {
|
|
278
|
-
(0, utils_js_1.assert)(viteConfig);
|
|
279
|
-
(0, utils_js_1.objectAssign)(globalContext_, {
|
|
280
|
-
isPrerendering: true,
|
|
281
|
-
viteConfig
|
|
282
|
-
});
|
|
283
|
-
globalContext = globalContext_;
|
|
284
|
-
}
|
|
285
|
-
else {
|
|
286
|
-
(0, utils_js_1.objectAssign)(globalContext_, {
|
|
287
|
-
isPrerendering: false,
|
|
288
|
-
viteConfig: null
|
|
289
|
-
});
|
|
290
|
-
globalContext = globalContext_;
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
return globalContext;
|
|
294
|
-
}
|
|
295
|
-
async function getUserFiles() {
|
|
296
|
-
// Help TypeScript resolve what TypeScript (wrongfully) believes to be cyclic dependency
|
|
297
|
-
const globalObject_ = globalObject;
|
|
298
|
-
const { pageConfigsRuntime } = globalObject_;
|
|
299
|
-
(0, utils_js_1.assert)(pageConfigsRuntime);
|
|
300
|
-
const { pageFilesAll, allPageIds, pageConfigs, pageConfigGlobal, globalConfig, pageConfigsUserFriendly } = pageConfigsRuntime;
|
|
301
|
-
const { pageRoutes, onBeforeRouteHook } = await (0, loadPageRoutes_js_1.loadPageRoutes)(pageFilesAll, pageConfigs, pageConfigGlobal, allPageIds);
|
|
302
|
-
const userFiles = {
|
|
303
|
-
pageFilesAll,
|
|
304
|
-
pageConfigs,
|
|
305
|
-
pageConfigGlobal,
|
|
306
|
-
allPageIds,
|
|
307
|
-
pageRoutes,
|
|
308
|
-
onBeforeRouteHook,
|
|
309
|
-
pages: pageConfigsUserFriendly,
|
|
310
|
-
config: globalConfig.config
|
|
311
|
-
};
|
|
312
|
-
(0, assertV1Design_js_1.assertV1Design)(
|
|
313
|
-
// pageConfigs is PageConfigRuntime[] but assertV1Design() requires PageConfigBuildTime[]
|
|
314
|
-
pageConfigs.length > 0, pageFilesAll);
|
|
315
|
-
return userFiles;
|
|
316
|
-
}
|
|
317
224
|
function assertViteManifest(manifest) {
|
|
318
225
|
(0, utils_js_1.assert)((0, utils_js_1.isPlainObject)(manifest));
|
|
319
226
|
/* We should include these assertions but we don't as a workaround for PWA manifests: https://github.com/vikejs/vike/issues/769
|
|
@@ -329,10 +236,7 @@ function assertViteManifest(manifest) {
|
|
|
329
236
|
}
|
|
330
237
|
async function loadBuildEntry(outDir) {
|
|
331
238
|
debug('loadBuildEntry()');
|
|
332
|
-
if (globalObject.
|
|
333
|
-
(0, utils_js_1.assert)(globalObject.buildInfo);
|
|
334
|
-
(0, utils_js_1.assert)(globalObject.assetsManifest);
|
|
335
|
-
(0, utils_js_1.assert)(globalObject.buildEntry);
|
|
239
|
+
if (globalObject.globalContext) {
|
|
336
240
|
return;
|
|
337
241
|
}
|
|
338
242
|
if (!globalObject.buildEntry) {
|
|
@@ -356,7 +260,7 @@ async function loadBuildEntry(outDir) {
|
|
|
356
260
|
assertBuildEntry(buildEntry);
|
|
357
261
|
globalObject.assetsManifest = buildEntry.assetsManifest;
|
|
358
262
|
globalObject.buildInfo = buildEntry.buildInfo;
|
|
359
|
-
await
|
|
263
|
+
await setGlobalContext(buildEntry.virtualFileExports);
|
|
360
264
|
}
|
|
361
265
|
async function setGlobalContext_buildEntry(buildEntry) {
|
|
362
266
|
debug('setGlobalContext_buildEntry()');
|
|
@@ -416,15 +320,79 @@ async function updateUserFiles() {
|
|
|
416
320
|
// Avoid race condition: abort if there is a new globalObject.viteDevServer (happens when vite.config.js is modified => Vite's dev server is fully reloaded).
|
|
417
321
|
if (viteDevServer !== globalObject.viteDevServer)
|
|
418
322
|
return;
|
|
419
|
-
await
|
|
323
|
+
await setGlobalContext(virtualFileExports);
|
|
420
324
|
resolve();
|
|
421
325
|
}
|
|
422
|
-
async function
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
326
|
+
async function setGlobalContext(virtualFileExports) {
|
|
327
|
+
const globalContext = await (0, createGlobalContextShared_js_1.createGlobalContextShared)(virtualFileExports, globalObject, addGlobalContext);
|
|
328
|
+
(0, assertV1Design_js_1.assertV1Design)(
|
|
329
|
+
// pageConfigs is PageConfigRuntime[] but assertV1Design() requires PageConfigBuildTime[]
|
|
330
|
+
globalContext._pageConfigs.length > 0, globalContext._pageFilesAll);
|
|
331
|
+
// Public usage
|
|
332
|
+
globalObject.globalContext_public = makePublic(globalContext);
|
|
427
333
|
assertGlobalContextIsDefined();
|
|
334
|
+
(0, utils_js_1.onSetupRuntime)();
|
|
335
|
+
// Never actually used, only used for TypeScript `ReturnType<typeof setGlobalContext>`
|
|
336
|
+
return globalContext;
|
|
337
|
+
}
|
|
338
|
+
async function addGlobalContext(globalContext) {
|
|
339
|
+
const { pageRoutes, onBeforeRouteHook } = await (0, loadPageRoutes_js_1.loadPageRoutes)(globalContext._pageFilesAll, globalContext._pageConfigs, globalContext._pageConfigGlobal, globalContext._allPageIds);
|
|
340
|
+
const globalContextBase = {
|
|
341
|
+
_pageRoutes: pageRoutes,
|
|
342
|
+
_onBeforeRouteHook: onBeforeRouteHook
|
|
343
|
+
};
|
|
344
|
+
const { viteDevServer, viteConfig, viteConfigRuntime, isPrerendering, isProduction } = globalObject;
|
|
345
|
+
(0, utils_js_1.assert)(typeof isProduction === 'boolean');
|
|
346
|
+
if (!isProduction) {
|
|
347
|
+
(0, utils_js_1.assert)(viteDevServer);
|
|
348
|
+
(0, utils_js_1.assert)(globalContext); // main common requirement
|
|
349
|
+
(0, utils_js_1.assert)(viteConfig);
|
|
350
|
+
(0, utils_js_1.assert)(viteConfigRuntime);
|
|
351
|
+
(0, utils_js_1.assert)(!isPrerendering);
|
|
352
|
+
return {
|
|
353
|
+
...globalContext,
|
|
354
|
+
...globalContextBase,
|
|
355
|
+
...resolveBaseRuntime(viteConfigRuntime, globalContext.config),
|
|
356
|
+
_isProduction: false,
|
|
357
|
+
_isPrerendering: false,
|
|
358
|
+
assetsManifest: null,
|
|
359
|
+
_viteDevServer: viteDevServer,
|
|
360
|
+
viteConfig,
|
|
361
|
+
viteConfigRuntime
|
|
362
|
+
};
|
|
363
|
+
}
|
|
364
|
+
else {
|
|
365
|
+
(0, utils_js_1.assert)(globalObject.buildEntry);
|
|
366
|
+
(0, utils_js_1.assert)(globalContext); // main common requiement
|
|
367
|
+
const { buildInfo, assetsManifest } = globalObject;
|
|
368
|
+
(0, utils_js_1.assert)(buildInfo);
|
|
369
|
+
(0, utils_js_1.assert)(assetsManifest);
|
|
370
|
+
const globalContextBase2 = {
|
|
371
|
+
...globalContext,
|
|
372
|
+
...globalContextBase,
|
|
373
|
+
...resolveBaseRuntime(buildInfo.viteConfigRuntime, globalContext.config),
|
|
374
|
+
_isProduction: true,
|
|
375
|
+
assetsManifest,
|
|
376
|
+
_viteDevServer: null,
|
|
377
|
+
viteConfigRuntime: buildInfo.viteConfigRuntime,
|
|
378
|
+
_usesClientRouter: buildInfo.usesClientRouter
|
|
379
|
+
};
|
|
380
|
+
if (isPrerendering) {
|
|
381
|
+
(0, utils_js_1.assert)(viteConfig);
|
|
382
|
+
return {
|
|
383
|
+
...globalContextBase2,
|
|
384
|
+
_isPrerendering: true,
|
|
385
|
+
viteConfig
|
|
386
|
+
};
|
|
387
|
+
}
|
|
388
|
+
else {
|
|
389
|
+
return {
|
|
390
|
+
...globalContextBase2,
|
|
391
|
+
_isPrerendering: false,
|
|
392
|
+
viteConfig: null
|
|
393
|
+
};
|
|
394
|
+
}
|
|
395
|
+
}
|
|
428
396
|
}
|
|
429
397
|
function clearGlobalContext() {
|
|
430
398
|
debug('clearGlobalContext()');
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.getHtmlTags = getHtmlTags;
|
|
7
7
|
const isFontFallback_js_1 = require("../../renderPage/isFontFallback.js");
|
|
8
8
|
const utils_js_1 = require("../../utils.js");
|
|
9
|
-
const
|
|
9
|
+
const serializeContext_js_1 = require("../serializeContext.js");
|
|
10
10
|
const sanitizeJson_js_1 = require("./sanitizeJson.js");
|
|
11
11
|
const inferHtmlTags_js_1 = require("./inferHtmlTags.js");
|
|
12
12
|
const mergeScriptTags_js_1 = require("./mergeScriptTags.js");
|
|
@@ -14,11 +14,12 @@ const helpers_js_1 = require("../../../../shared/page-configs/helpers.js");
|
|
|
14
14
|
const getConfigValueRuntime_js_1 = require("../../../../shared/page-configs/getConfigValueRuntime.js");
|
|
15
15
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
16
16
|
const getConfigDefinedAt_js_1 = require("../../../../shared/page-configs/getConfigDefinedAt.js");
|
|
17
|
+
const htmlElementIds_js_1 = require("../../../../shared/htmlElementIds.js");
|
|
17
18
|
const stamp = '__injectFilterEntry';
|
|
18
19
|
async function getHtmlTags(pageContext, streamFromReactStreamingPackage, injectFilter, pageAssets, viteDevScript, isStream) {
|
|
19
20
|
(0, utils_js_1.assert)([true, false].includes(pageContext._isHtmlOnly));
|
|
20
21
|
const isHtmlOnly = pageContext._isHtmlOnly;
|
|
21
|
-
const { isProduction } = pageContext._globalContext;
|
|
22
|
+
const { _isProduction: isProduction } = pageContext._globalContext;
|
|
22
23
|
const injectScriptsAt = getInjectScriptsAt(pageContext.pageId, pageContext._pageConfigs);
|
|
23
24
|
const injectFilterEntries = [];
|
|
24
25
|
pageAssets
|
|
@@ -124,14 +125,21 @@ async function getHtmlTags(pageContext, streamFromReactStreamingPackage, injectF
|
|
|
124
125
|
// - https://github.com/vikejs/vike-vue/issues/85
|
|
125
126
|
(0, utils_js_1.assertWarning)(false, "We recommend against using HTML streaming and a pageContext promise (https://vike.dev/streaming#initial-data-after-stream-end) at the same time, because progressive hydration (https://vike.dev/streaming#progressive-rendering) won't work.", { onlyOnce: true });
|
|
126
127
|
}
|
|
127
|
-
// <script id="vike_pageContext" type="application/json">
|
|
128
128
|
if (!isHtmlOnly) {
|
|
129
|
+
// <script id="vike_pageContext" type="application/json">
|
|
129
130
|
htmlTags.push({
|
|
130
131
|
htmlTag: () =>
|
|
131
132
|
// Needs to be called after resolvePageContextPromise()
|
|
132
133
|
getPageContextJsonScriptTag(pageContext),
|
|
133
134
|
position: positionJavaScriptEntry
|
|
134
135
|
});
|
|
136
|
+
// <script id="vike_globalContext" type="application/json">
|
|
137
|
+
htmlTags.push({
|
|
138
|
+
htmlTag: () =>
|
|
139
|
+
// Needs to be called after resolvePageContextPromise()
|
|
140
|
+
getGlobalContextJsonScriptTag(pageContext),
|
|
141
|
+
position: positionJavaScriptEntry
|
|
142
|
+
});
|
|
135
143
|
}
|
|
136
144
|
// The JavaScript entry <script> tag
|
|
137
145
|
const scriptEntry = mergeScriptEntries(pageAssets, viteDevScript);
|
|
@@ -162,13 +170,18 @@ function mergeScriptEntries(pageAssets, viteDevScript) {
|
|
|
162
170
|
return scriptTag;
|
|
163
171
|
}
|
|
164
172
|
function getPageContextJsonScriptTag(pageContext) {
|
|
165
|
-
const
|
|
166
|
-
const htmlTag = `<script id="
|
|
173
|
+
const pageContextClientSerialized = (0, sanitizeJson_js_1.sanitizeJson)((0, serializeContext_js_1.getPageContextClientSerialized)(pageContext));
|
|
174
|
+
const htmlTag = `<script id="${htmlElementIds_js_1.htmlElementId_pageContext}" type="application/json">${pageContextClientSerialized}</script>`;
|
|
167
175
|
// Used by contra.com https://github.com/gajus
|
|
168
176
|
// @ts-expect-error
|
|
169
177
|
pageContext._pageContextHtmlTag = htmlTag;
|
|
170
178
|
return htmlTag;
|
|
171
179
|
}
|
|
180
|
+
function getGlobalContextJsonScriptTag(pageContext) {
|
|
181
|
+
const globalContextClientSerialized = (0, sanitizeJson_js_1.sanitizeJson)((0, serializeContext_js_1.getGlobalContextClientSerialized)(pageContext));
|
|
182
|
+
const htmlTag = `<script id="${htmlElementIds_js_1.htmlElementId_globalContext}" type="application/json">${globalContextClientSerialized}</script>`;
|
|
183
|
+
return htmlTag;
|
|
184
|
+
}
|
|
172
185
|
function assertInjectFilterEntries(injectFilterEntries) {
|
|
173
186
|
try {
|
|
174
187
|
checkForWrongUsage(injectFilterEntries);
|
|
@@ -9,10 +9,10 @@ const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
|
9
9
|
const reachOutCTA = 'Create a new GitHub issue to discuss a solution.';
|
|
10
10
|
async function getViteDevScript(pageContext) {
|
|
11
11
|
const globalContext = pageContext._globalContext;
|
|
12
|
-
if (globalContext.
|
|
12
|
+
if (globalContext._isProduction) {
|
|
13
13
|
return '';
|
|
14
14
|
}
|
|
15
|
-
const { viteDevServer } = globalContext;
|
|
15
|
+
const { _viteDevServer: viteDevServer } = globalContext;
|
|
16
16
|
const fakeHtmlBegin = '<html> <head>'; // White space to test whether user is using a minifier
|
|
17
17
|
const fakeHtmlEnd = '</head><body></body></html>';
|
|
18
18
|
let fakeHtml = fakeHtmlBegin + fakeHtmlEnd;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getPropVal = getPropVal;
|
|
4
|
+
exports.setPropVal = setPropVal;
|
|
5
|
+
exports.getPropKeys = getPropKeys;
|
|
6
|
+
const utils_js_1 = require("../utils.js");
|
|
7
|
+
// Get a nested property from an object using a dot-separated path such as 'user.id'
|
|
8
|
+
function getPropVal(obj, prop) {
|
|
9
|
+
const keys = getPropKeys(prop);
|
|
10
|
+
let value = obj;
|
|
11
|
+
for (const key of keys) {
|
|
12
|
+
if ((0, utils_js_1.isObject)(value) && key in value) {
|
|
13
|
+
value = value[key];
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
return null; // Property or intermediate property doesn't exist
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return { value };
|
|
20
|
+
}
|
|
21
|
+
// Set a nested property in an object using a dot-separated path such as 'user.id'
|
|
22
|
+
function setPropVal(obj, prop, val) {
|
|
23
|
+
const keys = getPropKeys(prop);
|
|
24
|
+
let currentObj = obj;
|
|
25
|
+
// Creating intermediate objects if necessary
|
|
26
|
+
for (let i = 0; i <= keys.length - 2; i++) {
|
|
27
|
+
const key = keys[i];
|
|
28
|
+
if (!(key in currentObj)) {
|
|
29
|
+
// Create intermediate object
|
|
30
|
+
currentObj[key] = {};
|
|
31
|
+
}
|
|
32
|
+
if (!(0, utils_js_1.isObject)(currentObj[key])) {
|
|
33
|
+
// Skip value upon data structure conflict
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
currentObj = currentObj[key];
|
|
37
|
+
}
|
|
38
|
+
// Set the final key to the value
|
|
39
|
+
const finalKey = keys[keys.length - 1];
|
|
40
|
+
currentObj[finalKey] = val;
|
|
41
|
+
}
|
|
42
|
+
function getPropKeys(prop) {
|
|
43
|
+
// Like `prop.split('.')` but with added support for `\` escaping, see getPageContextClientSerialized.spec.ts
|
|
44
|
+
return prop
|
|
45
|
+
.split(/(?<!\\)\./) // Split on unescaped dots
|
|
46
|
+
.map((key) => key.replace(/\\\./g, '.')); // Replace escaped dots with literal dots
|
|
47
|
+
}
|
|
@@ -197,7 +197,7 @@ function renderTemplate(templateContent, pageContext) {
|
|
|
197
197
|
}
|
|
198
198
|
}
|
|
199
199
|
{
|
|
200
|
-
const { isProduction } = pageContext._globalContext;
|
|
200
|
+
const { _isProduction: isProduction } = pageContext._globalContext;
|
|
201
201
|
if ((0, utils_js_1.isHtml)(templateVar) &&
|
|
202
202
|
// We don't show this warning in production because it's expected that some users may (un)willingly do some XSS injection: we avoid flooding the production logs.
|
|
203
203
|
!isProduction) {
|
package/dist/cjs/node/runtime/html/{serializePageContextClientSide.js → serializeContext.js}
RENAMED
|
@@ -3,9 +3,9 @@ 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
|
-
exports.
|
|
8
|
-
exports.
|
|
6
|
+
exports.getPageContextClientSerialized = getPageContextClientSerialized;
|
|
7
|
+
exports.getPageContextClientSerializedAbort = getPageContextClientSerializedAbort;
|
|
8
|
+
exports.getGlobalContextClientSerialized = getGlobalContextClientSerialized;
|
|
9
9
|
const stringify_1 = require("@brillout/json-serializer/stringify");
|
|
10
10
|
const utils_js_1 = require("../utils.js");
|
|
11
11
|
const error_page_js_1 = require("../../../shared/error-page.js");
|
|
@@ -14,7 +14,8 @@ const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
|
14
14
|
const NOT_SERIALIZABLE_js_1 = require("../../../shared/NOT_SERIALIZABLE.js");
|
|
15
15
|
const pageContextInitIsPassedToClient_js_1 = require("../../../shared/misc/pageContextInitIsPassedToClient.js");
|
|
16
16
|
const isServerSideError_js_1 = require("../../../shared/misc/isServerSideError.js");
|
|
17
|
-
const
|
|
17
|
+
const propKeys_js_1 = require("./propKeys.js");
|
|
18
|
+
const passToClientBuiltInPageContext = [
|
|
18
19
|
'abortReason',
|
|
19
20
|
'_urlRewrite',
|
|
20
21
|
'_urlRedirect',
|
|
@@ -28,29 +29,39 @@ const PASS_TO_CLIENT = [
|
|
|
28
29
|
'routeParams',
|
|
29
30
|
'data' // for data() hook
|
|
30
31
|
];
|
|
31
|
-
const
|
|
32
|
-
function
|
|
33
|
-
const
|
|
34
|
-
const pageContextClient = applyPassToClient(
|
|
35
|
-
if (
|
|
32
|
+
const pageToClientBuiltInPageContextError = ['pageProps', 'is404', isServerSideError_js_1.isServerSideError];
|
|
33
|
+
function getPageContextClientSerialized(pageContext) {
|
|
34
|
+
const passToClientPageContext = getPassToClientPageContext(pageContext);
|
|
35
|
+
const pageContextClient = applyPassToClient(passToClientPageContext, pageContext);
|
|
36
|
+
if (passToClientPageContext.some((prop) => (0, propKeys_js_1.getPropVal)(pageContext._pageContextInit, prop))) {
|
|
36
37
|
pageContextClient[pageContextInitIsPassedToClient_js_1.pageContextInitIsPassedToClient] = true;
|
|
37
38
|
}
|
|
38
|
-
|
|
39
|
+
const pageContextClientSerialized = serializeObject(pageContextClient, 'pageContext', passToClientPageContext);
|
|
40
|
+
return pageContextClientSerialized;
|
|
41
|
+
}
|
|
42
|
+
function getGlobalContextClientSerialized(pageContext) {
|
|
43
|
+
const passToClient = pageContext._passToClient;
|
|
44
|
+
const globalContextClient = applyPassToClient(passToClient, pageContext.globalContext);
|
|
45
|
+
const globalContextClientSerialized = serializeObject(globalContextClient, 'globalContext', passToClient);
|
|
46
|
+
return globalContextClientSerialized;
|
|
47
|
+
}
|
|
48
|
+
function serializeObject(obj, objName, passToClient) {
|
|
49
|
+
let serialized;
|
|
39
50
|
try {
|
|
40
|
-
|
|
51
|
+
serialized = serializeValue(obj);
|
|
41
52
|
}
|
|
42
53
|
catch (err) {
|
|
43
54
|
const h = (s) => picocolors_1.default.cyan(s);
|
|
44
55
|
let hasWarned = false;
|
|
45
56
|
const propsNonSerializable = [];
|
|
46
57
|
passToClient.forEach((prop) => {
|
|
47
|
-
const res = getPropVal(
|
|
58
|
+
const res = (0, propKeys_js_1.getPropVal)(obj, prop);
|
|
48
59
|
if (!res)
|
|
49
60
|
return;
|
|
50
61
|
const { value } = res;
|
|
51
|
-
const varName =
|
|
62
|
+
const varName = `${objName}${(0, propKeys_js_1.getPropKeys)(prop).map(utils_js_1.getPropAccessNotation).join('')}`;
|
|
52
63
|
try {
|
|
53
|
-
|
|
64
|
+
serializeValue(value, varName);
|
|
54
65
|
}
|
|
55
66
|
catch (err) {
|
|
56
67
|
propsNonSerializable.push(prop);
|
|
@@ -62,7 +73,7 @@ function serializePageContextClientSide(pageContext) {
|
|
|
62
73
|
}
|
|
63
74
|
(0, utils_js_1.assertUsage)(false, `Cannot serialize config ${h(pathString)} set by useConfig(), see https://vike.dev/useConfig#serialization-error`);
|
|
64
75
|
}
|
|
65
|
-
// Non-serializable
|
|
76
|
+
// Non-serializable property set by the user
|
|
66
77
|
let msg = [
|
|
67
78
|
`${h(varName)} can't be serialized and, therefore, can't be passed to the client side.`,
|
|
68
79
|
`Make sure ${h(varName)} is serializable, or remove ${h(JSON.stringify(prop))} from ${h('passToClient')}.`
|
|
@@ -83,31 +94,31 @@ function serializePageContextClientSide(pageContext) {
|
|
|
83
94
|
});
|
|
84
95
|
(0, utils_js_1.assert)(hasWarned);
|
|
85
96
|
propsNonSerializable.forEach((prop) => {
|
|
86
|
-
|
|
97
|
+
obj[(0, propKeys_js_1.getPropKeys)(prop)[0]] = NOT_SERIALIZABLE_js_1.NOT_SERIALIZABLE;
|
|
87
98
|
});
|
|
88
99
|
try {
|
|
89
|
-
|
|
100
|
+
serialized = serializeValue(obj);
|
|
90
101
|
}
|
|
91
102
|
catch (err) {
|
|
92
103
|
(0, utils_js_1.assert)(false);
|
|
93
104
|
}
|
|
94
105
|
}
|
|
95
|
-
return
|
|
106
|
+
return serialized;
|
|
96
107
|
}
|
|
97
|
-
function
|
|
108
|
+
function serializeValue(value, varName) {
|
|
98
109
|
return (0, stringify_1.stringify)(value, { forbidReactElements: true, valueName: varName });
|
|
99
110
|
}
|
|
100
|
-
function
|
|
101
|
-
let passToClient = [...pageContext._passToClient, ...
|
|
111
|
+
function getPassToClientPageContext(pageContext) {
|
|
112
|
+
let passToClient = [...pageContext._passToClient, ...passToClientBuiltInPageContext];
|
|
102
113
|
if ((0, error_page_js_1.isErrorPage)(pageContext.pageId, pageContext._pageConfigs)) {
|
|
103
114
|
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(pageContext, 'is404', 'boolean'));
|
|
104
115
|
(0, addIs404ToPageProps_js_1.addIs404ToPageProps)(pageContext);
|
|
105
|
-
passToClient.push(...
|
|
116
|
+
passToClient.push(...pageToClientBuiltInPageContextError);
|
|
106
117
|
}
|
|
107
118
|
passToClient = (0, utils_js_1.unique)(passToClient);
|
|
108
119
|
return passToClient;
|
|
109
120
|
}
|
|
110
|
-
function
|
|
121
|
+
function getPageContextClientSerializedAbort(pageContext) {
|
|
111
122
|
(0, utils_js_1.assert)(pageContext._urlRedirect || pageContext._urlRewrite || pageContext.abortStatusCode);
|
|
112
123
|
(0, utils_js_1.assert)(pageContext._abortCall);
|
|
113
124
|
(0, utils_js_1.assert)(pageContext._abortCaller);
|
|
@@ -140,59 +151,18 @@ function serializePageContextAbort(pageContext) {
|
|
|
140
151
|
onlyOnce: false
|
|
141
152
|
});
|
|
142
153
|
}
|
|
143
|
-
return
|
|
154
|
+
return serializeValue(pageContext);
|
|
144
155
|
}
|
|
145
156
|
function applyPassToClient(passToClient, pageContext) {
|
|
146
157
|
const pageContextClient = {};
|
|
147
158
|
passToClient.forEach((prop) => {
|
|
148
159
|
// Get value from pageContext
|
|
149
|
-
const res = getPropVal(pageContext, prop);
|
|
160
|
+
const res = (0, propKeys_js_1.getPropVal)(pageContext, prop);
|
|
150
161
|
if (!res)
|
|
151
162
|
return;
|
|
152
163
|
const { value } = res;
|
|
153
164
|
// Set value to pageContextClient
|
|
154
|
-
setPropVal(pageContextClient, prop, value);
|
|
165
|
+
(0, propKeys_js_1.setPropVal)(pageContextClient, prop, value);
|
|
155
166
|
});
|
|
156
167
|
return pageContextClient;
|
|
157
168
|
}
|
|
158
|
-
// Get a nested property from an object using a dot-separated path such as 'user.id'
|
|
159
|
-
function getPropVal(obj, prop) {
|
|
160
|
-
const keys = getPropKeys(prop);
|
|
161
|
-
let value = obj;
|
|
162
|
-
for (const key of keys) {
|
|
163
|
-
if ((0, utils_js_1.isObject)(value) && key in value) {
|
|
164
|
-
value = value[key];
|
|
165
|
-
}
|
|
166
|
-
else {
|
|
167
|
-
return null; // Property or intermediate property doesn't exist
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
return { value };
|
|
171
|
-
}
|
|
172
|
-
// Set a nested property in an object using a dot-separated path such as 'user.id'
|
|
173
|
-
function setPropVal(obj, prop, val) {
|
|
174
|
-
const keys = getPropKeys(prop);
|
|
175
|
-
let currentObj = obj;
|
|
176
|
-
// Creating intermediate objects if necessary
|
|
177
|
-
for (let i = 0; i <= keys.length - 2; i++) {
|
|
178
|
-
const key = keys[i];
|
|
179
|
-
if (!(key in currentObj)) {
|
|
180
|
-
// Create intermediate object
|
|
181
|
-
currentObj[key] = {};
|
|
182
|
-
}
|
|
183
|
-
if (!(0, utils_js_1.isObject)(currentObj[key])) {
|
|
184
|
-
// Skip value upon data structure conflict
|
|
185
|
-
return;
|
|
186
|
-
}
|
|
187
|
-
currentObj = currentObj[key];
|
|
188
|
-
}
|
|
189
|
-
// Set the final key to the value
|
|
190
|
-
const finalKey = keys[keys.length - 1];
|
|
191
|
-
currentObj[finalKey] = val;
|
|
192
|
-
}
|
|
193
|
-
function getPropKeys(prop) {
|
|
194
|
-
// Like `prop.split('.')` but with added support for `\` escaping, see serializePageContextClientSide.spec.ts
|
|
195
|
-
return prop
|
|
196
|
-
.split(/(?<!\\)\./) // Split on unescaped dots
|
|
197
|
-
.map((key) => key.replace(/\\\./g, '.')); // Replace escaped dots with literal dots
|
|
198
|
-
}
|
|
@@ -22,7 +22,7 @@ async function analyzePage(pageFilesAll, pageConfig, pageId, globalContext) {
|
|
|
22
22
|
eagerlyImported: false
|
|
23
23
|
});
|
|
24
24
|
// In production we inject the import of the server virtual module with ?extractAssets inside the client virtual module
|
|
25
|
-
if (!globalContext.
|
|
25
|
+
if (!globalContext._isProduction) {
|
|
26
26
|
clientDependencies.push({
|
|
27
27
|
id: (0, virtualFilePageConfigValuesAll_js_1.getVirtualFileIdPageConfigValuesAll)(pageConfig.pageId, false),
|
|
28
28
|
onlyAssets: true,
|