@kimesh/kit 0.2.42 → 0.2.43

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.
Files changed (2) hide show
  1. package/dist/index.mjs +18 -6
  2. package/package.json +4 -4
package/dist/index.mjs CHANGED
@@ -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 lang="en">
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(configRoot, "index.html"), generateHtml(config.name || "Kimesh App"), "utf-8");
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,
@@ -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) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kimesh/kit",
3
- "version": "0.2.42",
3
+ "version": "0.2.43",
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": "0.2.42",
31
- "@kimesh/layers": "0.2.42",
32
- "@kimesh/router-generator": "0.2.42",
30
+ "@kimesh/auto-import": "0.2.43",
31
+ "@kimesh/layers": "0.2.43",
32
+ "@kimesh/router-generator": "0.2.43",
33
33
  "@vitejs/plugin-vue": "^6.0.4",
34
34
  "c12": "^3.3.3",
35
35
  "consola": "^3.4.2",