clarusjs 0.7.0 → 0.8.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.
Files changed (41) hide show
  1. package/dist/check/generate.js +1 -21
  2. package/dist/cli/check.js +44 -11
  3. package/dist/cli/explain.js +0 -1
  4. package/dist/cli/index.js +0 -1
  5. package/dist/compiler/emit-client.js +1 -11
  6. package/dist/compiler/emit-server.js +1 -2
  7. package/dist/compiler/errors.js +0 -1
  8. package/dist/compiler/html-expr.js +2 -7
  9. package/dist/compiler/index.js +10 -8
  10. package/dist/compiler/ir.d.ts +1 -0
  11. package/dist/compiler/ir.js +9 -14
  12. package/dist/compiler/parse.d.ts +1 -0
  13. package/dist/compiler/parse.js +18 -19
  14. package/dist/compiler/script.js +2 -31
  15. package/dist/compiler/shared.js +0 -5
  16. package/dist/runtime/fragments.js +8 -3
  17. package/dist/runtime/html.d.ts +2 -0
  18. package/dist/runtime/html.js +4 -0
  19. package/dist/runtime/loader.js +39 -2
  20. package/dist/runtime/router.d.ts +1 -1
  21. package/dist/runtime/router.js +9 -8
  22. package/dist/runtime/server.d.ts +1 -1
  23. package/dist/runtime/server.js +1 -1
  24. package/dist/server/handler.d.ts +10 -0
  25. package/dist/server/handler.js +48 -48
  26. package/dist/server/head.d.ts +36 -0
  27. package/dist/server/head.js +129 -0
  28. package/dist/server/manifest.js +0 -3
  29. package/dist/server/modes.js +0 -5
  30. package/dist/server/views.js +0 -7
  31. package/dist/vite/build.d.ts +8 -0
  32. package/dist/vite/build.js +42 -17
  33. package/dist/vite/links.d.ts +2 -0
  34. package/dist/vite/links.js +11 -10
  35. package/dist/vite/manifest.js +2 -10
  36. package/dist/vite/netlify.js +1 -7
  37. package/dist/vite/plugin.d.ts +29 -0
  38. package/dist/vite/plugin.js +99 -73
  39. package/dist/vite/sitemap.d.ts +11 -0
  40. package/dist/vite/sitemap.js +31 -0
  41. package/package.json +4 -2
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Newest commit time (unix seconds) of every file under `dir` that git knows, by absolute path. One `git log` lists
3
+ * commits newest first with the files each touched, so a file's first appearance is its last change. Not a git
4
+ * repository (or no git): an empty map.
5
+ */
6
+ export declare function gitDates(root: string, dir: string): Map<string, number>;
7
+ /** The sitemap: one <url> per page, under the site URL and base; lastmod (unix seconds) as a date when known. */
8
+ export declare function sitemapXml(siteUrl: string, base: string, pages: {
9
+ path: string;
10
+ lastmod: number | undefined;
11
+ }[]): string;
@@ -0,0 +1,31 @@
1
+ import { execFileSync } from 'node:child_process';
2
+ import { resolve } from 'node:path';
3
+ const xml = (s) => s.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
4
+ export function gitDates(root, dir) {
5
+ const dates = new Map();
6
+ let log;
7
+ try {
8
+ log = execFileSync('git', ['log', '--format=%x01%ct', '-z', '--name-only', '--relative', '--', dir], { cwd: root, encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'], maxBuffer: 64 * 1024 * 1024 });
9
+ }
10
+ catch {
11
+ return dates;
12
+ }
13
+ for (const commit of log.split('\x01').slice(1)) {
14
+ const [time, ...files] = commit.split('\0');
15
+ for (const file of files.map((f) => f.replace(/^\n/, '')).filter(Boolean)) {
16
+ const path = resolve(root, file);
17
+ if (!dates.has(path))
18
+ dates.set(path, Number(time));
19
+ }
20
+ }
21
+ return dates;
22
+ }
23
+ export function sitemapXml(siteUrl, base, pages) {
24
+ const root = new URL(/^https?:\/\//i.test(base) ? new URL(base).pathname : base, siteUrl.replace(/\/?$/, '/'));
25
+ const urls = pages.map(({ path, lastmod }) => {
26
+ const loc = new URL(`./${path.slice(1)}`, root).href;
27
+ const date = lastmod === undefined ? '' : `<lastmod>${new Date(lastmod * 1000).toISOString().slice(0, 10)}</lastmod>`;
28
+ return `<url><loc>${xml(loc)}</loc>${date}</url>\n`;
29
+ });
30
+ return `<?xml version="1.0" encoding="UTF-8"?>\n<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">\n${urls.join('')}</urlset>\n`;
31
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clarusjs",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "description": "Clear, compiled views: templates compiled to server HTML, with JavaScript only for interactive islands. SSR, SSG and CSR from one component model, built on Vite.",
5
5
  "license": "MIT",
6
6
  "keywords": [
@@ -77,8 +77,10 @@
77
77
  "vite": "^8.0.0"
78
78
  },
79
79
  "devDependencies": {
80
+ "@tailwindcss/vite": "^4.3.5",
80
81
  "@types/node": "^26.6.6",
81
82
  "happy-dom": "^21.0.4",
83
+ "tailwindcss": "^4.3.5",
82
84
  "typescript": "^7.0.2",
83
85
  "vite": "^8.3.8",
84
86
  "vitest": "^5.1.1"
@@ -87,7 +89,7 @@
87
89
  "access": "public"
88
90
  },
89
91
  "scripts": {
90
- "build": "node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\" && tsc -p tsconfig.build.json",
92
+ "build": "node ../../scripts/build-package.mjs",
91
93
  "test": "vitest run",
92
94
  "typecheck": "tsc --noEmit"
93
95
  }