@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.js
CHANGED
|
@@ -12555,7 +12555,7 @@ async function runRouteServerHook(route, ctx) {
|
|
|
12555
12555
|
}
|
|
12556
12556
|
|
|
12557
12557
|
// modules/server/handlers/response.ts
|
|
12558
|
-
function handleDataResponse(res, loaderResult, theme) {
|
|
12558
|
+
function handleDataResponse(res, loaderResult, theme, layoutProps, pageProps, error, message) {
|
|
12559
12559
|
res.setHeader("Content-Type", "application/json; charset=utf-8");
|
|
12560
12560
|
if (loaderResult.redirect) {
|
|
12561
12561
|
res.statusCode = 200;
|
|
@@ -12567,14 +12567,26 @@ function handleDataResponse(res, loaderResult, theme) {
|
|
|
12567
12567
|
res.end(JSON.stringify({ notFound: true }));
|
|
12568
12568
|
return;
|
|
12569
12569
|
}
|
|
12570
|
-
|
|
12571
|
-
|
|
12572
|
-
|
|
12573
|
-
|
|
12574
|
-
|
|
12575
|
-
|
|
12576
|
-
|
|
12577
|
-
|
|
12570
|
+
const response = {
|
|
12571
|
+
// Combined props for backward compatibility
|
|
12572
|
+
props: loaderResult.props ?? {},
|
|
12573
|
+
metadata: loaderResult.metadata ?? null,
|
|
12574
|
+
theme: loaderResult.theme ?? theme ?? null
|
|
12575
|
+
};
|
|
12576
|
+
if (layoutProps !== void 0 && layoutProps !== null) {
|
|
12577
|
+
response.layoutProps = layoutProps;
|
|
12578
|
+
}
|
|
12579
|
+
if (pageProps !== void 0 && pageProps !== null) {
|
|
12580
|
+
response.pageProps = pageProps;
|
|
12581
|
+
}
|
|
12582
|
+
if (error !== void 0) {
|
|
12583
|
+
response.error = error;
|
|
12584
|
+
}
|
|
12585
|
+
if (message !== void 0) {
|
|
12586
|
+
response.message = message;
|
|
12587
|
+
}
|
|
12588
|
+
res.statusCode = error ? 500 : 200;
|
|
12589
|
+
res.end(JSON.stringify(response));
|
|
12578
12590
|
}
|
|
12579
12591
|
function handleRedirect(res, redirect) {
|
|
12580
12592
|
const { destination, permanent } = redirect;
|
|
@@ -12766,6 +12778,7 @@ async function handlePageRequestInternal(options) {
|
|
|
12766
12778
|
const clientCssPath = env === "dev" ? "/static/client.css" : projectRoot ? getClientCssPath(projectRoot) : "/static/client.css";
|
|
12767
12779
|
const assetManifest = env === "prod" && projectRoot ? loadAssetManifest(projectRoot) : null;
|
|
12768
12780
|
const isDataReq = isDataRequest(req);
|
|
12781
|
+
const skipLayoutHooks = isDataReq && req.headers["x-skip-layout-hooks"] === "true";
|
|
12769
12782
|
if (env === "prod" && ssgOutDir) {
|
|
12770
12783
|
if (isDataReq) {
|
|
12771
12784
|
if (tryServeSsgData(res, ssgOutDir, urlPath)) {
|
|
@@ -12789,7 +12802,7 @@ async function handlePageRequestInternal(options) {
|
|
|
12789
12802
|
locals: {}
|
|
12790
12803
|
};
|
|
12791
12804
|
const layoutProps2 = {};
|
|
12792
|
-
if (notFoundPage.layoutServerHooks && notFoundPage.layoutServerHooks.length > 0) {
|
|
12805
|
+
if (!skipLayoutHooks && notFoundPage.layoutServerHooks && notFoundPage.layoutServerHooks.length > 0) {
|
|
12793
12806
|
for (let i = 0; i < notFoundPage.layoutServerHooks.length; i++) {
|
|
12794
12807
|
const layoutServerHook = notFoundPage.layoutServerHooks[i];
|
|
12795
12808
|
if (layoutServerHook) {
|
|
@@ -12824,6 +12837,17 @@ async function handlePageRequestInternal(options) {
|
|
|
12824
12837
|
...loaderResult2,
|
|
12825
12838
|
props: combinedProps2
|
|
12826
12839
|
};
|
|
12840
|
+
if (isDataReq) {
|
|
12841
|
+
const pagePropsOnly = loaderResult2.props || {};
|
|
12842
|
+
handleDataResponse(
|
|
12843
|
+
res,
|
|
12844
|
+
combinedLoaderResult2,
|
|
12845
|
+
theme,
|
|
12846
|
+
skipLayoutHooks ? null : Object.keys(layoutProps2).length > 0 ? layoutProps2 : null,
|
|
12847
|
+
pagePropsOnly
|
|
12848
|
+
);
|
|
12849
|
+
return;
|
|
12850
|
+
}
|
|
12827
12851
|
const initialData2 = buildInitialData(urlPath, {}, combinedLoaderResult2);
|
|
12828
12852
|
const appTree2 = buildAppTree(notFoundPage, {}, initialData2.props);
|
|
12829
12853
|
initialData2.notFound = true;
|
|
@@ -12895,7 +12919,7 @@ async function handlePageRequestInternal(options) {
|
|
|
12895
12919
|
const layoutProps = {};
|
|
12896
12920
|
const layoutMetadata = [];
|
|
12897
12921
|
const reqLogger = getRequestLogger(req);
|
|
12898
|
-
if (route.layoutServerHooks && route.layoutServerHooks.length > 0) {
|
|
12922
|
+
if (!skipLayoutHooks && route.layoutServerHooks && route.layoutServerHooks.length > 0) {
|
|
12899
12923
|
for (let i = 0; i < route.layoutServerHooks.length; i++) {
|
|
12900
12924
|
const layoutServerHook = route.layoutServerHooks[i];
|
|
12901
12925
|
if (layoutServerHook) {
|
|
@@ -12979,7 +13003,14 @@ async function handlePageRequestInternal(options) {
|
|
|
12979
13003
|
metadata: combinedMetadata
|
|
12980
13004
|
};
|
|
12981
13005
|
if (isDataReq) {
|
|
12982
|
-
|
|
13006
|
+
const pagePropsOnly = loaderResult.props || {};
|
|
13007
|
+
handleDataResponse(
|
|
13008
|
+
res,
|
|
13009
|
+
combinedLoaderResult,
|
|
13010
|
+
theme,
|
|
13011
|
+
skipLayoutHooks ? null : Object.keys(layoutProps).length > 0 ? layoutProps : null,
|
|
13012
|
+
pagePropsOnly
|
|
13013
|
+
);
|
|
12983
13014
|
return;
|
|
12984
13015
|
}
|
|
12985
13016
|
if (loaderResult.redirect) {
|
|
@@ -13073,6 +13104,7 @@ async function handlePageRequestInternal(options) {
|
|
|
13073
13104
|
async function renderErrorPageWithStream(errorPage, req, res, error, routeChunks, theme, projectRoot, env = "dev") {
|
|
13074
13105
|
try {
|
|
13075
13106
|
const isDataReq = isDataRequest(req);
|
|
13107
|
+
const skipLayoutHooks = isDataReq && req.headers["x-skip-layout-hooks"] === "true";
|
|
13076
13108
|
const ctx = {
|
|
13077
13109
|
req,
|
|
13078
13110
|
res,
|
|
@@ -13082,7 +13114,7 @@ async function renderErrorPageWithStream(errorPage, req, res, error, routeChunks
|
|
|
13082
13114
|
};
|
|
13083
13115
|
const layoutProps = {};
|
|
13084
13116
|
const reqLogger = getRequestLogger(req);
|
|
13085
|
-
if (errorPage.layoutServerHooks && errorPage.layoutServerHooks.length > 0) {
|
|
13117
|
+
if (!skipLayoutHooks && errorPage.layoutServerHooks && errorPage.layoutServerHooks.length > 0) {
|
|
13086
13118
|
for (let i = 0; i < errorPage.layoutServerHooks.length; i++) {
|
|
13087
13119
|
const layoutServerHook = errorPage.layoutServerHooks[i];
|
|
13088
13120
|
if (layoutServerHook) {
|
|
@@ -13120,15 +13152,18 @@ async function renderErrorPageWithStream(errorPage, req, res, error, routeChunks
|
|
|
13120
13152
|
const routerData = buildRouterData(req);
|
|
13121
13153
|
initialData.error = true;
|
|
13122
13154
|
if (isDataReq) {
|
|
13123
|
-
|
|
13124
|
-
|
|
13125
|
-
|
|
13126
|
-
|
|
13127
|
-
|
|
13128
|
-
|
|
13129
|
-
|
|
13130
|
-
|
|
13131
|
-
|
|
13155
|
+
const pagePropsOnly = loaderResult.props || {};
|
|
13156
|
+
handleDataResponse(
|
|
13157
|
+
res,
|
|
13158
|
+
combinedLoaderResult,
|
|
13159
|
+
theme,
|
|
13160
|
+
skipLayoutHooks ? null : Object.keys(layoutProps).length > 0 ? layoutProps : null,
|
|
13161
|
+
pagePropsOnly,
|
|
13162
|
+
true,
|
|
13163
|
+
// error flag
|
|
13164
|
+
String(error)
|
|
13165
|
+
// error message
|
|
13166
|
+
);
|
|
13132
13167
|
return;
|
|
13133
13168
|
}
|
|
13134
13169
|
const appTree = buildAppTree(errorPage, { error: String(error) }, initialData.props);
|