@evjs/create-app 0.2.16 → 0.3.1

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 (71) hide show
  1. package/README.md +16 -6
  2. package/dist/index.js +1 -1
  3. package/package.json +1 -1
  4. package/templates/api-routes/README.md +11 -7
  5. package/templates/api-routes/ev.config.ts +5 -0
  6. package/templates/api-routes/package.json +1 -1
  7. package/templates/api-routes/src/apis/api/posts/{$id.ts → $id/api.ts} +2 -4
  8. package/templates/api-routes/src/apis/api/{posts.ts → posts/api.ts} +1 -1
  9. package/templates/api-routes/src/apis/api/{posts-store.ts → posts/posts-store.ts} +1 -1
  10. package/templates/api-routes/src/{layout/index.tsx → pages/layout.tsx} +2 -1
  11. package/templates/basic/README.md +22 -4
  12. package/templates/basic/ev.config.ts +1 -1
  13. package/templates/basic/package.json +1 -1
  14. package/templates/basic/src/pages/about/components/RouteCard.tsx +15 -0
  15. package/templates/basic/src/pages/about/page.config.ts +9 -0
  16. package/templates/basic/src/pages/about/page.tsx +14 -0
  17. package/templates/basic/src/pages/components/index.tsx +8 -0
  18. package/templates/basic/src/pages/page.config.ts +12 -0
  19. package/templates/basic/src/pages/{index.tsx → page.tsx} +4 -2
  20. package/templates/complex-routing/README.md +17 -8
  21. package/templates/complex-routing/ev.config.ts +5 -0
  22. package/templates/complex-routing/package.json +1 -1
  23. package/templates/custom-ws-transport/README.md +12 -5
  24. package/templates/custom-ws-transport/ev.config.ts +5 -0
  25. package/templates/custom-ws-transport/package.json +1 -1
  26. package/templates/mpa/README.md +30 -10
  27. package/templates/mpa/ev.config.ts +1 -8
  28. package/templates/mpa/package.json +1 -1
  29. package/templates/mpa/src/pages/about/page.config.ts +12 -0
  30. package/templates/mpa/src/pages/{about.tsx → about/page.tsx} +2 -2
  31. package/templates/mpa/src/pages/components/PageScopeNote.tsx +8 -0
  32. package/templates/mpa/src/pages/page.config.ts +12 -0
  33. package/templates/mpa/src/pages/{home.tsx → page.tsx} +5 -2
  34. package/templates/plugin-authoring/README.md +26 -5
  35. package/templates/plugin-authoring/ev.config.ts +66 -0
  36. package/templates/plugin-authoring/package.json +1 -1
  37. package/templates/plugin-authoring/src/pages/page.config.ts +16 -0
  38. package/templates/with-sqlite/README.md +3 -2
  39. package/templates/with-sqlite/ev.config.ts +5 -0
  40. package/templates/with-sqlite/package.json +1 -1
  41. package/templates/with-tailwind/README.md +20 -0
  42. package/templates/with-tailwind/ev.config.ts +2 -5
  43. package/templates/with-tailwind/package.json +1 -1
  44. package/templates/with-tailwind/src/pages/{index.tsx → page.tsx} +4 -2
  45. package/templates/with-trpc/README.md +6 -4
  46. package/templates/with-trpc/ev.config.ts +5 -0
  47. package/templates/with-trpc/package.json +1 -1
  48. package/templates/basic/src/pages/about.tsx +0 -17
  49. /package/templates/api-routes/src/apis/api/{health.ts → health/api.ts} +0 -0
  50. /package/templates/api-routes/src/pages/{index.tsx → page.tsx} +0 -0
  51. /package/templates/basic/src/{layout/index.tsx → pages/layout.tsx} +0 -0
  52. /package/templates/basic/src/pages/{search.tsx → search/page.tsx} +0 -0
  53. /package/templates/basic/src/pages/users/{$userId.tsx → $userId/page.tsx} +0 -0
  54. /package/templates/complex-routing/src/pages/{dashboard.tsx → dashboard/page.tsx} +0 -0
  55. /package/templates/complex-routing/src/{layout/index.tsx → pages/layout.tsx} +0 -0
  56. /package/templates/complex-routing/src/pages/{old-blog.tsx → old-blog/page.tsx} +0 -0
  57. /package/templates/complex-routing/src/pages/{index.tsx → page.tsx} +0 -0
  58. /package/templates/complex-routing/src/pages/posts/{$postId.tsx → $postId/page.tsx} +0 -0
  59. /package/templates/complex-routing/src/pages/posts/{index.tsx → page.tsx} +0 -0
  60. /package/templates/complex-routing/src/pages/{search.tsx → search/page.tsx} +0 -0
  61. /package/templates/complex-routing/src/pages/users/{$username.tsx → $username/page.tsx} +0 -0
  62. /package/templates/custom-ws-transport/src/{layout/index.tsx → pages/layout.tsx} +0 -0
  63. /package/templates/custom-ws-transport/src/pages/{index.tsx → page.tsx} +0 -0
  64. /package/templates/mpa/src/pages/{about.html → about/index.html} +0 -0
  65. /package/templates/plugin-authoring/src/{layout/index.tsx → pages/layout.tsx} +0 -0
  66. /package/templates/plugin-authoring/src/pages/{index.tsx → page.tsx} +0 -0
  67. /package/templates/with-sqlite/src/{layout/index.tsx → pages/layout.tsx} +0 -0
  68. /package/templates/with-sqlite/src/pages/{index.tsx → page.tsx} +0 -0
  69. /package/templates/with-tailwind/src/{layout/index.tsx → pages/layout.tsx} +0 -0
  70. /package/templates/with-trpc/src/{layout/index.tsx → pages/layout.tsx} +0 -0
  71. /package/templates/with-trpc/src/pages/{index.tsx → page.tsx} +0 -0
package/README.md CHANGED
@@ -20,12 +20,18 @@ npx @evjs/create-app [name] [options]
20
20
 
21
21
  ## Templates
22
22
 
23
+ Every template uses the same Page-and-Route authoring model: `page.tsx` anchors,
24
+ optional build-time `page.config.ts` for static title/named metadata and
25
+ rendering, and directory-derived URLs.
26
+ `routing.mode` is the only routing-mode configuration; SPA and MPA
27
+ materialize the same Page tree differently.
28
+
23
29
  | Name | Description |
24
30
  |------|-------------|
25
- | **`basic`** | Basic full-stack example with routing and server functions. |
26
- | **`mpa`** | Multi-page application with separate page entries. |
27
- | **`api-routes`** | REST API routes via default server file routes. |
28
- | **`complex-routing`** | Root layout, loaders, search params, and nested paths. |
31
+ | **`basic`** | Basic full-stack SPA with routing, `page.config.ts`, and server functions. |
32
+ | **`mpa`** | The same Page/config model materialized as separate documents. |
33
+ | **`api-routes`** | REST API routes via positive `src/apis/**/api.*` anchors. |
34
+ | **`complex-routing`** | Advanced Page routes with a root layout, params, redirects, and nested paths. |
29
35
  | **`custom-ws-transport`** | Custom transport example using WebSockets. |
30
36
  | **`plugin-authoring`** | Starter focused on plugin authoring and bundler hooks. |
31
37
  | **`with-sqlite`** | Full-stack CRUD example backed by SQLite. |
@@ -40,8 +46,12 @@ npx @evjs/create-app my-new-app
40
46
 
41
47
  Follow the interactive prompts to select your features and get started in seconds.
42
48
 
43
- Generated route type files such as `src/route-types.d.ts` are not copied
44
- from templates; `ev dev` and `ev build` recreate them for the new project.
49
+ Generated framework files such as `src/route-types.d.ts` are never copied from
50
+ templates and should remain ignored by source control.
51
+
52
+ `page.config.ts` is evaluated by evjs during graph construction. It is not a
53
+ browser entry: plugins must explicitly project any configured extension data
54
+ that their runtime needs.
45
55
 
46
56
  ## License
47
57
 
package/dist/index.js CHANGED
@@ -49,7 +49,7 @@ export async function runCreateAppCli(argv = process.argv) {
49
49
  value: "api-routes",
50
50
  },
51
51
  {
52
- title: "Complex Routing (params, search, root layout, loaders)",
52
+ title: "Complex Routing (nested Pages, params, search, redirects)",
53
53
  value: "complex-routing",
54
54
  },
55
55
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@evjs/create-app",
3
- "version": "0.2.16",
3
+ "version": "0.3.1",
4
4
  "description": "Scaffold a new evjs project",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -12,22 +12,26 @@ npm run dev
12
12
 
13
13
  | File | Purpose |
14
14
  |------|---------|
15
+ | `ev.config.ts` | Selects SPA routing mode |
16
+ | `src/pages/page.tsx` | Root Page that exercises the REST endpoints |
17
+ | `src/pages/layout.tsx` | File-convention root layout |
15
18
  | `src/middleware.ts` | Framework request middleware for all server requests |
16
19
  | `src/apis/api/middleware.ts` | API route middleware for `/api/**` file routes |
17
- | `src/apis/api/posts.ts` | List/create handlers for `/api/posts` |
18
- | `src/apis/api/posts/$id.ts` | Dynamic handlers for `/api/posts/:id` |
19
- | `src/apis/api/health.ts` | Health check endpoint |
20
- | `src/apis/api/posts-store.ts` | Colocated helper module ignored by route discovery |
20
+ | `src/apis/api/posts/api.ts` | List/create handlers for `/api/posts` |
21
+ | `src/apis/api/posts/$id/api.ts` | Dynamic handlers for `/api/posts/:id` |
22
+ | `src/apis/api/health/api.ts` | Health check endpoint |
23
+ | `src/apis/api/posts/posts-store.ts` | Private helper colocated in the `/api/posts` route scope |
21
24
 
22
25
  ## What It Demonstrates
23
26
 
24
- - Uppercase method exports (`GET`, `POST`, `PUT`, `DELETE`) for REST endpoints
25
- - Dynamic route files (`$id.ts` -> `:id`)
27
+ - Directory-owned `api.ts` anchors with uppercase method exports (`GET`, `POST`, `PUT`, `DELETE`)
28
+ - Dynamic route directories (`$id/api.ts` -> `:id`)
26
29
  - Query string parsing (`?limit=N`)
27
30
  - Custom status codes (201, 204, 404)
28
31
  - Auto `OPTIONS` and `405 Method Not Allowed`
29
32
  - Framework request and API route `middleware.ts` conventions
30
- - Colocated helper files without route exports
33
+ - Colocated private helpers that are not named `api.ts`
34
+ - A root `page.tsx` anchor mapped to `/` by file convention
31
35
 
32
36
  ## Try It
33
37
 
@@ -0,0 +1,5 @@
1
+ import { defineConfig } from "@evjs/ev";
2
+
3
+ export default defineConfig({
4
+ routing: { mode: "spa" },
5
+ });
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "example-api-routes",
3
- "version": "0.2.16",
3
+ "version": "0.3.1",
4
4
  "private": true,
5
5
  "scripts": {
6
6
  "dev": "ev dev",
@@ -1,8 +1,6 @@
1
- /**
2
- * Dynamic route handlers for /api/posts/:id.
3
- */
1
+ /** Dynamic route handlers for /api/posts/:id. */
4
2
 
5
- import { posts } from "@/apis/api/posts-store";
3
+ import { posts } from "@/apis/api/posts/posts-store";
6
4
 
7
5
  interface RouteContext {
8
6
  req: {
@@ -2,7 +2,7 @@
2
2
  * Route handlers for the /api/posts REST endpoint.
3
3
  *
4
4
  * Demonstrates:
5
- * - Multiple HTTP methods on a single file path
5
+ * - Multiple HTTP methods on one api.ts anchor
6
6
  * - JSON request/response
7
7
  * - Custom status codes
8
8
  */
@@ -1,4 +1,4 @@
1
- /** Simulated post database shared by colocated server route modules. */
1
+ /** Simulated post database private to the /api/posts route scope. */
2
2
  export interface Post {
3
3
  id: string;
4
4
  title: string;
@@ -5,7 +5,8 @@ export default function Root({ children }: { children?: ReactNode }) {
5
5
  <div style={{ fontFamily: "system-ui, sans-serif", padding: "1rem" }}>
6
6
  <h1>Route Handlers Example</h1>
7
7
  <p style={{ color: "#666" }}>
8
- REST endpoints discovered from <code>src/apis</code>
8
+ REST endpoints anchored by <code>api.ts</code> under{" "}
9
+ <code>src/apis</code>
9
10
  </p>
10
11
  {children}
11
12
  </div>
@@ -1,6 +1,7 @@
1
1
  # basic
2
2
 
3
- The standard starting point for an evjs application. Demonstrates both client-side routing and server functions.
3
+ The standard starting point for an evjs application. It demonstrates the
4
+ Page-and-Route file convention alongside server functions.
4
5
 
5
6
  ## Run
6
7
 
@@ -12,14 +13,31 @@ npm run dev
12
13
 
13
14
  | File | Purpose |
14
15
  |------|---------|
15
- | `src/layout/index.tsx` | SPA root layout |
16
- | `src/pages/` | Page route files |
16
+ | `ev.config.ts` | Selects SPA routing mode |
17
+ | `src/pages/layout.tsx` | File-convention root layout |
18
+ | `src/pages/page.tsx` | Root Page mapped to `/` |
19
+ | `src/pages/page.config.ts` | Static root Page title/meta and CSR rendering config |
20
+ | `src/pages/about/page.config.ts` | Route-specific title/meta for `/about` |
21
+ | `src/pages/components/index.tsx` | Page-scoped component; its `index.tsx` never creates a route |
22
+ | `src/pages/about/components/RouteCard.tsx` | Ordinary page-scoped component without a private prefix |
17
23
  | `src/apis/users.server.ts` | `"use server"` CRUD functions |
18
24
 
19
25
  ## What It Demonstrates
20
26
 
21
- - SPA page routing from `src/pages`
27
+ - One `page.tsx` anchor convention for static, dynamic, and search-param routes
28
+ - Static `title` and named `meta` in the same build-time `page.config.ts`
29
+ contract as rendering and plugin capabilities
30
+ - SPA navigation applies the deepest active Page metadata without inheriting
31
+ metadata from parent Pages
32
+ - `/about` intentionally omits `keywords` and `viewport`: navigation removes
33
+ the root Page keyword and restores the HTML template viewport baseline
34
+ - URL paths derived from Page directories, including `users/$userId/page.tsx`
35
+ - Colocated Page code without `_` prefixes; only `page.tsx` creates a Page
22
36
  - `"use server"` directive for auto-discovered server functions
23
37
  - `useQuery(getUsers)` for type-safe data fetching
24
38
  - `useMutation({ mutationFn: createUser })` for server-side mutations
25
39
  - `getFnQueryKey(getUsers)` for cache invalidation
40
+
41
+ This example uses the canonical `routing.mode: "spa"` file-convention profile.
42
+ Explicit `application.routes` is a separate SPA-only input into the same
43
+ normalized graph.
@@ -1,5 +1,5 @@
1
1
  import { defineConfig } from "@evjs/ev";
2
2
 
3
3
  export default defineConfig({
4
- // Add any custom evjs configuration here
4
+ routing: { mode: "spa" },
5
5
  });
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "example-basic",
3
- "version": "0.2.16",
3
+ "version": "0.3.1",
4
4
  "private": true,
5
5
  "scripts": {
6
6
  "dev": "ev dev",
@@ -0,0 +1,15 @@
1
+ import type { ReactNode } from "react";
2
+
3
+ export function RouteCard({ children }: { children?: ReactNode }) {
4
+ return (
5
+ <div
6
+ style={{
7
+ border: "1px solid #e2e8f0",
8
+ borderRadius: 12,
9
+ padding: "1rem",
10
+ }}
11
+ >
12
+ {children}
13
+ </div>
14
+ );
15
+ }
@@ -0,0 +1,9 @@
1
+ import { definePageConfig } from "@evjs/ev";
2
+
3
+ export default definePageConfig({
4
+ title: "About evjs",
5
+ meta: {
6
+ description: "About the canonical evjs Page-and-Route model.",
7
+ "theme-color": "#f8fafc",
8
+ },
9
+ });
@@ -0,0 +1,14 @@
1
+ import { RouteCard } from "./components/RouteCard";
2
+
3
+ export default function AboutPage() {
4
+ return (
5
+ <RouteCard>
6
+ <h2>Static Route</h2>
7
+ <p>
8
+ The <code>about</code> Page lives at{" "}
9
+ <code>src/pages/about/page.tsx</code>; its directory maps to{" "}
10
+ <code>/about</code>.
11
+ </p>
12
+ </RouteCard>
13
+ );
14
+ }
@@ -0,0 +1,8 @@
1
+ export default function PageScopeNote() {
2
+ return (
3
+ <p style={{ color: "#475569", marginBottom: 0 }}>
4
+ This nested components/index.tsx is ordinary code in the root Page scope;
5
+ only page.tsx creates a Page route.
6
+ </p>
7
+ );
8
+ }
@@ -0,0 +1,12 @@
1
+ import { definePageConfig } from "@evjs/ev";
2
+
3
+ export default definePageConfig({
4
+ title: "evjs Basic",
5
+ meta: {
6
+ description: "The canonical evjs SPA example.",
7
+ keywords: "evjs,spa,server functions",
8
+ viewport: "width=device-width, initial-scale=1",
9
+ "theme-color": "#ffffff",
10
+ },
11
+ render: "csr",
12
+ });
@@ -7,6 +7,7 @@ import {
7
7
  } from "@evjs/ev/query";
8
8
  import { useState } from "react";
9
9
  import { createUser, getUsers } from "@/apis/users.server";
10
+ import PageScopeNote from "./components";
10
11
 
11
12
  const cardStyle = {
12
13
  border: "1px solid #e2e8f0",
@@ -44,8 +45,8 @@ export default function UsersPage() {
44
45
  <div style={cardStyle}>
45
46
  <h2>Routing Patterns</h2>
46
47
  <p style={{ color: "#475569" }}>
47
- Page files cover static, dynamic-param, and search-param pages with
48
- framework-managed routing glue.
48
+ Page directories map to static, dynamic-param, and search-param URLs
49
+ through one file convention.
49
50
  </p>
50
51
  <div style={{ display: "flex", gap: "1rem", flexWrap: "wrap" }}>
51
52
  <Link to="/about" style={linkStyle}>
@@ -58,6 +59,7 @@ export default function UsersPage() {
58
59
  Open search route
59
60
  </Link>
60
61
  </div>
62
+ <PageScopeNote />
61
63
  </div>
62
64
 
63
65
  <div style={cardStyle}>
@@ -1,6 +1,7 @@
1
1
  # complex-routing
2
2
 
3
- Advanced SPA page routing patterns.
3
+ Advanced SPA routing through the same Page-and-Route file convention
4
+ used by the basic example.
4
5
 
5
6
  ## Run
6
7
 
@@ -12,15 +13,23 @@ npm run dev
12
13
 
13
14
  | File | Purpose |
14
15
  |------|---------|
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 |
16
+ | `ev.config.ts` | Selects SPA routing mode |
17
+ | `src/pages/layout.tsx` | File-convention root layout with navigation |
18
+ | `src/pages/page.tsx` | Root Page for `/` |
19
+ | `src/pages/posts/page.tsx` | Page for `/posts` |
20
+ | `src/pages/posts/$postId/page.tsx` | Dynamic Page for `/posts/:postId` |
18
21
 
19
22
  ## What It Demonstrates
20
23
 
21
- - Dynamic route params (`$postId`)
22
- - SPA root layout
23
- - Route loaders with `queryClient.ensureQueryData`
24
+ - Canonical `page.tsx` anchors with directory-derived URLs
25
+ - Nested routes and dynamic `$postId` directory segments
26
+ - File-convention root layout
27
+ - Server-function queries from route components
24
28
  - Search params with `validateSearch`
25
- - Catch-all 404 route
29
+ - Redirects through the `/old-blog` Page lifecycle
26
30
  - Page hooks such as `usePageParams()` and `usePageSearch()`
31
+
32
+ This example uses SPA mode because MPA rejects its dynamic route and
33
+ router-only React facets. Canonical SPA and MPA apps share the same `page.tsx`
34
+ Page-anchor convention; `routing.mode` selects how supported Pages are
35
+ materialized.
@@ -0,0 +1,5 @@
1
+ import { defineConfig } from "@evjs/ev";
2
+
3
+ export default defineConfig({
4
+ routing: { mode: "spa" },
5
+ });
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "example-complex-routing",
3
- "version": "0.2.16",
3
+ "version": "0.3.1",
4
4
  "private": true,
5
5
  "scripts": {
6
6
  "dev": "ev dev",
@@ -1,6 +1,7 @@
1
1
  # custom-ws-transport
2
2
 
3
- Custom WebSocket transport for server function calls.
3
+ Client-side `TransportAdapter` example for sending server-function calls over
4
+ WebSocket. This repository does not provide the matching WebSocket server.
4
5
 
5
6
  ## Run
6
7
 
@@ -8,12 +9,17 @@ Custom WebSocket transport for server function calls.
8
9
  npm run dev
9
10
  ```
10
11
 
12
+ The page shell runs locally, but server-function calls require a same-origin
13
+ `/ws` endpoint that accepts the documented `{ id, fnId, args }` messages and
14
+ returns `{ id, result }` or `{ id, error }`.
15
+
11
16
  ## Key Files
12
17
 
13
18
  | File | Purpose |
14
19
  |------|---------|
15
- | `src/layout/index.tsx` | SPA root layout |
16
- | `src/pages/index.tsx` | `initTransport` with WebSocket adapter and users CRUD UI |
20
+ | `ev.config.ts` | Selects SPA routing mode |
21
+ | `src/pages/layout.tsx` | File-convention root layout |
22
+ | `src/pages/page.tsx` | `initTransport` with WebSocket adapter and users CRUD UI |
17
23
  | `src/apis/users.server.ts` | Server functions |
18
24
 
19
25
 
@@ -21,5 +27,6 @@ npm run dev
21
27
 
22
28
  - Custom `TransportAdapter` over WebSocket
23
29
  - `initTransport({ adapter: { send } })` extension
24
- - `dispatch()` for protocol-agnostic server-side handling
25
- - Same server functions work over HTTP and WebSocket
30
+ - Request correlation and pending-call cleanup for a custom client protocol
31
+ - The client message contract a matching WebSocket server must implement
32
+ - Transport setup inside the root Page scope
@@ -0,0 +1,5 @@
1
+ import { defineConfig } from "@evjs/ev";
2
+
3
+ export default defineConfig({
4
+ routing: { mode: "spa" },
5
+ });
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "example-custom-ws-transport",
3
- "version": "0.2.16",
3
+ "version": "0.3.1",
4
4
  "private": true,
5
5
  "scripts": {
6
6
  "dev": "ev dev",
@@ -1,6 +1,7 @@
1
- # mpa
1
+ # Unified MPA
2
2
 
3
- Minimal multi-page application example using evjs page routing.
3
+ Minimal multi-page application using the same `page.tsx` file
4
+ convention as SPA applications.
4
5
 
5
6
  ## Run
6
7
 
@@ -8,6 +9,9 @@ Minimal multi-page application example using evjs page routing.
8
9
  npm run dev
9
10
  ```
10
11
 
12
+ Open `/` on the URL printed by the CLI, then follow the static link to
13
+ `/about`.
14
+
11
15
  ## Build
12
16
 
13
17
  ```bash
@@ -17,18 +21,34 @@ npm run build
17
21
  ## Key Files
18
22
 
19
23
  | File | Purpose |
20
- |------|---------|
21
- | `ev.config.ts` | Enables page MPA mode |
24
+ | --- | --- |
25
+ | `ev.config.ts` | Selects MPA routing mode |
22
26
  | `index.html` | Shared fallback HTML template |
23
- | `src/pages/home.tsx` | Home page component |
24
- | `src/pages/about.tsx` | About page component |
25
- | `src/pages/about.html` | Page-specific MPA HTML template for `about.tsx` |
27
+ | `src/pages/page.tsx` | Root Page for `/` |
28
+ | `src/pages/page.config.ts` | Static title/meta and rendering config for `/` |
29
+ | `src/pages/components/PageScopeNote.tsx` | Colocated root Page component without an `_` prefix |
30
+ | `src/pages/about/page.tsx` | Page for `/about` |
31
+ | `src/pages/about/page.config.ts` | Static title/meta and `about.html` Document alias for `/about` |
32
+ | `src/pages/about/index.html` | Optional Page-specific HTML template baseline |
26
33
 
27
34
  ## What It Demonstrates
28
35
 
29
36
  - Multi-page build via `routing.mode: "mpa"`
30
- - Independent router-free React page for each page file
31
- - Shared HTML fallback plus a colocated page-specific HTML template
32
- - Static links between pages
37
+ - The same directory-derived `page.tsx` routes as SPA
38
+ - The same static `title` and named `meta` contract as SPA
39
+ - One independent router-free React entry per Page
40
+ - A complete Page directory acts as private source scope, so colocated helpers,
41
+ components, hooks, and models do not need `_` prefixes
42
+ - Page config title/meta add missing tags and override matching values in a
43
+ shared or colocated HTML template while omitted keys preserve that template
44
+ baseline
45
+ - `/about` omits `viewport`, so its colocated HTML viewport remains the
46
+ Document baseline
47
+ - A colocated `index.html` customizes one MPA Page without route configuration
48
+ - `document.aliases` emits `/about.html` as an alias of `/about/index.html`
49
+ - Stable `/` and `/about` URLs across SPA and MPA mode
33
50
  - No `@evjs/client`, `@evjs/server`, or generated `route-types.d.ts`
34
51
  dependency is needed for this router-free client output
52
+
53
+ Explicit `component`/`routes` config is a SPA-only route-tree input and is not
54
+ accepted as an MPA authoring model.
@@ -1,12 +1,5 @@
1
1
  import { defineConfig } from "@evjs/ev";
2
2
 
3
3
  export default defineConfig({
4
- output: {
5
- client: "dist",
6
- server: "dist-server",
7
- },
8
- html: "./index.html",
9
- routing: {
10
- mode: "mpa",
11
- },
4
+ routing: { mode: "mpa" },
12
5
  });
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "example-mpa",
3
- "version": "0.2.16",
3
+ "version": "0.3.1",
4
4
  "private": true,
5
5
  "scripts": {
6
6
  "dev": "ev dev",
@@ -0,0 +1,12 @@
1
+ import { definePageConfig } from "@evjs/ev";
2
+
3
+ export default definePageConfig({
4
+ title: "evjs MPA About",
5
+ meta: {
6
+ description: "The about Page in the canonical evjs MPA example.",
7
+ "theme-color": "#f8fafc",
8
+ },
9
+ document: {
10
+ aliases: ["about.html"],
11
+ },
12
+ });
@@ -3,10 +3,10 @@ export default function AboutPage() {
3
3
  <main style={{ fontFamily: "ui-sans-serif, system-ui", margin: "2rem" }}>
4
4
  <h1>About Page</h1>
5
5
  <p>
6
- This page is rendered from <code>src/pages/about.tsx</code>.
6
+ This page is rendered from <code>src/pages/about/page.tsx</code>.
7
7
  </p>
8
8
  <p>
9
- <a href="/home.html">Back to Home page</a>
9
+ <a href="/">Back to Home page</a>
10
10
  </p>
11
11
  </main>
12
12
  );
@@ -0,0 +1,8 @@
1
+ export function PageScopeNote() {
2
+ return (
3
+ <p>
4
+ This colocated component stays private to the root Page without an
5
+ underscore-prefixed directory.
6
+ </p>
7
+ );
8
+ }
@@ -0,0 +1,12 @@
1
+ import { definePageConfig } from "@evjs/ev";
2
+
3
+ export default definePageConfig({
4
+ title: "evjs MPA Home",
5
+ meta: {
6
+ description: "The home Page in the canonical evjs MPA example.",
7
+ keywords: "evjs,mpa,home",
8
+ viewport: "width=device-width, initial-scale=1",
9
+ "theme-color": "#ffffff",
10
+ },
11
+ render: "csr",
12
+ });
@@ -1,12 +1,15 @@
1
+ import { PageScopeNote } from "./components/PageScopeNote";
2
+
1
3
  export default function HomePage() {
2
4
  return (
3
5
  <main style={{ fontFamily: "ui-sans-serif, system-ui", margin: "2rem" }}>
4
6
  <h1>Home Page</h1>
5
7
  <p>
6
- This page is rendered from <code>src/pages/home.tsx</code>.
8
+ This page is rendered from <code>src/pages/page.tsx</code>.
7
9
  </p>
10
+ <PageScopeNote />
8
11
  <p>
9
- <a href="/about.html">Go to About page</a>
12
+ <a href="/about">Go to About page</a>
10
13
  </p>
11
14
  </main>
12
15
  );
@@ -1,8 +1,15 @@
1
1
  # plugin-authoring
2
2
 
3
- Demonstrates the evjs plugin lifecycle hooks used by ordinary build-time
4
- extensions:
3
+ Demonstrates one evjs plugin API combining Application, Page, Route, and
4
+ Document extension declarations with the lifecycle hooks used by ordinary
5
+ build-time extensions.
5
6
 
7
+ - **top-level `extensions`** — author static, namespaced Application data
8
+ - **`page.config.ts`** — author static, namespaced Page and unique-Route data
9
+ - **one extension registry** — register Application, Page, Route, and Document owners of one namespace
10
+ - **`setup`** — read the resolved Application value before graph analysis
11
+ - **`contributions`** — read all four resolved owner bags from semantic graph views
12
+ - **`config`** — update framework config before defaults are resolved
6
13
  - **`bundlerConfig`** — modify the underlying bundler config (type-safe via `utoopack()` helper)
7
14
  - **`buildStart`** — run logic before compilation begins
8
15
  - **`buildEnd`** — run logic after compilation completes
@@ -11,6 +18,18 @@ extensions:
11
18
  For plugins that need to declare generated `.ev` artifacts and attach them to
12
19
  framework slots, see the generated contributions documentation.
13
20
 
21
+ Plugins use one `Plugin` shape: declare static capabilities in `describe()` and
22
+ add semantic contributions through the corresponding framework APIs.
23
+
24
+ The application itself uses the canonical model:
25
+ `src/pages/page.tsx` defines `/`, `src/pages/layout.tsx` supplies the SPA root
26
+ layout, `ev.config.ts` configures the Application extension, and
27
+ `src/pages/page.config.ts` configures the Page and its unique Route. The
28
+ Document declaration supplies a default for the SPA's Application-owned
29
+ Document; a CSR SPA Page does not own a separate Document. All four owners use
30
+ the same `@example/metadata` namespace and schema version. These build-time
31
+ values are not automatically serialized into browser runtime.
32
+
14
33
  ## Run
15
34
 
16
35
  ```bash
@@ -19,6 +38,8 @@ npm run dev
19
38
 
20
39
  ## What to look for
21
40
 
22
- 1. Console output from `buildStart` and `buildEnd` hooks during build
23
- 2. The `<!-- Built with evjs | file.html | N asset(s) -->` comment in the output HTML (injected by `transformHtml`)
24
- 3. `.txt` file support added via the `bundlerConfig` hook (utoopack raw rule)
41
+ 1. The resolved Application `@example/metadata` value in `setup`
42
+ 2. The resolved Page, Route, and Document `@example/metadata` values in `contributions`
43
+ 3. Console output from `buildStart` and `buildEnd` hooks during build
44
+ 4. The `<!-- Built with evjs | file.html | N asset(s) -->` comment in the output HTML (injected by `transformHtml`)
45
+ 5. The type-safe `.txt` rule declaration in the `bundlerConfig` hook
@@ -1,5 +1,64 @@
1
1
  import { merge, utoopack } from "@evjs/bundler-utoopack";
2
2
  import { defineConfig } from "@evjs/ev";
3
+ import { definePlugin } from "@evjs/ev/plugin";
4
+
5
+ const metadataPlugin = definePlugin({
6
+ name: "example-metadata-plugin",
7
+ describe(api) {
8
+ api.applicationExtension<
9
+ { enabled: boolean; channel: string },
10
+ { enabled?: boolean }
11
+ >({
12
+ namespace: "@example/metadata",
13
+ schemaVersion: "1",
14
+ defaults: { enabled: false, channel: "web" },
15
+ });
16
+ api.pageExtension({
17
+ namespace: "@example/metadata",
18
+ schemaVersion: "1",
19
+ defaults: { label: "Plugin authoring Page" },
20
+ });
21
+ api.routeExtension({
22
+ namespace: "@example/metadata",
23
+ schemaVersion: "1",
24
+ defaults: ({ routeId }) => ({ label: `Route ${routeId}` }),
25
+ });
26
+ api.documentExtension({
27
+ namespace: "@example/metadata",
28
+ schemaVersion: "1",
29
+ defaults: ({ output }) => ({
30
+ label: `Document ${output}`,
31
+ theme: "light",
32
+ }),
33
+ });
34
+ },
35
+ setup(ctx) {
36
+ const metadata = ctx.config.extensions["@example/metadata"];
37
+ console.log(
38
+ `[example-metadata-plugin] Application value: ${JSON.stringify(metadata)}`,
39
+ );
40
+ },
41
+ contributions(ctx) {
42
+ for (const page of ctx.framework.pages) {
43
+ const metadata = page.extensions["@example/metadata"];
44
+ console.log(
45
+ `[example-metadata-plugin] Page ${page.id}: ${JSON.stringify(metadata)}`,
46
+ );
47
+ }
48
+ for (const route of ctx.framework.routes) {
49
+ const metadata = route.extensions["@example/metadata"];
50
+ console.log(
51
+ `[example-metadata-plugin] Route ${route.id}: ${JSON.stringify(metadata)}`,
52
+ );
53
+ }
54
+ for (const document of ctx.framework.documents) {
55
+ const metadata = document.extensions["@example/metadata"];
56
+ console.log(
57
+ `[example-metadata-plugin] Document ${document.id}: ${JSON.stringify(metadata)}`,
58
+ );
59
+ }
60
+ },
61
+ });
3
62
 
4
63
  /**
5
64
  * Example: evjs plugin system.
@@ -12,7 +71,14 @@ import { defineConfig } from "@evjs/ev";
12
71
  * - `transformHtml` — modify the output HTML document after asset injection
13
72
  */
14
73
  export default defineConfig({
74
+ routing: { mode: "spa" },
75
+ extensions: {
76
+ "@example/metadata": {
77
+ enabled: true,
78
+ },
79
+ },
15
80
  plugins: [
81
+ metadataPlugin,
16
82
  {
17
83
  name: "example-txt-plugin",
18
84
  config(config) {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "example-plugin-authoring",
3
- "version": "0.2.16",
3
+ "version": "0.3.1",
4
4
  "private": true,
5
5
  "scripts": {
6
6
  "dev": "ev dev",
@@ -0,0 +1,16 @@
1
+ import { definePageConfig } from "@evjs/ev";
2
+
3
+ export default definePageConfig({
4
+ extensions: {
5
+ "@example/metadata": {
6
+ label: "Configured by page.config.ts",
7
+ },
8
+ },
9
+ route: {
10
+ extensions: {
11
+ "@example/metadata": {
12
+ label: "Configured for the home Route",
13
+ },
14
+ },
15
+ },
16
+ });
@@ -12,8 +12,9 @@ npm run dev
12
12
 
13
13
  | File | Purpose |
14
14
  |------|---------|
15
- | `src/layout/index.tsx` | SPA root layout |
16
- | `src/pages/index.tsx` | Users list + todo management UI |
15
+ | `ev.config.ts` | Selects SPA routing mode |
16
+ | `src/pages/layout.tsx` | File-convention root layout |
17
+ | `src/pages/page.tsx` | Users list + todo management UI |
17
18
  | `src/apis/db.server.ts` | SQLite setup plus user and todo CRUD server functions |
18
19
 
19
20
  ## What It Demonstrates
@@ -0,0 +1,5 @@
1
+ import { defineConfig } from "@evjs/ev";
2
+
3
+ export default defineConfig({
4
+ routing: { mode: "spa" },
5
+ });
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "example-with-sqlite",
3
- "version": "0.2.16",
3
+ "version": "0.3.1",
4
4
  "private": true,
5
5
  "scripts": {
6
6
  "dev": "ev dev",
@@ -0,0 +1,20 @@
1
+ # with-tailwind
2
+
3
+ Tailwind CSS v4 through the evjs PostCSS pipeline and canonical Page
4
+ model.
5
+
6
+ ## Run
7
+
8
+ ```bash
9
+ npm run dev
10
+ ```
11
+
12
+ ## Key Files
13
+
14
+ | File | Purpose |
15
+ |------|---------|
16
+ | `ev.config.ts` | Selects SPA routing mode and output directories |
17
+ | `src/pages/page.tsx` | Root Page using Tailwind utilities |
18
+ | `src/pages/layout.tsx` | File-convention root layout importing global styles |
19
+ | `src/styles.css` | Tailwind CSS entry |
20
+ | `postcss.config.mjs` | PostCSS and Tailwind configuration |
@@ -4,13 +4,10 @@ import { defineConfig } from "@evjs/ev";
4
4
  * Example: Using Tailwind CSS.
5
5
  *
6
6
  * Tailwind is supported out-of-the-box by the framework.
7
- * Because a `postcss.config.js` file exists in this directory,
7
+ * Because a `postcss.config.mjs` file exists in this directory,
8
8
  * `evjs` automatically applies `postcss-loader` alongside `css-loader`.
9
9
  * No custom loaders or `bundler` hooks are needed!
10
10
  */
11
11
  export default defineConfig({
12
- output: {
13
- client: "dist",
14
- server: "dist-server",
15
- },
12
+ routing: { mode: "spa" },
16
13
  });
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "example-with-tailwind",
3
- "version": "0.2.16",
3
+ "version": "0.3.1",
4
4
  "private": true,
5
5
  "scripts": {
6
6
  "dev": "ev dev",
@@ -38,7 +38,7 @@ export default function HomePage() {
38
38
  <div className="text-3xl mb-3">Zero</div>
39
39
  <h3 className="font-semibold text-white mb-1">Page Routes</h3>
40
40
  <p className="text-sm text-slate-400">
41
- The route path is derived from <code>src/pages/index.tsx</code>.
41
+ <code>src/pages/page.tsx</code> defines the <code>/</code> Page.
42
42
  </p>
43
43
  </div>
44
44
  </div>
@@ -63,7 +63,9 @@ export default function HomePage() {
63
63
  <div className="rounded-xl border border-white/10 bg-white/5 backdrop-blur-sm p-6">
64
64
  <h2 className="text-lg font-semibold text-white mb-4">ev.config.ts</h2>
65
65
  <pre className="text-sm text-slate-300 bg-black/30 rounded-lg p-4 overflow-x-auto">
66
- <code>{`export default defineConfig({});`}</code>
66
+ <code>{`export default defineConfig({
67
+ routing: { mode: "spa" },
68
+ });`}</code>
67
69
  </pre>
68
70
  </div>
69
71
  </main>
@@ -12,12 +12,14 @@ npm run dev
12
12
 
13
13
  | File | Purpose |
14
14
  |------|---------|
15
- | `src/layout/index.tsx` | SPA root layout |
16
- | `src/pages/index.tsx` | UI consuming both tRPC and evjs APIs |
17
- | `src/apis/trpc.server.ts` | tRPC router and evjs server functions |
15
+ | `ev.config.ts` | Selects SPA routing mode |
16
+ | `src/pages/layout.tsx` | File-convention root layout |
17
+ | `src/pages/page.tsx` | UI consuming both tRPC and evjs APIs |
18
+ | `src/trpc.ts` | tRPC router and procedure definitions |
19
+ | `src/apis/trpc.server.ts` | Server-function dispatcher bridge into the tRPC router |
18
20
 
19
21
  ## What It Demonstrates
20
22
 
21
23
  - tRPC client + server alongside evjs server functions
22
- - `@trpc/server` router defined inside a `"use server"` file
24
+ - A `"use server"` bridge dispatching calls into an `@trpc/server` router
23
25
  - Both APIs coexist in the same build pipeline
@@ -0,0 +1,5 @@
1
+ import { defineConfig } from "@evjs/ev";
2
+
3
+ export default defineConfig({
4
+ routing: { mode: "spa" },
5
+ });
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "example-with-trpc",
3
- "version": "0.2.16",
3
+ "version": "0.3.1",
4
4
  "private": true,
5
5
  "scripts": {
6
6
  "dev": "ev dev",
@@ -1,17 +0,0 @@
1
- const cardStyle = {
2
- border: "1px solid #e2e8f0",
3
- borderRadius: 12,
4
- padding: "1rem",
5
- };
6
-
7
- export default function AboutPage() {
8
- return (
9
- <div style={cardStyle}>
10
- <h2>Static Route</h2>
11
- <p>
12
- This page is discovered from <code>src/pages/about.tsx</code> and served
13
- at <code>/about</code>.
14
- </p>
15
- </div>
16
- );
17
- }