@evjs/create-app 0.2.16 → 0.3.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.
- package/README.md +16 -6
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/templates/api-routes/README.md +11 -7
- package/templates/api-routes/ev.config.ts +5 -0
- package/templates/api-routes/package.json +1 -1
- package/templates/api-routes/src/apis/api/posts/{$id.ts → $id/api.ts} +2 -4
- package/templates/api-routes/src/apis/api/{posts.ts → posts/api.ts} +1 -1
- package/templates/api-routes/src/apis/api/{posts-store.ts → posts/posts-store.ts} +1 -1
- package/templates/api-routes/src/{layout/index.tsx → pages/layout.tsx} +2 -1
- package/templates/basic/README.md +25 -4
- package/templates/basic/ev.config.ts +1 -1
- package/templates/basic/package.json +1 -1
- package/templates/basic/src/pages/about/components/RouteCard.tsx +15 -0
- package/templates/basic/src/pages/about/page.config.ts +9 -0
- package/templates/basic/src/pages/about/page.tsx +14 -0
- package/templates/basic/src/pages/components/index.tsx +8 -0
- package/templates/basic/src/pages/page.config.ts +12 -0
- package/templates/basic/src/pages/{index.tsx → page.tsx} +4 -2
- package/templates/complex-routing/README.md +17 -8
- package/templates/complex-routing/ev.config.ts +5 -0
- package/templates/complex-routing/package.json +1 -1
- package/templates/custom-ws-transport/README.md +4 -2
- package/templates/custom-ws-transport/ev.config.ts +5 -0
- package/templates/custom-ws-transport/package.json +1 -1
- package/templates/mpa/README.md +34 -10
- package/templates/mpa/ev.config.ts +1 -8
- package/templates/mpa/package.json +1 -1
- package/templates/mpa/src/pages/about/page.config.ts +12 -0
- package/templates/mpa/src/pages/{about.tsx → about/page.tsx} +2 -2
- package/templates/mpa/src/pages/components/PageScopeNote.tsx +8 -0
- package/templates/mpa/src/pages/page.config.ts +12 -0
- package/templates/mpa/src/pages/{home.tsx → page.tsx} +5 -2
- package/templates/plugin-authoring/README.md +28 -5
- package/templates/plugin-authoring/ev.config.ts +66 -0
- package/templates/plugin-authoring/package.json +1 -1
- package/templates/plugin-authoring/src/pages/page.config.ts +16 -0
- package/templates/with-sqlite/README.md +3 -2
- package/templates/with-sqlite/ev.config.ts +5 -0
- package/templates/with-sqlite/package.json +1 -1
- package/templates/with-tailwind/README.md +20 -0
- package/templates/with-tailwind/ev.config.ts +2 -5
- package/templates/with-tailwind/package.json +1 -1
- package/templates/with-tailwind/src/pages/{index.tsx → page.tsx} +4 -2
- package/templates/with-trpc/README.md +3 -2
- package/templates/with-trpc/ev.config.ts +5 -0
- package/templates/with-trpc/package.json +1 -1
- package/templates/basic/src/pages/about.tsx +0 -17
- /package/templates/api-routes/src/apis/api/{health.ts → health/api.ts} +0 -0
- /package/templates/api-routes/src/pages/{index.tsx → page.tsx} +0 -0
- /package/templates/basic/src/{layout/index.tsx → pages/layout.tsx} +0 -0
- /package/templates/basic/src/pages/{search.tsx → search/page.tsx} +0 -0
- /package/templates/basic/src/pages/users/{$userId.tsx → $userId/page.tsx} +0 -0
- /package/templates/complex-routing/src/pages/{dashboard.tsx → dashboard/page.tsx} +0 -0
- /package/templates/complex-routing/src/{layout/index.tsx → pages/layout.tsx} +0 -0
- /package/templates/complex-routing/src/pages/{old-blog.tsx → old-blog/page.tsx} +0 -0
- /package/templates/complex-routing/src/pages/{index.tsx → page.tsx} +0 -0
- /package/templates/complex-routing/src/pages/posts/{$postId.tsx → $postId/page.tsx} +0 -0
- /package/templates/complex-routing/src/pages/posts/{index.tsx → page.tsx} +0 -0
- /package/templates/complex-routing/src/pages/{search.tsx → search/page.tsx} +0 -0
- /package/templates/complex-routing/src/pages/users/{$username.tsx → $username/page.tsx} +0 -0
- /package/templates/custom-ws-transport/src/{layout/index.tsx → pages/layout.tsx} +0 -0
- /package/templates/custom-ws-transport/src/pages/{index.tsx → page.tsx} +0 -0
- /package/templates/mpa/src/pages/{about.html → about/index.html} +0 -0
- /package/templates/plugin-authoring/src/{layout/index.tsx → pages/layout.tsx} +0 -0
- /package/templates/plugin-authoring/src/pages/{index.tsx → page.tsx} +0 -0
- /package/templates/with-sqlite/src/{layout/index.tsx → pages/layout.tsx} +0 -0
- /package/templates/with-sqlite/src/pages/{index.tsx → page.tsx} +0 -0
- /package/templates/with-tailwind/src/{layout/index.tsx → pages/layout.tsx} +0 -0
- /package/templates/with-trpc/src/{layout/index.tsx → pages/layout.tsx} +0 -0
- /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 Core 0.3 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
|
|
26
|
-
| **`mpa`** |
|
|
27
|
-
| **`api-routes`** | REST API routes via
|
|
28
|
-
| **`complex-routing`** |
|
|
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
|
|
44
|
-
|
|
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,
|
|
52
|
+
title: "Complex Routing (nested Pages, params, search, redirects)",
|
|
53
53
|
value: "complex-routing",
|
|
54
54
|
},
|
|
55
55
|
{
|
package/package.json
CHANGED
|
@@ -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` |
|
|
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
|
-
-
|
|
25
|
-
- Dynamic route
|
|
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
|
|
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
|
|
|
@@ -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
|
|
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.
|
|
3
|
+
The standard starting point for an evjs application. It demonstrates the
|
|
4
|
+
unified Core 0.3 Page-and-Route file convention alongside server functions.
|
|
4
5
|
|
|
5
6
|
## Run
|
|
6
7
|
|
|
@@ -12,14 +13,34 @@ npm run dev
|
|
|
12
13
|
|
|
13
14
|
| File | Purpose |
|
|
14
15
|
|------|---------|
|
|
15
|
-
| `
|
|
16
|
-
| `src/pages
|
|
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
|
-
-
|
|
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
|
+
For source using explicit route configuration, this SPA Page tree is the
|
|
42
|
+
canonical file-convention form. The `application.routes` converter accepts a
|
|
43
|
+
SPA-only route tree and normalizes it into the same graph; after moving each
|
|
44
|
+
route component to its URL directory as `page.tsx`, use
|
|
45
|
+
`routing.mode: "spa"`. Explicit `component`/`routes` config does not define an
|
|
46
|
+
MPA materialization mode.
|
|
@@ -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,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,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
|
|
48
|
-
|
|
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
|
|
3
|
+
Advanced SPA routing through the same Core 0.3 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
|
-
| `
|
|
16
|
-
| `src/pages/
|
|
17
|
-
| `src/pages/
|
|
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
|
-
-
|
|
22
|
-
-
|
|
23
|
-
-
|
|
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
|
-
-
|
|
29
|
+
- Redirects through the `/old-blog` Page lifecycle
|
|
26
30
|
- Page hooks such as `usePageParams()` and `usePageSearch()`
|
|
31
|
+
|
|
32
|
+
This example intentionally uses SPA mode because its dynamic route and React
|
|
33
|
+
route facets are not yet materialized by the MPA runtime. Canonical SPA and MPA
|
|
34
|
+
apps still share the same `page.tsx` Page-anchor convention; `routing.mode`
|
|
35
|
+
selects how supported Pages are materialized.
|
|
@@ -12,8 +12,9 @@ npm run dev
|
|
|
12
12
|
|
|
13
13
|
| File | Purpose |
|
|
14
14
|
|------|---------|
|
|
15
|
-
| `
|
|
16
|
-
| `src/pages/
|
|
15
|
+
| `ev.config.ts` | Selects SPA routing mode |
|
|
16
|
+
| `src/pages/layout.tsx` | File-convention root layout |
|
|
17
|
+
| `src/pages/page.tsx` | `initTransport` with WebSocket adapter and users CRUD UI |
|
|
17
18
|
| `src/apis/users.server.ts` | Server functions |
|
|
18
19
|
|
|
19
20
|
|
|
@@ -23,3 +24,4 @@ npm run dev
|
|
|
23
24
|
- `initTransport({ adapter: { send } })` extension
|
|
24
25
|
- `dispatch()` for protocol-agnostic server-side handling
|
|
25
26
|
- Same server functions work over HTTP and WebSocket
|
|
27
|
+
- Transport setup inside the root Page scope
|
package/templates/mpa/README.md
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Unified MPA
|
|
2
2
|
|
|
3
|
-
Minimal multi-page application
|
|
3
|
+
Minimal Core 0.3 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,38 @@ npm run build
|
|
|
17
21
|
## Key Files
|
|
18
22
|
|
|
19
23
|
| File | Purpose |
|
|
20
|
-
|
|
21
|
-
| `ev.config.ts` |
|
|
24
|
+
| --- | --- |
|
|
25
|
+
| `ev.config.ts` | Selects MPA routing mode |
|
|
22
26
|
| `index.html` | Shared fallback HTML template |
|
|
23
|
-
| `src/pages/
|
|
24
|
-
| `src/pages/
|
|
25
|
-
| `src/pages/
|
|
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
|
-
-
|
|
31
|
-
-
|
|
32
|
-
-
|
|
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
|
+
Source trees whose published entries use `index.tsx` must rename them to
|
|
54
|
+
`page.tsx`, map static title and supported named meta to `page.config.ts` core
|
|
55
|
+
fields, and move remaining plugin-owned values to namespaced extensions.
|
|
56
|
+
Core discovers only canonical Page anchors. Explicit `component`/`routes`
|
|
57
|
+
config remains a SPA-only route-tree input and is not accepted as an MPA
|
|
58
|
+
authoring model.
|
|
@@ -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="/
|
|
9
|
+
<a href="/">Back to Home page</a>
|
|
10
10
|
</p>
|
|
11
11
|
</main>
|
|
12
12
|
);
|
|
@@ -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/
|
|
8
|
+
This page is rendered from <code>src/pages/page.tsx</code>.
|
|
7
9
|
</p>
|
|
10
|
+
<PageScopeNote />
|
|
8
11
|
<p>
|
|
9
|
-
<a href="/about
|
|
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
|
|
4
|
-
|
|
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,20 @@ 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. Typed
|
|
23
|
+
runtime hooks and semantic facet attachment are not implemented yet and remain
|
|
24
|
+
outside this example's scope.
|
|
25
|
+
|
|
26
|
+
The application itself uses the unified Core 0.3 model:
|
|
27
|
+
`src/pages/page.tsx` defines `/`, `src/pages/layout.tsx` supplies the SPA root
|
|
28
|
+
layout, `ev.config.ts` configures the Application extension, and
|
|
29
|
+
`src/pages/page.config.ts` configures the Page and its unique Route. The
|
|
30
|
+
Document declaration supplies a default for the SPA's Application-owned
|
|
31
|
+
Document; a CSR SPA Page does not own a separate Document. All four owners use
|
|
32
|
+
the same `@example/metadata` namespace and schema version. These build-time
|
|
33
|
+
values are not automatically serialized into browser runtime.
|
|
34
|
+
|
|
14
35
|
## Run
|
|
15
36
|
|
|
16
37
|
```bash
|
|
@@ -19,6 +40,8 @@ npm run dev
|
|
|
19
40
|
|
|
20
41
|
## What to look for
|
|
21
42
|
|
|
22
|
-
1.
|
|
23
|
-
2. The
|
|
24
|
-
3.
|
|
43
|
+
1. The resolved Application `@example/metadata` value in `setup`
|
|
44
|
+
2. The resolved Page, Route, and Document `@example/metadata` values in `contributions`
|
|
45
|
+
3. Console output from `buildStart` and `buildEnd` hooks during build
|
|
46
|
+
4. The `<!-- Built with evjs | file.html | N asset(s) -->` comment in the output HTML (injected by `transformHtml`)
|
|
47
|
+
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) {
|
|
@@ -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
|
-
| `
|
|
16
|
-
| `src/pages/
|
|
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,20 @@
|
|
|
1
|
+
# with-tailwind
|
|
2
|
+
|
|
3
|
+
Tailwind CSS v4 through the evjs PostCSS pipeline and unified Core 0.3 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.
|
|
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
|
-
|
|
13
|
-
client: "dist",
|
|
14
|
-
server: "dist-server",
|
|
15
|
-
},
|
|
12
|
+
routing: { mode: "spa" },
|
|
16
13
|
});
|
|
@@ -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
|
-
|
|
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({
|
|
66
|
+
<code>{`export default defineConfig({
|
|
67
|
+
routing: { mode: "spa" },
|
|
68
|
+
});`}</code>
|
|
67
69
|
</pre>
|
|
68
70
|
</div>
|
|
69
71
|
</main>
|
|
@@ -12,8 +12,9 @@ npm run dev
|
|
|
12
12
|
|
|
13
13
|
| File | Purpose |
|
|
14
14
|
|------|---------|
|
|
15
|
-
| `
|
|
16
|
-
| `src/pages/
|
|
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 |
|
|
17
18
|
| `src/apis/trpc.server.ts` | tRPC router and evjs server functions |
|
|
18
19
|
|
|
19
20
|
## What It Demonstrates
|
|
@@ -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
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|