@lolyjs/core 0.2.0-alpha.18 → 0.2.0-alpha.19
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/cli.cjs +57 -22
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +57 -22
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +152 -42
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +152 -42
- package/dist/index.js.map +1 -1
- package/dist/react/cache.cjs +82 -32
- package/dist/react/cache.cjs.map +1 -1
- package/dist/react/cache.d.mts +6 -19
- package/dist/react/cache.d.ts +6 -19
- package/dist/react/cache.js +83 -33
- package/dist/react/cache.js.map +1 -1
- package/dist/react/components.cjs +10 -8
- package/dist/react/components.cjs.map +1 -1
- package/dist/react/components.js +10 -8
- package/dist/react/components.js.map +1 -1
- package/dist/react/hooks.cjs.map +1 -1
- package/dist/react/hooks.js.map +1 -1
- package/dist/runtime.cjs +95 -20
- package/dist/runtime.cjs.map +1 -1
- package/dist/runtime.js +95 -20
- package/dist/runtime.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -12550,7 +12550,7 @@ async function runRouteServerHook(route, ctx) {
|
|
|
12550
12550
|
}
|
|
12551
12551
|
|
|
12552
12552
|
// modules/server/handlers/response.ts
|
|
12553
|
-
function handleDataResponse(res, loaderResult, theme) {
|
|
12553
|
+
function handleDataResponse(res, loaderResult, theme, layoutProps, pageProps, error, message) {
|
|
12554
12554
|
res.setHeader("Content-Type", "application/json; charset=utf-8");
|
|
12555
12555
|
if (loaderResult.redirect) {
|
|
12556
12556
|
res.statusCode = 200;
|
|
@@ -12562,14 +12562,26 @@ function handleDataResponse(res, loaderResult, theme) {
|
|
|
12562
12562
|
res.end(JSON.stringify({ notFound: true }));
|
|
12563
12563
|
return;
|
|
12564
12564
|
}
|
|
12565
|
-
|
|
12566
|
-
|
|
12567
|
-
|
|
12568
|
-
|
|
12569
|
-
|
|
12570
|
-
|
|
12571
|
-
|
|
12572
|
-
|
|
12565
|
+
const response = {
|
|
12566
|
+
// Combined props for backward compatibility
|
|
12567
|
+
props: loaderResult.props ?? {},
|
|
12568
|
+
metadata: loaderResult.metadata ?? null,
|
|
12569
|
+
theme: loaderResult.theme ?? theme ?? null
|
|
12570
|
+
};
|
|
12571
|
+
if (layoutProps !== void 0 && layoutProps !== null) {
|
|
12572
|
+
response.layoutProps = layoutProps;
|
|
12573
|
+
}
|
|
12574
|
+
if (pageProps !== void 0 && pageProps !== null) {
|
|
12575
|
+
response.pageProps = pageProps;
|
|
12576
|
+
}
|
|
12577
|
+
if (error !== void 0) {
|
|
12578
|
+
response.error = error;
|
|
12579
|
+
}
|
|
12580
|
+
if (message !== void 0) {
|
|
12581
|
+
response.message = message;
|
|
12582
|
+
}
|
|
12583
|
+
res.statusCode = error ? 500 : 200;
|
|
12584
|
+
res.end(JSON.stringify(response));
|
|
12573
12585
|
}
|
|
12574
12586
|
function handleRedirect(res, redirect) {
|
|
12575
12587
|
const { destination, permanent } = redirect;
|
|
@@ -12761,6 +12773,7 @@ async function handlePageRequestInternal(options) {
|
|
|
12761
12773
|
const clientCssPath = env === "dev" ? "/static/client.css" : projectRoot ? getClientCssPath(projectRoot) : "/static/client.css";
|
|
12762
12774
|
const assetManifest = env === "prod" && projectRoot ? loadAssetManifest(projectRoot) : null;
|
|
12763
12775
|
const isDataReq = isDataRequest(req);
|
|
12776
|
+
const skipLayoutHooks = isDataReq && req.headers["x-skip-layout-hooks"] === "true";
|
|
12764
12777
|
if (env === "prod" && ssgOutDir) {
|
|
12765
12778
|
if (isDataReq) {
|
|
12766
12779
|
if (tryServeSsgData(res, ssgOutDir, urlPath)) {
|
|
@@ -12784,7 +12797,7 @@ async function handlePageRequestInternal(options) {
|
|
|
12784
12797
|
locals: {}
|
|
12785
12798
|
};
|
|
12786
12799
|
const layoutProps2 = {};
|
|
12787
|
-
if (notFoundPage.layoutServerHooks && notFoundPage.layoutServerHooks.length > 0) {
|
|
12800
|
+
if (!skipLayoutHooks && notFoundPage.layoutServerHooks && notFoundPage.layoutServerHooks.length > 0) {
|
|
12788
12801
|
for (let i = 0; i < notFoundPage.layoutServerHooks.length; i++) {
|
|
12789
12802
|
const layoutServerHook = notFoundPage.layoutServerHooks[i];
|
|
12790
12803
|
if (layoutServerHook) {
|
|
@@ -12819,6 +12832,17 @@ async function handlePageRequestInternal(options) {
|
|
|
12819
12832
|
...loaderResult2,
|
|
12820
12833
|
props: combinedProps2
|
|
12821
12834
|
};
|
|
12835
|
+
if (isDataReq) {
|
|
12836
|
+
const pagePropsOnly = loaderResult2.props || {};
|
|
12837
|
+
handleDataResponse(
|
|
12838
|
+
res,
|
|
12839
|
+
combinedLoaderResult2,
|
|
12840
|
+
theme,
|
|
12841
|
+
skipLayoutHooks ? null : Object.keys(layoutProps2).length > 0 ? layoutProps2 : null,
|
|
12842
|
+
pagePropsOnly
|
|
12843
|
+
);
|
|
12844
|
+
return;
|
|
12845
|
+
}
|
|
12822
12846
|
const initialData2 = buildInitialData(urlPath, {}, combinedLoaderResult2);
|
|
12823
12847
|
const appTree2 = buildAppTree(notFoundPage, {}, initialData2.props);
|
|
12824
12848
|
initialData2.notFound = true;
|
|
@@ -12890,7 +12914,7 @@ async function handlePageRequestInternal(options) {
|
|
|
12890
12914
|
const layoutProps = {};
|
|
12891
12915
|
const layoutMetadata = [];
|
|
12892
12916
|
const reqLogger = getRequestLogger(req);
|
|
12893
|
-
if (route.layoutServerHooks && route.layoutServerHooks.length > 0) {
|
|
12917
|
+
if (!skipLayoutHooks && route.layoutServerHooks && route.layoutServerHooks.length > 0) {
|
|
12894
12918
|
for (let i = 0; i < route.layoutServerHooks.length; i++) {
|
|
12895
12919
|
const layoutServerHook = route.layoutServerHooks[i];
|
|
12896
12920
|
if (layoutServerHook) {
|
|
@@ -12974,7 +12998,14 @@ async function handlePageRequestInternal(options) {
|
|
|
12974
12998
|
metadata: combinedMetadata
|
|
12975
12999
|
};
|
|
12976
13000
|
if (isDataReq) {
|
|
12977
|
-
|
|
13001
|
+
const pagePropsOnly = loaderResult.props || {};
|
|
13002
|
+
handleDataResponse(
|
|
13003
|
+
res,
|
|
13004
|
+
combinedLoaderResult,
|
|
13005
|
+
theme,
|
|
13006
|
+
skipLayoutHooks ? null : Object.keys(layoutProps).length > 0 ? layoutProps : null,
|
|
13007
|
+
pagePropsOnly
|
|
13008
|
+
);
|
|
12978
13009
|
return;
|
|
12979
13010
|
}
|
|
12980
13011
|
if (loaderResult.redirect) {
|
|
@@ -13068,6 +13099,7 @@ async function handlePageRequestInternal(options) {
|
|
|
13068
13099
|
async function renderErrorPageWithStream(errorPage, req, res, error, routeChunks, theme, projectRoot, env = "dev") {
|
|
13069
13100
|
try {
|
|
13070
13101
|
const isDataReq = isDataRequest(req);
|
|
13102
|
+
const skipLayoutHooks = isDataReq && req.headers["x-skip-layout-hooks"] === "true";
|
|
13071
13103
|
const ctx = {
|
|
13072
13104
|
req,
|
|
13073
13105
|
res,
|
|
@@ -13077,7 +13109,7 @@ async function renderErrorPageWithStream(errorPage, req, res, error, routeChunks
|
|
|
13077
13109
|
};
|
|
13078
13110
|
const layoutProps = {};
|
|
13079
13111
|
const reqLogger = getRequestLogger(req);
|
|
13080
|
-
if (errorPage.layoutServerHooks && errorPage.layoutServerHooks.length > 0) {
|
|
13112
|
+
if (!skipLayoutHooks && errorPage.layoutServerHooks && errorPage.layoutServerHooks.length > 0) {
|
|
13081
13113
|
for (let i = 0; i < errorPage.layoutServerHooks.length; i++) {
|
|
13082
13114
|
const layoutServerHook = errorPage.layoutServerHooks[i];
|
|
13083
13115
|
if (layoutServerHook) {
|
|
@@ -13115,15 +13147,18 @@ async function renderErrorPageWithStream(errorPage, req, res, error, routeChunks
|
|
|
13115
13147
|
const routerData = buildRouterData(req);
|
|
13116
13148
|
initialData.error = true;
|
|
13117
13149
|
if (isDataReq) {
|
|
13118
|
-
|
|
13119
|
-
|
|
13120
|
-
|
|
13121
|
-
|
|
13122
|
-
|
|
13123
|
-
|
|
13124
|
-
|
|
13125
|
-
|
|
13126
|
-
|
|
13150
|
+
const pagePropsOnly = loaderResult.props || {};
|
|
13151
|
+
handleDataResponse(
|
|
13152
|
+
res,
|
|
13153
|
+
combinedLoaderResult,
|
|
13154
|
+
theme,
|
|
13155
|
+
skipLayoutHooks ? null : Object.keys(layoutProps).length > 0 ? layoutProps : null,
|
|
13156
|
+
pagePropsOnly,
|
|
13157
|
+
true,
|
|
13158
|
+
// error flag
|
|
13159
|
+
String(error)
|
|
13160
|
+
// error message
|
|
13161
|
+
);
|
|
13127
13162
|
return;
|
|
13128
13163
|
}
|
|
13129
13164
|
const appTree = buildAppTree(errorPage, { error: String(error) }, initialData.props);
|