@evjs/create-app 0.1.11 → 0.2.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 (69) hide show
  1. package/README.md +5 -1
  2. package/dist/index.d.ts +3 -0
  3. package/dist/index.js +122 -98
  4. package/package.json +9 -1
  5. package/templates/api-routes/README.md +2 -2
  6. package/templates/api-routes/package.json +4 -4
  7. package/templates/api-routes/src/{pages/__root.tsx → layout/index.tsx} +3 -5
  8. package/templates/api-routes/src/pages/{home.tsx → index.tsx} +1 -9
  9. package/templates/basic/README.md +3 -5
  10. package/templates/basic/package.json +4 -4
  11. package/templates/basic/src/layout/index.tsx +27 -0
  12. package/templates/basic/src/pages/about.tsx +17 -0
  13. package/templates/basic/src/pages/index.tsx +100 -0
  14. package/templates/basic/src/pages/search.tsx +58 -0
  15. package/templates/basic/src/pages/users/$userId.tsx +31 -0
  16. package/templates/complex-routing/README.md +6 -7
  17. package/templates/complex-routing/package.json +4 -4
  18. package/templates/complex-routing/src/api/data.server.ts +1 -1
  19. package/templates/complex-routing/src/{pages/__root.tsx → layout/index.tsx} +4 -5
  20. package/templates/complex-routing/src/pages/dashboard.tsx +2 -23
  21. package/templates/complex-routing/src/pages/index.tsx +31 -0
  22. package/templates/complex-routing/src/pages/old-blog.tsx +9 -0
  23. package/templates/complex-routing/src/pages/posts/$postId.tsx +39 -0
  24. package/templates/complex-routing/src/pages/posts/index.tsx +21 -88
  25. package/templates/complex-routing/src/pages/search.tsx +10 -13
  26. package/templates/complex-routing/src/pages/users/$username.tsx +21 -0
  27. package/templates/custom-ws-transport/README.md +2 -2
  28. package/templates/custom-ws-transport/package.json +4 -4
  29. package/templates/custom-ws-transport/src/{pages/__root.tsx → layout/index.tsx} +4 -5
  30. package/templates/custom-ws-transport/src/pages/{home.tsx → index.tsx} +2 -9
  31. package/templates/mpa/README.md +8 -6
  32. package/templates/mpa/ev.config.ts +2 -3
  33. package/templates/mpa/package.json +2 -2
  34. package/templates/mpa/src/pages/about.tsx +13 -0
  35. package/templates/mpa/src/pages/home.tsx +13 -0
  36. package/templates/plugin-authoring/README.md +2 -2
  37. package/templates/plugin-authoring/ev.config.ts +11 -12
  38. package/templates/plugin-authoring/package.json +5 -4
  39. package/templates/plugin-authoring/src/layout/index.tsx +9 -0
  40. package/templates/plugin-authoring/src/pages/{home.tsx → index.tsx} +2 -9
  41. package/templates/with-sqlite/README.md +2 -1
  42. package/templates/with-sqlite/package.json +4 -4
  43. package/templates/with-sqlite/src/api/db.server.ts +103 -23
  44. package/templates/with-sqlite/src/{pages/__root.tsx → layout/index.tsx} +4 -5
  45. package/templates/with-sqlite/src/pages/{home.tsx → index.tsx} +1 -9
  46. package/templates/with-tailwind/ev.config.ts +3 -1
  47. package/templates/with-tailwind/package.json +3 -4
  48. package/templates/with-tailwind/src/{pages/__root.tsx → layout/index.tsx} +4 -7
  49. package/templates/with-tailwind/src/pages/{home.tsx → index.tsx} +17 -31
  50. package/templates/with-trpc/README.md +2 -1
  51. package/templates/with-trpc/package.json +4 -4
  52. package/templates/with-trpc/src/{pages/__root.tsx → layout/index.tsx} +3 -7
  53. package/templates/with-trpc/src/pages/{home.tsx → index.tsx} +2 -9
  54. package/templates/api-routes/src/main.tsx +0 -15
  55. package/templates/basic/src/main.tsx +0 -37
  56. package/templates/basic/src/pages/__root.tsx +0 -49
  57. package/templates/basic/src/pages/home.tsx +0 -207
  58. package/templates/complex-routing/src/main.tsx +0 -29
  59. package/templates/complex-routing/src/pages/catch.tsx +0 -26
  60. package/templates/complex-routing/src/pages/home.tsx +0 -35
  61. package/templates/complex-routing/src/pages/user.tsx +0 -28
  62. package/templates/custom-ws-transport/src/main.tsx +0 -15
  63. package/templates/mpa/src/about/main.tsx +0 -23
  64. package/templates/mpa/src/home/main.tsx +0 -23
  65. package/templates/plugin-authoring/src/main.tsx +0 -15
  66. package/templates/plugin-authoring/src/pages/__root.tsx +0 -13
  67. package/templates/with-sqlite/src/main.tsx +0 -15
  68. package/templates/with-tailwind/src/main.tsx +0 -15
  69. package/templates/with-trpc/src/main.tsx +0 -15
@@ -1,6 +1,6 @@
1
1
  # complex-routing
2
2
 
3
- Advanced routing patterns with TanStack Router.
3
+ Advanced SPA page routing patterns.
4
4
 
5
5
  ## Run
6
6
 
@@ -12,16 +12,15 @@ npm run dev
12
12
 
13
13
  | File | Purpose |
14
14
  |------|---------|
15
- | `src/main.tsx` | Route tree assembly |
16
- | `src/pages/__root.tsx` | Root layout with navigation |
17
- | `src/pages/home.tsx` | Index route |
18
- | `src/pages/posts/` | Nested routes with loader |
15
+ | `src/layout/index.tsx` | SPA root layout with navigation |
16
+ | `src/pages/index.tsx` | Index route |
17
+ | `src/pages/posts/` | Nested paths with loaders |
19
18
 
20
19
  ## What It Demonstrates
21
20
 
22
21
  - Dynamic route params (`$postId`)
23
- - Pathless layout routes
22
+ - SPA root layout
24
23
  - Route loaders with `queryClient.ensureQueryData`
25
24
  - Search params with `validateSearch`
26
25
  - Catch-all 404 route
27
- - Type-safe `route.useParams()`
26
+ - Page hooks such as `usePageParams()` and `usePageSearch()`
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "example-complex-routing",
3
- "version": "0.1.11",
3
+ "version": "0.2.0",
4
4
  "private": true,
5
5
  "scripts": {
6
6
  "dev": "ev dev",
@@ -8,14 +8,14 @@
8
8
  "check-types": "tsc --noEmit"
9
9
  },
10
10
  "dependencies": {
11
+ "@evjs/client": "*",
12
+ "@evjs/ev": "*",
13
+ "@evjs/server": "*",
11
14
  "react": "^19.2.4",
12
15
  "react-dom": "^19.2.4"
13
16
  },
14
17
  "devDependencies": {
15
18
  "@evjs/cli": "*",
16
- "@evjs/client": "*",
17
- "@evjs/ev": "*",
18
- "@evjs/server": "*",
19
19
  "@types/react": "^19.1.8",
20
20
  "@types/react-dom": "^19.1.8",
21
21
  "typescript": "^6.0.2"
@@ -20,7 +20,7 @@ const posts = [
20
20
  {
21
21
  id: "3",
22
22
  title: "Routing Patterns",
23
- body: "evjs uses TanStack Router for type-safe routing...",
23
+ body: "evjs keeps route params and navigation type-safe while pages stay simple...",
24
24
  author: "alice",
25
25
  tags: ["routing", "tutorial"],
26
26
  },
@@ -1,4 +1,5 @@
1
- import { createAppRootRoute, Link, Outlet } from "@evjs/client";
1
+ import { Link } from "@evjs/client";
2
+ import type { ReactNode } from "react";
2
3
 
3
4
  const styles = {
4
5
  app: {
@@ -18,7 +19,7 @@ const styles = {
18
19
  activeLink: { color: "#111", fontWeight: 600 as const },
19
20
  };
20
21
 
21
- function RootLayout() {
22
+ export default function RootLayout({ children }: { children?: ReactNode }) {
22
23
  return (
23
24
  <div style={styles.app}>
24
25
  <nav style={styles.nav}>
@@ -52,9 +53,7 @@ function RootLayout() {
52
53
  Search
53
54
  </Link>
54
55
  </nav>
55
- <Outlet />
56
+ {children}
56
57
  </div>
57
58
  );
58
59
  }
59
-
60
- export const rootRoute = createAppRootRoute({ component: RootLayout });
@@ -1,6 +1,5 @@
1
- import { createRoute, Outlet, useQuery } from "@evjs/client";
1
+ import { useQuery } from "@evjs/client";
2
2
  import { getStats } from "../api/data.server";
3
- import { rootRoute } from "./__root";
4
3
 
5
4
  const styles = {
6
5
  card: {
@@ -20,21 +19,7 @@ const styles = {
20
19
  },
21
20
  };
22
21
 
23
- // ── Pathless layout (no URL segment, just shared UI) ──
24
-
25
- export const dashboardLayout = createRoute({
26
- getParentRoute: () => rootRoute,
27
- id: "dashboard-layout",
28
- component: () => (
29
- <div>
30
- <Outlet />
31
- </div>
32
- ),
33
- });
34
-
35
- // ── Dashboard page (/dashboard) ──
36
-
37
- function Dashboard() {
22
+ export default function Dashboard() {
38
23
  const { data: stats } = useQuery(getStats);
39
24
  if (!stats) return <p>Loading...</p>;
40
25
  return (
@@ -71,9 +56,3 @@ function Dashboard() {
71
56
  </div>
72
57
  );
73
58
  }
74
-
75
- export const dashboardRoute = createRoute({
76
- getParentRoute: () => dashboardLayout,
77
- path: "/dashboard",
78
- component: Dashboard,
79
- });
@@ -0,0 +1,31 @@
1
+ import { Link } from "@evjs/client";
2
+
3
+ export default function HomePage() {
4
+ return (
5
+ <div>
6
+ <h1>evjs Complex Routing Example</h1>
7
+ <p>
8
+ Demonstrates page routing, dynamic params, search params, redirects, and
9
+ server function data.
10
+ </p>
11
+ <ul>
12
+ <li>
13
+ <Link to="/posts">Posts</Link> - post list and dynamic{" "}
14
+ <code>$postId</code> pages
15
+ </li>
16
+ <li>
17
+ <Link to="/dashboard">Dashboard</Link> - server function data
18
+ </li>
19
+ <li>
20
+ <Link to="/search" search={{ q: "tutorial" }}>
21
+ Search
22
+ </Link>{" "}
23
+ - search params
24
+ </li>
25
+ <li>
26
+ <Link to="/old-blog">Old Blog</Link> - redirect to /posts
27
+ </li>
28
+ </ul>
29
+ </div>
30
+ );
31
+ }
@@ -0,0 +1,9 @@
1
+ import { redirect } from "@evjs/client";
2
+
3
+ export function beforeLoad() {
4
+ throw redirect({ to: "/posts" });
5
+ }
6
+
7
+ export default function OldBlogRedirect() {
8
+ return null;
9
+ }
@@ -0,0 +1,39 @@
1
+ import { Link, usePageParams, useQuery } from "@evjs/client";
2
+ import { getPost } from "../../api/data.server";
3
+
4
+ const styles = {
5
+ tag: {
6
+ display: "inline-block",
7
+ background: "#f3f4f6",
8
+ borderRadius: 4,
9
+ padding: "2px 8px",
10
+ fontSize: 12,
11
+ marginRight: 4,
12
+ },
13
+ };
14
+
15
+ export default function PostDetail() {
16
+ const { postId } = usePageParams();
17
+ const { data: post } = useQuery(getPost, postId);
18
+
19
+ if (!post) return <p>Loading...</p>;
20
+ return (
21
+ <div>
22
+ <h2>{post.title}</h2>
23
+ <p style={{ color: "#6b7280" }}>
24
+ by{" "}
25
+ <Link to="/users/$username" params={{ username: post.author }}>
26
+ {post.author}
27
+ </Link>
28
+ </p>
29
+ <p>{post.body}</p>
30
+ <div>
31
+ {post.tags.map((tag) => (
32
+ <span key={tag} style={styles.tag}>
33
+ {tag}
34
+ </span>
35
+ ))}
36
+ </div>
37
+ </div>
38
+ );
39
+ }
@@ -1,100 +1,33 @@
1
- import { createRoute, Link, Outlet, useQuery } from "@evjs/client";
2
- import { getPost, getPosts } from "../../api/data.server";
3
- import { rootRoute } from "../__root";
1
+ import { Link, useQuery } from "@evjs/client";
2
+ import { getPosts } from "../../api/data.server";
4
3
 
5
4
  const styles = {
6
- sidebar: { display: "flex", gap: "1.5rem" },
7
- nav: {
8
- minWidth: 180,
9
- borderRight: "1px solid #e5e7eb",
10
- paddingRight: "1rem",
11
- },
12
- tag: {
13
- display: "inline-block",
14
- background: "#f3f4f6",
15
- borderRadius: 4,
16
- padding: "2px 8px",
17
- fontSize: 12,
18
- marginRight: 4,
5
+ card: {
6
+ border: "1px solid #e5e7eb",
7
+ borderRadius: 8,
8
+ padding: "1rem",
9
+ marginBottom: "0.75rem",
19
10
  },
20
11
  };
21
12
 
22
- // ── Posts layout (/posts) ──
23
-
24
- function PostsLayout() {
13
+ export default function PostsPage() {
25
14
  const { data: posts } = useQuery(getPosts);
26
- return (
27
- <div style={styles.sidebar}>
28
- <div style={styles.nav}>
29
- <h3 style={{ marginTop: 0 }}>Posts</h3>
30
- <ul style={{ listStyle: "none", padding: 0 }}>
31
- {posts?.map((p) => (
32
- <li key={p.id} style={{ marginBottom: "0.25rem" }}>
33
- <Link
34
- to="/posts/$postId"
35
- params={{ postId: p.id }}
36
- style={{ textDecoration: "none", color: "#374151" }}
37
- activeProps={{ style: { fontWeight: "bold", color: "#111" } }}
38
- >
39
- {p.title}
40
- </Link>
41
- </li>
42
- ))}
43
- </ul>
44
- </div>
45
- <div style={{ flex: 1 }}>
46
- <Outlet />
47
- </div>
48
- </div>
49
- );
50
- }
51
15
 
52
- export const postsRoute = createRoute({
53
- getParentRoute: () => rootRoute,
54
- path: "/posts",
55
- component: PostsLayout,
56
- });
57
-
58
- // ── Posts index (/posts/) ──
59
-
60
- export const postsIndexRoute = createRoute({
61
- getParentRoute: () => postsRoute,
62
- path: "/",
63
- component: () => (
64
- <p style={{ color: "#6b7280" }}>← Select a post from the sidebar</p>
65
- ),
66
- });
67
-
68
- // ── Post detail (/posts/$postId) ──
69
-
70
- function PostDetail() {
71
- const { postId } = postDetailRoute.useParams();
72
- const { data: post } = useQuery(getPost, postId);
73
-
74
- if (!post) return <p>Loading...</p>;
75
16
  return (
76
17
  <div>
77
- <h2>{post.title}</h2>
78
- <p style={{ color: "#6b7280" }}>
79
- by{" "}
80
- <Link to="/users/$username" params={{ username: post.author }}>
81
- {post.author}
82
- </Link>
83
- </p>
84
- <p>{post.body}</p>
85
- <div>
86
- {post.tags.map((tag) => (
87
- <span key={tag} style={styles.tag}>
88
- {tag}
89
- </span>
90
- ))}
91
- </div>
18
+ <h2>Posts</h2>
19
+ {posts?.map((post) => (
20
+ <div key={post.id} style={styles.card}>
21
+ <Link
22
+ to="/posts/$postId"
23
+ params={{ postId: post.id }}
24
+ style={{ textDecoration: "none", color: "#111" }}
25
+ >
26
+ <strong>{post.title}</strong>
27
+ </Link>
28
+ <p style={{ color: "#6b7280" }}>{post.body}</p>
29
+ </div>
30
+ ))}
92
31
  </div>
93
32
  );
94
33
  }
95
-
96
- export const postDetailRoute = createRoute({
97
- getParentRoute: () => postsRoute,
98
- path: "$postId",
99
- component: PostDetail,
100
- });
@@ -1,6 +1,5 @@
1
- import { createRoute, Link, useQuery } from "@evjs/client";
1
+ import { Link, usePageSearch, useQuery } from "@evjs/client";
2
2
  import { getPosts } from "../api/data.server";
3
- import { rootRoute } from "./__root";
4
3
 
5
4
  const styles = {
6
5
  card: {
@@ -11,8 +10,15 @@ const styles = {
11
10
  },
12
11
  };
13
12
 
14
- function SearchPage() {
15
- const { q } = searchRoute.useSearch();
13
+ export function validateSearch(search: Record<string, unknown>) {
14
+ return {
15
+ q: (search.q as string) || "",
16
+ };
17
+ }
18
+
19
+ export default function SearchPage() {
20
+ const search = usePageSearch();
21
+ const q = typeof search.q === "string" ? search.q : "";
16
22
  const { data: results } = useQuery(getPosts, q || undefined);
17
23
 
18
24
  return (
@@ -60,12 +66,3 @@ function SearchPage() {
60
66
  </div>
61
67
  );
62
68
  }
63
-
64
- export const searchRoute = createRoute({
65
- getParentRoute: () => rootRoute,
66
- path: "/search",
67
- validateSearch: (search: Record<string, unknown>) => ({
68
- q: (search.q as string) || "",
69
- }),
70
- component: SearchPage,
71
- });
@@ -0,0 +1,21 @@
1
+ import { Link, usePageParams, useQuery } from "@evjs/client";
2
+ import { getUser } from "../../api/data.server";
3
+
4
+ const styles = {
5
+ card: { border: "1px solid #e5e7eb", borderRadius: 8, padding: "1rem" },
6
+ };
7
+
8
+ export default function UserProfile() {
9
+ const { username } = usePageParams();
10
+ const { data: user } = useQuery(getUser, username);
11
+
12
+ if (!user) return <p>Loading...</p>;
13
+ return (
14
+ <div style={styles.card}>
15
+ <h2>{user.name}</h2>
16
+ <p style={{ color: "#6b7280" }}>@{user.username}</p>
17
+ <p>{user.bio}</p>
18
+ <Link to="/posts">Back to posts</Link>
19
+ </div>
20
+ );
21
+ }
@@ -12,8 +12,8 @@ npm run dev
12
12
 
13
13
  | File | Purpose |
14
14
  |------|---------|
15
- | `src/main.tsx` | `initTransport` with WebSocket adapter |
16
- | `src/routes.tsx` | UI with users CRUD |
15
+ | `src/layout/index.tsx` | SPA root layout |
16
+ | `src/pages/index.tsx` | `initTransport` with WebSocket adapter and users CRUD UI |
17
17
  | `src/api/users.server.ts` | Server functions |
18
18
 
19
19
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "example-custom-ws-transport",
3
- "version": "0.1.11",
3
+ "version": "0.2.0",
4
4
  "private": true,
5
5
  "scripts": {
6
6
  "dev": "ev dev",
@@ -8,14 +8,14 @@
8
8
  "check-types": "tsc --noEmit"
9
9
  },
10
10
  "dependencies": {
11
+ "@evjs/client": "*",
12
+ "@evjs/ev": "*",
13
+ "@evjs/server": "*",
11
14
  "react": "^19.2.4",
12
15
  "react-dom": "^19.2.4"
13
16
  },
14
17
  "devDependencies": {
15
18
  "@evjs/cli": "*",
16
- "@evjs/client": "*",
17
- "@evjs/ev": "*",
18
- "@evjs/server": "*",
19
19
  "@types/react": "^19.1.8",
20
20
  "@types/react-dom": "^19.1.8",
21
21
  "@types/ws": "^8.18.1",
@@ -1,15 +1,14 @@
1
- import { createRootRoute, Link, Outlet } from "@evjs/client";
1
+ import { Link } from "@evjs/client";
2
+ import type { ReactNode } from "react";
2
3
 
3
- function Root() {
4
+ export default function Root({ children }: { children?: ReactNode }) {
4
5
  return (
5
6
  <div style={{ fontFamily: "system-ui, sans-serif", padding: "1rem" }}>
6
7
  <h1>Server Functions Example (WebSocket)</h1>
7
8
  <nav style={{ display: "flex", gap: "1rem", marginBottom: "1rem" }}>
8
9
  <Link to="/">Users</Link>
9
10
  </nav>
10
- <Outlet />
11
+ {children}
11
12
  </div>
12
13
  );
13
14
  }
14
-
15
- export const rootRoute = createRootRoute({ component: Root });
@@ -1,7 +1,6 @@
1
- import { createRoute, initTransport } from "@evjs/client";
1
+ import { initTransport } from "@evjs/client";
2
2
  import { useEffect, useState } from "react";
3
3
  import { createUser, getUsers } from "../api/users.server";
4
- import { rootRoute } from "./__root";
5
4
 
6
5
  // ── WebSocket Adapter ──
7
6
 
@@ -73,7 +72,7 @@ initTransport({
73
72
 
74
73
  // ── Users Page ──
75
74
 
76
- function UsersPage() {
75
+ export default function UsersPage() {
77
76
  const [name, setName] = useState("");
78
77
  const [email, setEmail] = useState("");
79
78
 
@@ -144,9 +143,3 @@ function UsersPage() {
144
143
  </div>
145
144
  );
146
145
  }
147
-
148
- export const usersRoute = createRoute({
149
- getParentRoute: () => rootRoute,
150
- path: "/",
151
- component: UsersPage,
152
- });
@@ -1,6 +1,6 @@
1
1
  # mpa
2
2
 
3
- Minimal multi-page application example using evjs `pages` config.
3
+ Minimal multi-page application example using evjs page routing.
4
4
 
5
5
  ## Run
6
6
 
@@ -18,14 +18,16 @@ npm run build
18
18
 
19
19
  | File | Purpose |
20
20
  |------|---------|
21
- | `ev.config.ts` | Enables MPA mode and defines page entries |
21
+ | `ev.config.ts` | Enables page MPA mode |
22
22
  | `index.html` | Shared HTML template for all pages |
23
- | `src/home/main.tsx` | Home page React entry |
24
- | `src/about/main.tsx` | About page React entry |
23
+ | `src/pages/home.tsx` | Home page component |
24
+ | `src/pages/about.tsx` | About page component |
25
25
 
26
26
  ## What It Demonstrates
27
27
 
28
- - Multi-page build via `pages`
29
- - Independent React entry for each page
28
+ - Multi-page build via `routing.mode: "mpa"`
29
+ - Independent router-free React page for each page file
30
30
  - Shared HTML template reused by all pages
31
31
  - Static links between pages
32
+ - No `@evjs/client`, `@evjs/server`, or generated `evjs-route-types.d.ts`
33
+ dependency is needed for this router-free client output
@@ -3,8 +3,7 @@ import { defineConfig } from "@evjs/ev";
3
3
  export default defineConfig({
4
4
  server: false,
5
5
  html: "./index.html",
6
- pages: {
7
- home: "./src/home/main.tsx",
8
- about: "./src/about/main.tsx",
6
+ routing: {
7
+ mode: "mpa",
9
8
  },
10
9
  });
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "example-mpa",
3
- "version": "0.1.11",
3
+ "version": "0.2.0",
4
4
  "private": true,
5
5
  "scripts": {
6
6
  "dev": "ev dev",
@@ -8,12 +8,12 @@
8
8
  "check-types": "tsc --noEmit"
9
9
  },
10
10
  "dependencies": {
11
+ "@evjs/ev": "*",
11
12
  "react": "^19.2.4",
12
13
  "react-dom": "^19.2.4"
13
14
  },
14
15
  "devDependencies": {
15
16
  "@evjs/cli": "*",
16
- "@evjs/ev": "*",
17
17
  "@types/react": "^19.1.8",
18
18
  "@types/react-dom": "^19.1.8",
19
19
  "typescript": "^6.0.2"
@@ -0,0 +1,13 @@
1
+ export default function AboutPage() {
2
+ return (
3
+ <main style={{ fontFamily: "ui-sans-serif, system-ui", margin: "2rem" }}>
4
+ <h1>About Page</h1>
5
+ <p>
6
+ This page is rendered from <code>src/pages/about.tsx</code>.
7
+ </p>
8
+ <p>
9
+ <a href="/home.html">Back to Home page</a>
10
+ </p>
11
+ </main>
12
+ );
13
+ }
@@ -0,0 +1,13 @@
1
+ export default function HomePage() {
2
+ return (
3
+ <main style={{ fontFamily: "ui-sans-serif, system-ui", margin: "2rem" }}>
4
+ <h1>Home Page</h1>
5
+ <p>
6
+ This page is rendered from <code>src/pages/home.tsx</code>.
7
+ </p>
8
+ <p>
9
+ <a href="/about.html">Go to About page</a>
10
+ </p>
11
+ </main>
12
+ );
13
+ }
@@ -5,7 +5,7 @@ Demonstrates the evjs plugin system with all available hooks:
5
5
  - **`bundlerConfig`** — modify the underlying bundler config (type-safe via `utoopack()` helper)
6
6
  - **`buildStart`** — run logic before compilation begins
7
7
  - **`buildEnd`** — run logic after compilation completes
8
- - **`transformHtml`** — modify the parsed HTML document after asset injection
8
+ - **`transformHtml`** — modify the parsed HTML document after asset injection with current HTML context
9
9
 
10
10
  ## Run
11
11
 
@@ -16,5 +16,5 @@ npm run dev
16
16
  ## What to look for
17
17
 
18
18
  1. Console output from `buildStart` and `buildEnd` hooks during build
19
- 2. The `<!-- Built with evjs | N asset(s) -->` comment in the output HTML (injected by `transformHtml`)
19
+ 2. The `<!-- Built with evjs | file.html | N asset(s) -->` comment in the output HTML (injected by `transformHtml`)
20
20
  3. `.txt` file support added via the `bundlerConfig` hook (utoopack raw rule)
@@ -18,12 +18,7 @@ export default defineConfig({
18
18
  config(config) {
19
19
  config.server = {
20
20
  ...(typeof config.server === "object" ? config.server : {}),
21
- functions: {
22
- ...(typeof config.server === "object"
23
- ? config.server.functions
24
- : {}),
25
- endpoint: "/api/rpc",
26
- },
21
+ basePath: "/api",
27
22
  };
28
23
  return config;
29
24
  },
@@ -45,19 +40,23 @@ export default defineConfig({
45
40
  }),
46
41
 
47
42
  buildEnd(result) {
43
+ const appAssets = Object.values(result.output.apps);
44
+ const pageAssets = Object.values(result.output.pages);
45
+ const jsCount = [...appAssets, ...pageAssets].reduce(
46
+ (count, entry) => count + entry.assets.js.length,
47
+ 0,
48
+ );
48
49
  console.log(
49
- `[example-txt-plugin] build complete — ${result.clientManifest.assets.js.length} JS asset(s)`,
50
+ `[example-txt-plugin] build complete — ${jsCount} JS asset(s)`,
50
51
  );
51
52
  },
52
53
 
53
54
  // Modify the parsed HTML document after evjs injects script/link tags
54
- transformHtml(doc, result) {
55
- const assetCount =
56
- result.clientManifest.assets.js.length +
57
- result.clientManifest.assets.css.length;
55
+ transformHtml(doc, ctx) {
56
+ const assetCount = ctx.assets.js.length + ctx.assets.css.length;
58
57
 
59
58
  const comment = doc.createComment(
60
- ` Built with evjs | ${assetCount} asset(s) `,
59
+ ` Built with evjs | ${ctx.fileName} | ${assetCount} asset(s) `,
61
60
  );
62
61
  doc.head?.appendChild(comment);
63
62
  },
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "example-plugin-authoring",
3
- "version": "0.1.11",
3
+ "version": "0.2.0",
4
4
  "private": true,
5
5
  "scripts": {
6
6
  "dev": "ev dev",
@@ -8,14 +8,15 @@
8
8
  "check-types": "tsc --noEmit"
9
9
  },
10
10
  "dependencies": {
11
+ "@evjs/client": "*",
12
+ "@evjs/ev": "*",
13
+ "@evjs/server": "*",
11
14
  "react": "^19.2.4",
12
15
  "react-dom": "^19.2.4"
13
16
  },
14
17
  "devDependencies": {
18
+ "@evjs/bundler-utoopack": "*",
15
19
  "@evjs/cli": "*",
16
- "@evjs/client": "*",
17
- "@evjs/ev": "*",
18
- "@evjs/server": "*",
19
20
  "@types/react": "^19.1.8",
20
21
  "@types/react-dom": "^19.1.8",
21
22
  "typescript": "^6.0.2"