@krate/runtime 0.3.0-beta.1 → 0.3.0-beta.2
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/server-renderer.js +5 -42
- package/package.json +2 -2
package/dist/server-renderer.js
CHANGED
|
@@ -111,48 +111,11 @@ async function renderPage(req) {
|
|
|
111
111
|
}
|
|
112
112
|
try {
|
|
113
113
|
const mod = await loadPageModule(page);
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
//
|
|
118
|
-
|
|
119
|
-
// streaming pages with async props render real data instead of {}.
|
|
120
|
-
const dataFn = mod.getServerSideProps || mod.getStaticProps;
|
|
121
|
-
if (typeof dataFn === "function") {
|
|
122
|
-
try {
|
|
123
|
-
const data = await dataFn({
|
|
124
|
-
params: req.params,
|
|
125
|
-
query: req.query,
|
|
126
|
-
headers: req.headers,
|
|
127
|
-
method: req.method,
|
|
128
|
-
url: req.url,
|
|
129
|
-
});
|
|
130
|
-
if (data && typeof data === "object") {
|
|
131
|
-
if (data.notFound) {
|
|
132
|
-
notFound = true;
|
|
133
|
-
}
|
|
134
|
-
else if (data.redirect) {
|
|
135
|
-
redirect =
|
|
136
|
-
typeof data.redirect === "string"
|
|
137
|
-
? data.redirect
|
|
138
|
-
: data.redirect.destination || data.redirect;
|
|
139
|
-
}
|
|
140
|
-
else if (data.props && typeof data.props === "object") {
|
|
141
|
-
props = data.props;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
catch (err) {
|
|
146
|
-
console.error(`[krate] ${dataFn.name || "getServerSideProps"} failed for ${req.route}:`, err);
|
|
147
|
-
return { html: "", status: 500 };
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
if (notFound) {
|
|
151
|
-
return { html: "", status: 404, notFound: true };
|
|
152
|
-
}
|
|
153
|
-
if (redirect) {
|
|
154
|
-
return { html: "", status: 302, redirect };
|
|
155
|
-
}
|
|
114
|
+
// Page-level data fetching (getStaticProps/getServerSideProps) has been
|
|
115
|
+
// removed; per-request data is provided by server components (@server),
|
|
116
|
+
// runtime components (@runtime), and middleware instead. The default export
|
|
117
|
+
// is rendered here with no injected page props.
|
|
118
|
+
const props = {};
|
|
156
119
|
// Get the default export (the component)
|
|
157
120
|
const Component = mod.default;
|
|
158
121
|
if (!Component) {
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@krate/runtime",
|
|
3
|
-
"version": "0.3.0-beta.
|
|
3
|
+
"version": "0.3.0-beta.2",
|
|
4
4
|
"description": "Client-side runtime for Krate — signals, hydration, SPA router, resources, and context.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
7
|
-
"homepage": "https://
|
|
7
|
+
"homepage": "https://krate.js.org",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
10
10
|
"url": "https://github.com/kratejs/krate.git"
|