@kimesh/kit 0.2.41 → 0.2.42-nightly.20260225093905
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.mjs +24 -8
- package/package.json +4 -4
package/dist/index.mjs
CHANGED
|
@@ -5,7 +5,7 @@ import { klona } from "klona/json";
|
|
|
5
5
|
import destr from "destr";
|
|
6
6
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
7
7
|
import consola from "consola";
|
|
8
|
-
import { existsSync, mkdirSync, readFileSync, realpathSync, statSync, writeFileSync } from "node:fs";
|
|
8
|
+
import { existsSync, mkdirSync, readFileSync, realpathSync, statSync, unlinkSync, writeFileSync } from "node:fs";
|
|
9
9
|
import { dirname, isAbsolute, join, resolve } from "node:path";
|
|
10
10
|
import fg from "fast-glob";
|
|
11
11
|
import { basename, dirname as dirname$1, extname, isAbsolute as isAbsolute$1, join as join$1, normalize, relative, resolve as resolve$1 } from "pathe";
|
|
@@ -2332,18 +2332,30 @@ export {}
|
|
|
2332
2332
|
|
|
2333
2333
|
//#endregion
|
|
2334
2334
|
//#region src/vite/html.ts
|
|
2335
|
+
function renderAttrs(attrs) {
|
|
2336
|
+
return Object.entries(attrs).filter(([, v]) => v !== void 0).map(([k, v]) => v === true ? k : `${k}="${v}"`).join(" ");
|
|
2337
|
+
}
|
|
2338
|
+
function renderTags(tag, items) {
|
|
2339
|
+
const selfClosing = tag === "meta" || tag === "link";
|
|
2340
|
+
return items.map((attrs) => {
|
|
2341
|
+
const rendered = renderAttrs(attrs);
|
|
2342
|
+
return selfClosing ? ` <${tag} ${rendered}>` : ` <${tag} ${rendered}></${tag}>`;
|
|
2343
|
+
}).join("\n");
|
|
2344
|
+
}
|
|
2335
2345
|
/**
|
|
2336
2346
|
* Generate the HTML template for a Kimesh app
|
|
2337
2347
|
*/
|
|
2338
|
-
function generateHtml(title) {
|
|
2348
|
+
function generateHtml(title, head) {
|
|
2349
|
+
const htmlAttrs = head?.htmlAttrs ? ` ${renderAttrs(head.htmlAttrs)}` : " lang=\"en\"";
|
|
2350
|
+
const bodyAttrs = head?.bodyAttrs ? ` ${renderAttrs(head.bodyAttrs)}` : "";
|
|
2339
2351
|
return `<!DOCTYPE html>
|
|
2340
|
-
<html
|
|
2352
|
+
<html${htmlAttrs}>
|
|
2341
2353
|
<head>
|
|
2342
2354
|
<meta charset="UTF-8">
|
|
2343
2355
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
2344
|
-
<title>${title}</title
|
|
2356
|
+
<title>${head?.title || title}</title>${head?.meta?.length ? "\n" + renderTags("meta", head.meta) : ""}${head?.link?.length ? "\n" + renderTags("link", head.link) : ""}${head?.script?.length ? "\n" + renderTags("script", head.script) : ""}${head?.style?.length ? "\n" + renderTags("style", head.style) : ""}
|
|
2345
2357
|
</head>
|
|
2346
|
-
<body>
|
|
2358
|
+
<body${bodyAttrs}>
|
|
2347
2359
|
<div id="app"></div>
|
|
2348
2360
|
<script type="module" src="/.kimesh/entry.ts"><\/script>
|
|
2349
2361
|
</body>
|
|
@@ -3468,7 +3480,7 @@ function kimeshPlugin(options = {}) {
|
|
|
3468
3480
|
const nodeModules = resolve$1(workspaceRoot, "node_modules");
|
|
3469
3481
|
if (command === "build") {
|
|
3470
3482
|
if (!existsSync(resolvedDirs.buildDir)) mkdirSync(resolvedDirs.buildDir, { recursive: true });
|
|
3471
|
-
writeFileSync(join$1(
|
|
3483
|
+
writeFileSync(join$1(configRoot, "index.html"), generateHtml(config.name || "Kimesh App", config.app?.head), "utf-8");
|
|
3472
3484
|
const hasContext = existsSync(join$1(resolvedDirs.srcDir, "app.context.ts"));
|
|
3473
3485
|
writeFileSync(join$1(resolvedDirs.buildDir, "entry.ts"), generateEntryCode({
|
|
3474
3486
|
hasContext,
|
|
@@ -3519,7 +3531,7 @@ function kimeshPlugin(options = {}) {
|
|
|
3519
3531
|
target: resolvedBuildConfig.target,
|
|
3520
3532
|
sourcemap: resolvedBuildConfig.sourcemap,
|
|
3521
3533
|
minify: resolvedBuildConfig.minify,
|
|
3522
|
-
rollupOptions: command === "build" ? { input: join$1(
|
|
3534
|
+
rollupOptions: command === "build" ? { input: join$1(configRoot, "index.html") } : void 0
|
|
3523
3535
|
},
|
|
3524
3536
|
optimizeDeps: { exclude: [
|
|
3525
3537
|
"#kimesh/routes",
|
|
@@ -3594,7 +3606,7 @@ function kimeshPlugin(options = {}) {
|
|
|
3594
3606
|
} else consola.debug(`[Kimesh] Layer tsconfig already exists, skipping: ${layerTsConfigPath}`);
|
|
3595
3607
|
}
|
|
3596
3608
|
const htmlPath = join$1(state.generatedDir, "index.html");
|
|
3597
|
-
writeFileSync(htmlPath, generateHtml(config.name || "Kimesh App"), "utf-8");
|
|
3609
|
+
writeFileSync(htmlPath, generateHtml(config.name || "Kimesh App", config.app?.head), "utf-8");
|
|
3598
3610
|
consola.debug(`[Kimesh] Generated HTML file: ${htmlPath}`);
|
|
3599
3611
|
},
|
|
3600
3612
|
configureServer(server) {
|
|
@@ -3615,6 +3627,10 @@ function kimeshPlugin(options = {}) {
|
|
|
3615
3627
|
server.watcher.on("add", handleWatchEvent("add"));
|
|
3616
3628
|
server.watcher.on("unlink", handleWatchEvent("unlink"));
|
|
3617
3629
|
server.middlewares.use(createSpaFallbackMiddleware(server, state.generatedDir));
|
|
3630
|
+
},
|
|
3631
|
+
closeBundle() {
|
|
3632
|
+
const rootHtml = join$1(state.root, "index.html");
|
|
3633
|
+
if (existsSync(rootHtml)) unlinkSync(rootHtml);
|
|
3618
3634
|
}
|
|
3619
3635
|
};
|
|
3620
3636
|
const routerPlugin = kimeshRouterGenerator({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kimesh/kit",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.42-nightly.20260225093905",
|
|
4
4
|
"description": "Build-time engine for Kimesh framework",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -27,9 +27,9 @@
|
|
|
27
27
|
"test:watch": "vitest"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@kimesh/auto-import": "
|
|
31
|
-
"@kimesh/layers": "
|
|
32
|
-
"@kimesh/router-generator": "
|
|
30
|
+
"@kimesh/auto-import": "workspace:*",
|
|
31
|
+
"@kimesh/layers": "workspace:*",
|
|
32
|
+
"@kimesh/router-generator": "workspace:*",
|
|
33
33
|
"@vitejs/plugin-vue": "^6.0.4",
|
|
34
34
|
"c12": "^3.3.3",
|
|
35
35
|
"consola": "^3.4.2",
|