vite-plugin-kiru 0.29.0-preview.2 → 0.29.0
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/index.js +9 -19
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -2206,7 +2206,6 @@ import {
|
|
|
2206
2206
|
render as kiruServerRender,
|
|
2207
2207
|
generateStaticPaths as kiruServerGenerateStaticPaths
|
|
2208
2208
|
} from "kiru/router/server"
|
|
2209
|
-
import { renderToString } from "kiru"
|
|
2210
2209
|
import Document from "${userDoc}"
|
|
2211
2210
|
import { pages, layouts } from "${VIRTUAL_ROUTES_ID}"
|
|
2212
2211
|
|
|
@@ -2222,15 +2221,11 @@ export async function generateStaticPaths() {
|
|
|
2222
2221
|
}
|
|
2223
2222
|
function createEntryClientModule() {
|
|
2224
2223
|
return `
|
|
2225
|
-
import { onLoadedDev } from "kiru/router/dev"
|
|
2226
2224
|
import { initClient } from "kiru/router/client"
|
|
2227
2225
|
import { dir, baseUrl, pages, layouts } from "${VIRTUAL_ROUTES_ID}"
|
|
2228
|
-
import "${resolveUserDocument2()}"
|
|
2226
|
+
import "${resolveUserDocument2()}"
|
|
2229
2227
|
|
|
2230
2228
|
initClient({ dir, baseUrl, pages, layouts })
|
|
2231
|
-
if (import.meta.env.DEV) {
|
|
2232
|
-
onLoadedDev()
|
|
2233
|
-
}
|
|
2234
2229
|
`;
|
|
2235
2230
|
}
|
|
2236
2231
|
return {
|
|
@@ -3260,6 +3255,8 @@ async function handleSSR(server, url, projectRoot, resolveUserDocument2) {
|
|
|
3260
3255
|
VIRTUAL_ENTRY_SERVER_ID
|
|
3261
3256
|
);
|
|
3262
3257
|
const moduleIds = [];
|
|
3258
|
+
const documentModule = resolveUserDocument2().substring(projectRoot.length);
|
|
3259
|
+
moduleIds.push(documentModule);
|
|
3263
3260
|
const ctx = {
|
|
3264
3261
|
registerModule: (moduleId) => {
|
|
3265
3262
|
moduleIds.push(moduleId);
|
|
@@ -3267,12 +3264,10 @@ async function handleSSR(server, url, projectRoot, resolveUserDocument2) {
|
|
|
3267
3264
|
registerPreloadedPageProps: () => {
|
|
3268
3265
|
}
|
|
3269
3266
|
};
|
|
3270
|
-
const { status,
|
|
3271
|
-
let html = injectClientScript(
|
|
3267
|
+
const { status, body } = await mod.render(url, ctx);
|
|
3268
|
+
let html = injectClientScript(body);
|
|
3272
3269
|
const importedModules = /* @__PURE__ */ new Set();
|
|
3273
3270
|
const seen = /* @__PURE__ */ new Set();
|
|
3274
|
-
const documentModule = resolveUserDocument2().substring(projectRoot.length);
|
|
3275
|
-
moduleIds.push(documentModule);
|
|
3276
3271
|
const scan = (mod2) => {
|
|
3277
3272
|
if (importedModules.has(mod2)) return;
|
|
3278
3273
|
importedModules.add(mod2);
|
|
@@ -3307,7 +3302,7 @@ async function handleSSR(server, url, projectRoot, resolveUserDocument2) {
|
|
|
3307
3302
|
});
|
|
3308
3303
|
html = html.replace("<head>", "<head>" + stylesheets.join("\n"));
|
|
3309
3304
|
}
|
|
3310
|
-
return { status, html
|
|
3305
|
+
return { status, html };
|
|
3311
3306
|
}
|
|
3312
3307
|
|
|
3313
3308
|
// src/preview-server.ts
|
|
@@ -4660,7 +4655,7 @@ async function renderRoute(state, mod, route, srcFilePath, clientEntry, cssLinks
|
|
|
4660
4655
|
}
|
|
4661
4656
|
};
|
|
4662
4657
|
const result = await mod.render(route, ctx);
|
|
4663
|
-
let html = result.
|
|
4658
|
+
let html = result.body;
|
|
4664
4659
|
if (clientEntry) {
|
|
4665
4660
|
const scriptTag = `<script type="module" src="/${clientEntry}"></script>`;
|
|
4666
4661
|
const headInjected = cssLinks ? html.replace("<head>", "<head>" + cssLinks) : html;
|
|
@@ -4827,7 +4822,7 @@ function kiru(opts = {}) {
|
|
|
4827
4822
|
}
|
|
4828
4823
|
const accept = req.headers["accept"] || "";
|
|
4829
4824
|
if (typeof accept === "string" && accept.includes("text/html") && !url.startsWith("/node_modules/") && !url.startsWith("/@") && !url.startsWith(dtHostScriptPath) && !url.startsWith(dtClientPathname)) {
|
|
4830
|
-
const { status, html
|
|
4825
|
+
const { status, html } = await handleSSR(
|
|
4831
4826
|
server,
|
|
4832
4827
|
url,
|
|
4833
4828
|
state.projectRoot,
|
|
@@ -4835,12 +4830,7 @@ function kiru(opts = {}) {
|
|
|
4835
4830
|
);
|
|
4836
4831
|
res.statusCode = status;
|
|
4837
4832
|
res.setHeader("Content-Type", "text/html");
|
|
4838
|
-
res.
|
|
4839
|
-
if (stream) {
|
|
4840
|
-
stream.pipe(res);
|
|
4841
|
-
} else {
|
|
4842
|
-
res.end();
|
|
4843
|
-
}
|
|
4833
|
+
res.end(html);
|
|
4844
4834
|
return;
|
|
4845
4835
|
}
|
|
4846
4836
|
} catch (e) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-plugin-kiru",
|
|
3
|
-
"version": "0.29.0
|
|
3
|
+
"version": "0.29.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"author": "",
|
|
10
10
|
"license": "ISC",
|
|
11
11
|
"peerDependencies": {
|
|
12
|
-
"kiru": ">=0.51.0
|
|
12
|
+
"kiru": ">=0.51.0"
|
|
13
13
|
},
|
|
14
14
|
"devDependencies": {
|
|
15
15
|
"@types/node": "^22.17.0",
|