@evjs/runtime 0.0.1-rc.6 → 0.0.1-rc.8
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/AGENT.md +292 -35
- package/esm/client/context.d.ts +1 -1
- package/esm/client/context.js +1 -1
- package/esm/client/create-app.d.ts +33 -11
- package/esm/client/create-app.d.ts.map +1 -1
- package/esm/client/create-app.js +12 -5
- package/esm/client/create-app.js.map +1 -1
- package/esm/client/query.d.ts +0 -2
- package/esm/client/query.d.ts.map +1 -1
- package/esm/client/query.js +0 -6
- package/esm/client/query.js.map +1 -1
- package/esm/server/dispatch.d.ts +1 -1
- package/esm/server/dispatch.js +1 -1
- package/package.json +14 -2
- package/esm/serializer.d.ts +0 -31
- package/esm/serializer.d.ts.map +0 -1
- package/esm/serializer.js +0 -7
- package/esm/serializer.js.map +0 -1
package/AGENT.md
CHANGED
|
@@ -1,78 +1,335 @@
|
|
|
1
|
-
# @evjs/runtime
|
|
1
|
+
# @evjs/runtime — Agent Guide
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
> AI-agent reference for developing apps with the `@evjs/runtime` package.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
Core runtime for evjs apps. Three entry points:
|
|
8
|
+
- `@evjs/runtime` + `@evjs/runtime/client` — client-side (React, TanStack)
|
|
9
|
+
- `@evjs/runtime/server` — server-side (Hono)
|
|
10
|
+
- `@evjs/runtime/server/ecma` — edge/serverless adapter
|
|
11
|
+
|
|
12
|
+
## Client API
|
|
6
13
|
|
|
7
14
|
### App Bootstrap
|
|
8
|
-
|
|
9
|
-
|
|
15
|
+
|
|
16
|
+
Separate route definitions from app bootstrap:
|
|
17
|
+
|
|
18
|
+
```tsx
|
|
19
|
+
// src/routes.tsx — route tree + components
|
|
20
|
+
import { createAppRootRoute, createRoute, Outlet } from "@evjs/runtime";
|
|
21
|
+
|
|
22
|
+
function RootLayout() {
|
|
23
|
+
return <div><Outlet /></div>;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const rootRoute = createAppRootRoute({ component: RootLayout });
|
|
27
|
+
|
|
28
|
+
const homeRoute = createRoute({
|
|
29
|
+
getParentRoute: () => rootRoute,
|
|
30
|
+
path: "/",
|
|
31
|
+
component: HomePage,
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
export const routeTree = rootRoute.addChildren([homeRoute]);
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
```tsx
|
|
38
|
+
// src/main.tsx — app bootstrap (keep minimal)
|
|
39
|
+
import { createApp } from "@evjs/runtime";
|
|
40
|
+
import { routeTree } from "./routes";
|
|
41
|
+
|
|
42
|
+
const app = createApp({ routeTree });
|
|
43
|
+
|
|
44
|
+
// REQUIRED for type-safe useParams, useSearch, Link, etc.
|
|
45
|
+
declare module "@tanstack/react-router" {
|
|
46
|
+
interface Register {
|
|
47
|
+
router: typeof app.router;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
app.render("#app");
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
**Key functions:**
|
|
55
|
+
| API | Import | Purpose |
|
|
56
|
+
|-----|--------|---------|
|
|
57
|
+
| `createApp` | `@evjs/runtime` | Bootstrap Router + QueryClient + render to DOM |
|
|
58
|
+
| `createAppRootRoute` | `@evjs/runtime` | Root route with typed `context.queryClient` |
|
|
59
|
+
| `createRoute` | `@evjs/runtime` | Define a route (re-export from TanStack Router) |
|
|
10
60
|
|
|
11
61
|
### Server Function Proxies
|
|
12
|
-
|
|
62
|
+
|
|
63
|
+
**Always use `query()` / `mutation()` wrappers.** Never call `useQuery` with manual fetch.
|
|
13
64
|
|
|
14
65
|
```tsx
|
|
15
|
-
import { query, mutation
|
|
66
|
+
import { query, mutation } from "@evjs/runtime/client";
|
|
16
67
|
import { getUsers, createUser } from "./api/users.server";
|
|
17
68
|
|
|
18
|
-
//
|
|
19
|
-
const { data } = query(getUsers).useQuery(
|
|
20
|
-
const { mutate } = mutation(createUser).useMutation();
|
|
69
|
+
// Data fetching
|
|
70
|
+
const { data, isLoading, error } = query(getUsers).useQuery();
|
|
21
71
|
|
|
22
|
-
//
|
|
23
|
-
const
|
|
24
|
-
api.query.getUsers.useQuery([]);
|
|
72
|
+
// With arguments (spread, not wrapped in array)
|
|
73
|
+
const { data } = query(getUser).useQuery(userId);
|
|
25
74
|
|
|
26
|
-
//
|
|
27
|
-
const
|
|
75
|
+
// Mutations
|
|
76
|
+
const { mutate, isPending } = mutation(createUser).useMutation();
|
|
77
|
+
mutate({ name: "Alice", email: "alice@example.com" });
|
|
78
|
+
|
|
79
|
+
// queryOptions — for route loaders, prefetching, cache control
|
|
80
|
+
const opts = query(getUsers).queryOptions();
|
|
28
81
|
queryClient.ensureQueryData(opts);
|
|
82
|
+
queryClient.prefetchQuery(opts);
|
|
29
83
|
|
|
30
|
-
//
|
|
84
|
+
// Cache invalidation via queryKey
|
|
31
85
|
queryClient.invalidateQueries({ queryKey: query(getUsers).queryKey() });
|
|
86
|
+
|
|
87
|
+
// Auto-invalidation on mutation success
|
|
88
|
+
const { mutate } = mutation(createUser).useMutation({
|
|
89
|
+
invalidates: [getUsers], // auto-invalidates getUsers queries on success
|
|
90
|
+
});
|
|
91
|
+
mutate({ name: "Alice", email: "alice@example.com" });
|
|
92
|
+
|
|
93
|
+
// Module proxy (for grouping)
|
|
94
|
+
import { createQueryProxy, createMutationProxy } from "@evjs/runtime/client";
|
|
95
|
+
const api = {
|
|
96
|
+
query: createQueryProxy({ getUsers, getUser }),
|
|
97
|
+
mutation: createMutationProxy({ createUser }),
|
|
98
|
+
};
|
|
99
|
+
api.query.getUsers.useQuery();
|
|
32
100
|
```
|
|
33
101
|
|
|
34
102
|
### Route Loader Pattern
|
|
103
|
+
|
|
104
|
+
Prefetch data before route renders — no loading spinners:
|
|
105
|
+
|
|
35
106
|
```tsx
|
|
36
|
-
const rootRoute = createAppRootRoute({ component: Root });
|
|
37
107
|
const usersRoute = createRoute({
|
|
38
108
|
getParentRoute: () => rootRoute,
|
|
39
109
|
path: "/users",
|
|
40
110
|
loader: ({ context }) =>
|
|
41
|
-
context.queryClient.ensureQueryData(query(getUsers).queryOptions(
|
|
111
|
+
context.queryClient.ensureQueryData(query(getUsers).queryOptions()),
|
|
42
112
|
component: UsersPage,
|
|
43
113
|
});
|
|
44
114
|
```
|
|
45
115
|
|
|
46
|
-
### Routing
|
|
47
|
-
`createRootRoute`, `createRoute`, `createRouter`, `Link`, `Outlet`, `Navigate`, `useParams`, `useSearch`, `useNavigate`, `useLocation`, `useMatch`, `useLoaderData`, `redirect`, `notFound`, `lazyRouteComponent`
|
|
116
|
+
### Routing
|
|
48
117
|
|
|
49
|
-
### Data (re-exports from @tanstack/react-query)
|
|
50
|
-
`useQuery`, `useMutation`, `useQueryClient`, `useSuspenseQuery`, `QueryClient`, `QueryClientProvider`
|
|
51
118
|
|
|
52
|
-
|
|
119
|
+
**Recommended structure:**
|
|
120
|
+
|
|
121
|
+
```
|
|
122
|
+
src/
|
|
123
|
+
├── main.tsx ← app bootstrap (keep minimal ~12 lines)
|
|
124
|
+
├── routes.tsx ← route tree + components
|
|
125
|
+
├── api/*.server.ts ← server functions
|
|
126
|
+
└── pages/ ← route components (for larger apps)
|
|
127
|
+
├── __root.tsx
|
|
128
|
+
├── home.tsx
|
|
129
|
+
└── posts/
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
> For small apps, define routes and components together in `routes.tsx`.
|
|
133
|
+
> For larger apps, split components into `pages/` directory (like `complex-routing` example).
|
|
134
|
+
|
|
135
|
+
**Key patterns:**
|
|
136
|
+
|
|
137
|
+
| Pattern | Code | Notes |
|
|
138
|
+
|---------|------|-------|
|
|
139
|
+
| Dynamic slug | `path: "$postId"` | Access via `route.useParams()` → `{ postId: string }` |
|
|
140
|
+
| Pathless layout | `id: "dashboard-layout"` | Shared UI without URL segment, use `<Outlet />` |
|
|
141
|
+
| Index route | `path: "/"` inside a group | Shown when parent matches exactly |
|
|
142
|
+
| Catch-all / 404 | `path: "*"` | Matches unmatched URLs |
|
|
143
|
+
| Search params | `validateSearch: (s) => ({ q: s.q ?? "" })` | Access via `route.useSearch()` |
|
|
144
|
+
| Redirect | `beforeLoad: () => { throw redirect({ to: "/posts" }) }` | |
|
|
145
|
+
| Route nesting | `postsRoute.addChildren([indexRoute, detailRoute])` | |
|
|
146
|
+
| Loader prefetch | `loader: ({ params, context }) => context.queryClient.ensureQueryData(...)` | |
|
|
147
|
+
|
|
148
|
+
**Type-safe routing (CRITICAL):**
|
|
149
|
+
|
|
150
|
+
```tsx
|
|
151
|
+
// src/main.tsx — ALWAYS register the router type
|
|
152
|
+
import { createApp } from "@evjs/runtime";
|
|
153
|
+
import { routeTree } from "./routes";
|
|
154
|
+
|
|
155
|
+
const app = createApp({ routeTree });
|
|
156
|
+
|
|
157
|
+
declare module "@tanstack/react-router" {
|
|
158
|
+
interface Register {
|
|
159
|
+
router: typeof app.router;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
app.render("#app");
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
Without this declaration, `useParams()`, `useSearch()`, and `Link` all return `any`.
|
|
167
|
+
|
|
168
|
+
**Use route-scoped hooks** (not global):
|
|
169
|
+
|
|
170
|
+
```tsx
|
|
171
|
+
// ✅ Type-safe — postId: string
|
|
172
|
+
const { postId } = postDetailRoute.useParams();
|
|
173
|
+
|
|
174
|
+
// ❌ Untyped — returns any
|
|
175
|
+
const params = useParams({ from: "/posts/$postId" });
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
### Transport Configuration
|
|
180
|
+
|
|
53
181
|
```tsx
|
|
54
182
|
import { initTransport } from "@evjs/runtime/client";
|
|
55
183
|
|
|
56
|
-
//
|
|
184
|
+
// Default HTTP transport (usually no config needed)
|
|
185
|
+
initTransport({ endpoint: "/api/fn" });
|
|
186
|
+
|
|
187
|
+
// Custom API host (e.g., separate backend)
|
|
57
188
|
initTransport({
|
|
58
189
|
baseUrl: "https://api.example.com",
|
|
59
|
-
endpoint: "/
|
|
190
|
+
endpoint: "/api/fn",
|
|
60
191
|
});
|
|
61
192
|
|
|
62
|
-
//
|
|
63
|
-
initTransport({
|
|
193
|
+
// WebSocket transport
|
|
194
|
+
initTransport({
|
|
195
|
+
transport: {
|
|
196
|
+
send: async (fnId, args) => {
|
|
197
|
+
// custom WebSocket implementation
|
|
198
|
+
},
|
|
199
|
+
},
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
// Custom codec (e.g., MessagePack)
|
|
203
|
+
initTransport({
|
|
204
|
+
codec: {
|
|
205
|
+
serialize: (data) => msgpack.encode(data),
|
|
206
|
+
deserialize: (buffer) => msgpack.decode(buffer),
|
|
207
|
+
contentType: "application/msgpack",
|
|
208
|
+
},
|
|
209
|
+
});
|
|
64
210
|
```
|
|
65
211
|
|
|
66
|
-
|
|
212
|
+
### Routing Re-exports
|
|
67
213
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
- `registerServerFn(fnId, fn)` — Register server function (called by build-tools).
|
|
71
|
-
- `createHandler()` — Standalone Hono server function handler.
|
|
214
|
+
From `@tanstack/react-router`:
|
|
215
|
+
`createRootRoute`, `createRoute`, `createRouter`, `Link`, `Outlet`, `Navigate`, `useParams`, `useSearch`, `useNavigate`, `useLocation`, `useMatch`, `useLoaderData`, `redirect`, `notFound`, `lazyRouteComponent`
|
|
72
216
|
|
|
73
|
-
|
|
217
|
+
### Data Re-exports
|
|
74
218
|
|
|
75
|
-
|
|
219
|
+
From `@tanstack/react-query`:
|
|
220
|
+
`useQuery`, `useMutation`, `useQueryClient`, `useSuspenseQuery`, `QueryClient`, `QueryClientProvider`
|
|
76
221
|
|
|
77
222
|
## Server Functions
|
|
78
|
-
|
|
223
|
+
|
|
224
|
+
```ts
|
|
225
|
+
// src/api/users.server.ts
|
|
226
|
+
"use server";
|
|
227
|
+
|
|
228
|
+
export async function getUsers() {
|
|
229
|
+
return await db.users.findMany();
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
export async function getUser(id: string) {
|
|
233
|
+
const user = await db.users.find(id);
|
|
234
|
+
if (!user) {
|
|
235
|
+
throw new ServerError("User not found", { status: 404, data: { id } });
|
|
236
|
+
}
|
|
237
|
+
return user;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
export async function createUser(name: string, email: string) {
|
|
241
|
+
return await db.users.create({ data: { name, email } });
|
|
242
|
+
}
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
**Rules:**
|
|
246
|
+
- File must start with `"use server";` directive
|
|
247
|
+
- Only **named async function exports** are supported
|
|
248
|
+
- No default exports, no arrow function exports
|
|
249
|
+
- Arguments are positional, transported as a tuple
|
|
250
|
+
- Use `.server.ts` extension or place in `src/api/`
|
|
251
|
+
- Build system auto-discovers — no manual registration
|
|
252
|
+
|
|
253
|
+
## Server API
|
|
254
|
+
|
|
255
|
+
```ts
|
|
256
|
+
import { createApp, serve, createHandler, registerMiddleware } from "@evjs/runtime/server";
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
| API | Purpose |
|
|
260
|
+
|-----|---------|
|
|
261
|
+
| `createApp({ endpoint? })` | Hono app with server function handler |
|
|
262
|
+
| `serve(app, { port?, host? })` | Node.js HTTP server with graceful shutdown |
|
|
263
|
+
| `createHandler()` | Standalone server function Hono handler |
|
|
264
|
+
| `registerServerFn(id, fn)` | Register a server function (used by build tools) |
|
|
265
|
+
| `registerMiddleware(fn)` | Register Hono middleware |
|
|
266
|
+
|
|
267
|
+
### ECMA Adapter (Edge / Serverless)
|
|
268
|
+
|
|
269
|
+
```ts
|
|
270
|
+
import { createFetchHandler } from "@evjs/runtime/server/ecma";
|
|
271
|
+
|
|
272
|
+
const app = createApp({ endpoint: "/api/fn" });
|
|
273
|
+
const handler = createFetchHandler(app);
|
|
274
|
+
|
|
275
|
+
// Deno
|
|
276
|
+
Deno.serve(handler);
|
|
277
|
+
|
|
278
|
+
// Bun / other edge runtimes
|
|
279
|
+
export default { fetch: handler };
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
## Error Handling
|
|
283
|
+
|
|
284
|
+
```ts
|
|
285
|
+
import { ServerError } from "@evjs/runtime";
|
|
286
|
+
|
|
287
|
+
// Server — throw structured errors
|
|
288
|
+
export async function getUser(id: string) {
|
|
289
|
+
const user = await db.users.find(id);
|
|
290
|
+
if (!user) throw new ServerError("User not found", { status: 404, data: { id } });
|
|
291
|
+
return user;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
// Client — catch typed errors
|
|
295
|
+
import { ServerFunctionError } from "@evjs/runtime";
|
|
296
|
+
|
|
297
|
+
try {
|
|
298
|
+
await getUser("123");
|
|
299
|
+
} catch (e) {
|
|
300
|
+
if (e instanceof ServerFunctionError) {
|
|
301
|
+
e.message; // "Server function \"getUser\" threw: User not found"
|
|
302
|
+
e.fnId; // the function ID
|
|
303
|
+
e.status; // 404
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
## Middleware
|
|
309
|
+
|
|
310
|
+
Middleware wraps server function calls, not HTTP requests. Use for auth, logging, rate limiting:
|
|
311
|
+
|
|
312
|
+
```ts
|
|
313
|
+
import { registerMiddleware } from "@evjs/runtime/server";
|
|
314
|
+
|
|
315
|
+
// ctx has { fnId: string, args: unknown[] }
|
|
316
|
+
registerMiddleware(async (ctx, next) => {
|
|
317
|
+
console.log(`Calling ${ctx.fnId} with`, ctx.args);
|
|
318
|
+
const start = Date.now();
|
|
319
|
+
const result = await next();
|
|
320
|
+
console.log(`${ctx.fnId} took ${Date.now() - start}ms`);
|
|
321
|
+
return result;
|
|
322
|
+
});
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
## Common Mistakes
|
|
326
|
+
|
|
327
|
+
1. **Don't use raw `useQuery`** for server functions — use `query(fn).useQuery(args)`
|
|
328
|
+
2. **Arguments are spread, not wrapped** — `query(getUser).useQuery(id)` not `query(getUser).useQuery([id])`
|
|
329
|
+
3. **Don't call server functions directly in components** — wrap with `query()` or `mutation()`
|
|
330
|
+
4. **Don't forget `"use server";`** at the top of `.server.ts` files
|
|
331
|
+
5. **Throw `ServerError`** on the server, catch `ServerFunctionError` on the client
|
|
332
|
+
6. **Always register the router type** — without `declare module "@tanstack/react-router" { ... }`, all route params/search will be `any`
|
|
333
|
+
7. **Use `route.useParams()`** not the global `useParams()` — the route-scoped version gives proper type inference
|
|
334
|
+
8. **Middleware receives `(ctx, next)`** where `ctx = { fnId, args }` — not a Hono context object
|
|
335
|
+
9. **Use `invalidates` on `useMutation()`** for auto cache invalidation — `invalidate()` was removed
|
package/esm/client/context.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ export interface AppRouteContext {
|
|
|
17
17
|
* getParentRoute: () => rootRoute,
|
|
18
18
|
* path: "/users",
|
|
19
19
|
* loader: ({ context }) =>
|
|
20
|
-
* context.queryClient.ensureQueryData(query(getUsers).queryOptions(
|
|
20
|
+
* context.queryClient.ensureQueryData(query(getUsers).queryOptions()),
|
|
21
21
|
* });
|
|
22
22
|
* ```
|
|
23
23
|
*/
|
package/esm/client/context.js
CHANGED
|
@@ -13,7 +13,7 @@ import { createRootRouteWithContext } from "@tanstack/react-router";
|
|
|
13
13
|
* getParentRoute: () => rootRoute,
|
|
14
14
|
* path: "/users",
|
|
15
15
|
* loader: ({ context }) =>
|
|
16
|
-
* context.queryClient.ensureQueryData(query(getUsers).queryOptions(
|
|
16
|
+
* context.queryClient.ensureQueryData(query(getUsers).queryOptions()),
|
|
17
17
|
* });
|
|
18
18
|
* ```
|
|
19
19
|
*/
|
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
import { QueryClient, type QueryClientConfig } from "@tanstack/react-query";
|
|
2
|
-
import type { AnyRoute
|
|
2
|
+
import type { AnyRoute } from "@tanstack/react-router";
|
|
3
3
|
/**
|
|
4
4
|
* Options for creating an ev application.
|
|
5
5
|
*/
|
|
6
6
|
export interface CreateAppOptions<TRouteTree extends AnyRoute> {
|
|
7
7
|
/** The root route tree produced by createRootRoute and addChildren. */
|
|
8
8
|
routeTree: TRouteTree;
|
|
9
|
-
/**
|
|
10
|
-
* Optional configuration for the TanStack Router.
|
|
11
|
-
*/
|
|
12
|
-
routerOptions?: Omit<Parameters<typeof import("@tanstack/react-router").createRouter>[0], "routeTree">;
|
|
13
9
|
/**
|
|
14
10
|
* Optional configuration for the TanStack Query Client.
|
|
15
11
|
*/
|
|
@@ -22,10 +18,25 @@ export interface CreateAppOptions<TRouteTree extends AnyRoute> {
|
|
|
22
18
|
}
|
|
23
19
|
/**
|
|
24
20
|
* An initialized ev application instance.
|
|
21
|
+
*
|
|
22
|
+
* Register the router type for full IDE type safety on `useParams`,
|
|
23
|
+
* `useSearch`, `Link`, etc:
|
|
24
|
+
*
|
|
25
|
+
* ```tsx
|
|
26
|
+
* const app = createApp({ routeTree });
|
|
27
|
+
*
|
|
28
|
+
* declare module "@tanstack/react-router" {
|
|
29
|
+
* interface Register {
|
|
30
|
+
* router: typeof app.router;
|
|
31
|
+
* }
|
|
32
|
+
* }
|
|
33
|
+
*
|
|
34
|
+
* app.render("#app");
|
|
35
|
+
* ```
|
|
25
36
|
*/
|
|
26
|
-
export interface App {
|
|
27
|
-
/** The TanStack Router instance. */
|
|
28
|
-
router:
|
|
37
|
+
export interface App<TRouter> {
|
|
38
|
+
/** The TanStack Router instance (use `typeof app.router` for type registration). */
|
|
39
|
+
router: TRouter;
|
|
29
40
|
/** The TanStack Query Client instance. */
|
|
30
41
|
queryClient: QueryClient;
|
|
31
42
|
/**
|
|
@@ -40,14 +51,25 @@ export interface App {
|
|
|
40
51
|
* This function initializes the router and query client and returns
|
|
41
52
|
* an app object that can be mounted into the DOM.
|
|
42
53
|
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
54
|
+
* Register the router type globally for full IDE type-safety on
|
|
55
|
+
* `useParams`, `useSearch`, `Link`, etc:
|
|
45
56
|
*
|
|
46
57
|
* @example
|
|
47
58
|
* ```tsx
|
|
48
59
|
* const app = createApp({ routeTree });
|
|
60
|
+
*
|
|
61
|
+
* declare module "@tanstack/react-router" {
|
|
62
|
+
* interface Register {
|
|
63
|
+
* router: typeof app.router;
|
|
64
|
+
* }
|
|
65
|
+
* }
|
|
66
|
+
*
|
|
49
67
|
* app.render("#app");
|
|
50
68
|
* ```
|
|
51
69
|
*/
|
|
52
|
-
export declare function createApp<TRouteTree extends AnyRoute>(options: CreateAppOptions<TRouteTree>):
|
|
70
|
+
export declare function createApp<TRouteTree extends AnyRoute>(options: CreateAppOptions<TRouteTree>): {
|
|
71
|
+
router: import("@tanstack/router-core").RouterCore<TRouteTree, "never", false, import("@tanstack/history").RouterHistory, Record<string, any>>;
|
|
72
|
+
queryClient: QueryClient;
|
|
73
|
+
render: (container: string | HTMLElement) => void;
|
|
74
|
+
};
|
|
53
75
|
//# sourceMappingURL=create-app.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-app.d.ts","sourceRoot":"","sources":["../../src/client/create-app.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,KAAK,iBAAiB,EAEvB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,QAAQ,EAAE,
|
|
1
|
+
{"version":3,"file":"create-app.d.ts","sourceRoot":"","sources":["../../src/client/create-app.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,KAAK,iBAAiB,EAEvB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAMvD;;GAEG;AACH,MAAM,WAAW,gBAAgB,CAAC,UAAU,SAAS,QAAQ;IAC3D,uEAAuE;IACvE,SAAS,EAAE,UAAU,CAAC;IACtB;;OAEG;IACH,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;IACtC;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,WAAW,GAAG,CAAC,OAAO;IAC1B,oFAAoF;IACpF,MAAM,EAAE,OAAO,CAAC;IAChB,0CAA0C;IAC1C,WAAW,EAAE,WAAW,CAAC;IACzB;;;OAGG;IACH,MAAM,CAAC,SAAS,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI,CAAC;CAC/C;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,SAAS,CAAC,UAAU,SAAS,QAAQ,EACnD,OAAO,EAAE,gBAAgB,CAAC,UAAU,CAAC;;;wBAgBV,MAAM,GAAG,WAAW,KAAG,IAAI;EAqBvD"}
|
package/esm/client/create-app.js
CHANGED
|
@@ -9,25 +9,32 @@ import { initTransport } from "./transport";
|
|
|
9
9
|
* This function initializes the router and query client and returns
|
|
10
10
|
* an app object that can be mounted into the DOM.
|
|
11
11
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
12
|
+
* Register the router type globally for full IDE type-safety on
|
|
13
|
+
* `useParams`, `useSearch`, `Link`, etc:
|
|
14
14
|
*
|
|
15
15
|
* @example
|
|
16
16
|
* ```tsx
|
|
17
17
|
* const app = createApp({ routeTree });
|
|
18
|
+
*
|
|
19
|
+
* declare module "@tanstack/react-router" {
|
|
20
|
+
* interface Register {
|
|
21
|
+
* router: typeof app.router;
|
|
22
|
+
* }
|
|
23
|
+
* }
|
|
24
|
+
*
|
|
18
25
|
* app.render("#app");
|
|
19
26
|
* ```
|
|
20
27
|
*/
|
|
21
28
|
export function createApp(options) {
|
|
22
|
-
const { routeTree,
|
|
29
|
+
const { routeTree, queryClientConfig, endpoint } = options;
|
|
23
30
|
if (endpoint) {
|
|
24
31
|
initTransport({ endpoint: endpoint });
|
|
25
32
|
}
|
|
26
33
|
const queryClient = new QueryClient(queryClientConfig);
|
|
27
34
|
const router = createRouter({
|
|
28
|
-
...routerOptions,
|
|
29
35
|
routeTree,
|
|
30
|
-
|
|
36
|
+
defaultPreload: "intent",
|
|
37
|
+
context: { queryClient },
|
|
31
38
|
});
|
|
32
39
|
function render(container) {
|
|
33
40
|
const el = typeof container === "string"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-app.js","sourceRoot":"","sources":["../../src/client/create-app.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,WAAW,EAEX,mBAAmB,GACpB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"create-app.js","sourceRoot":"","sources":["../../src/client/create-app.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,WAAW,EAEX,mBAAmB,GACpB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAiD5C;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,UAAU,SAAS,CACvB,OAAqC;IAErC,MAAM,EAAE,SAAS,EAAE,iBAAiB,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;IAE3D,IAAI,QAAQ,EAAE,CAAC;QACb,aAAa,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,CAAC;IACxC,CAAC;IAED,MAAM,WAAW,GAAG,IAAI,WAAW,CAAC,iBAAiB,CAAC,CAAC;IAEvD,MAAM,MAAM,GAAG,YAAY,CAAC;QAC1B,SAAS;QACT,cAAc,EAAE,QAAQ;QACxB,OAAO,EAAE,EAAE,WAAW,EAAqB;KAC5C,CAAC,CAAC;IAEH,SAAS,MAAM,CAAC,SAA+B;QAC7C,MAAM,EAAE,GACN,OAAO,SAAS,KAAK,QAAQ;YAC3B,CAAC,CAAC,QAAQ,CAAC,aAAa,CAAc,SAAS,CAAC;YAChD,CAAC,CAAC,SAAS,CAAC;QAEhB,IAAI,CAAC,EAAE,EAAE,CAAC;YACR,MAAM,IAAI,KAAK,CACb,0CAA0C,MAAM,CAAC,SAAS,CAAC,EAAE,CAC9D,CAAC;QACJ,CAAC;QAED,MAAM,IAAI,GAAG,UAAU,CAAC,EAAE,CAAC,CAAC;QAC5B,IAAI,CAAC,MAAM,CACT,KAAC,mBAAmB,IAAC,MAAM,EAAE,WAAW,YACtC,KAAC,cAAc,IAAC,MAAM,EAAE,MAAM,GAAI,GACd,CACvB,CAAC;IACJ,CAAC;IAED,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,CAAC;AACzC,CAAC"}
|
package/esm/client/query.d.ts
CHANGED
|
@@ -29,8 +29,6 @@ export interface QueryProxyHandler<TArgs extends unknown[], TResponse> {
|
|
|
29
29
|
};
|
|
30
30
|
/** Returns the query key for this function and arguments. */
|
|
31
31
|
queryKey(...args: TArgs): unknown[];
|
|
32
|
-
/** Invalidate cached queries for this function. */
|
|
33
|
-
invalidate(...args: TArgs): void;
|
|
34
32
|
}
|
|
35
33
|
/**
|
|
36
34
|
* The interface for a single server function's mutation proxy.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../src/client/query.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,uBAAuB,EAC5B,KAAK,sBAAsB,EAK5B,MAAM,uBAAuB,CAAC;AAG/B;;GAEG;AACH,MAAM,MAAM,cAAc,CAAC,KAAK,SAAS,OAAO,EAAE,EAAE,SAAS,IAAI,CAC/D,GAAG,IAAI,EAAE,KAAK,KACX,OAAO,CAAC,SAAS,CAAC,CAAC;AAExB;;GAEG;AACH,MAAM,WAAW,iBAAiB,CAAC,KAAK,SAAS,OAAO,EAAE,EAAE,SAA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CAAC;CAC9B,CAAC;AAkIF;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,MAAM,CAAC,EAAE,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,CAE7D;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,MAAM,CAAC,EAAE,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,CAEnE;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,KAAK,EAA2B,CAAC,CAC5C,KAAK,SAAS,OAAO,EAAE,EACvB,SAAS,EAET,EAAE,EAAE,cAAc,CAAC,KAAK,EAAE,SAAS,CAAC,KACjC,iBAAiB,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC,GACvC,UAAU,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AAEtC;;;GAGG;AACH,eAAO,MAAM,QAAQ,EAA8B,CAAC,CAAC,UAAU,EAAE,SAAS,EACxE,EAAE,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,OAAO,CAAC,SAAS,CAAC,KACzC,oBAAoB,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC,GAC/C,aAAa,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC"}
|
package/esm/client/query.js
CHANGED
|
@@ -70,12 +70,6 @@ function createHandler(fn, path) {
|
|
|
70
70
|
queryKey: (...args) => {
|
|
71
71
|
return [fnId || path.join("."), ...args];
|
|
72
72
|
},
|
|
73
|
-
invalidate: (...args) => {
|
|
74
|
-
const queryClient = useQueryClient();
|
|
75
|
-
queryClient.invalidateQueries({
|
|
76
|
-
queryKey: [fnId || path.join("."), ...args],
|
|
77
|
-
});
|
|
78
|
-
},
|
|
79
73
|
path: path.join("."),
|
|
80
74
|
};
|
|
81
75
|
}
|
package/esm/client/query.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query.js","sourceRoot":"","sources":["../../src/client/query.ts"],"names":[],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51
51
|
}
|
|
52
52
|
export type DispatchResult = DispatchSuccess | DispatchError;
|
|
53
53
|
/**
|
|
54
|
-
* Dispatch
|
|
54
|
+
* Dispatch a server function call to a registered server function.
|
|
55
55
|
*
|
|
56
56
|
* @param fnId - The unique function ID.
|
|
57
57
|
* @param args - The arguments to pass to the function.
|
package/esm/server/dispatch.js
CHANGED
|
@@ -18,7 +18,7 @@ export function registerMiddleware(fn) {
|
|
|
18
18
|
middlewares.push(fn);
|
|
19
19
|
}
|
|
20
20
|
/**
|
|
21
|
-
* Dispatch
|
|
21
|
+
* Dispatch a server function call to a registered server function.
|
|
22
22
|
*
|
|
23
23
|
* @param fnId - The unique function ID.
|
|
24
24
|
* @param args - The arguments to pass to the function.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@evjs/runtime",
|
|
3
|
-
"version": "0.0.1-rc.
|
|
4
|
-
"description": "",
|
|
3
|
+
"version": "0.0.1-rc.8",
|
|
4
|
+
"description": "Client and server runtime for the evjs framework",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@hono/node-server": "^1.19.11",
|
|
7
7
|
"@logtape/logtape": "^2.0.4",
|
|
@@ -69,11 +69,23 @@
|
|
|
69
69
|
},
|
|
70
70
|
"scripts": {
|
|
71
71
|
"build": "tsc",
|
|
72
|
+
"test": "vitest run",
|
|
72
73
|
"check-types": "tsc --noEmit",
|
|
73
74
|
"prepublishOnly": "npm run build"
|
|
74
75
|
},
|
|
75
76
|
"files": [
|
|
76
77
|
"esm",
|
|
77
78
|
"AGENT.md"
|
|
79
|
+
],
|
|
80
|
+
"keywords": [
|
|
81
|
+
"evjs",
|
|
82
|
+
"react",
|
|
83
|
+
"server-functions",
|
|
84
|
+
"rpc",
|
|
85
|
+
"routing",
|
|
86
|
+
"tanstack",
|
|
87
|
+
"typescript",
|
|
88
|
+
"full-stack",
|
|
89
|
+
"framework"
|
|
78
90
|
]
|
|
79
91
|
}
|
package/esm/serializer.d.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Pluggable serialization interface.
|
|
3
|
-
*
|
|
4
|
-
* By default the framework uses JSON. Implement this interface to use
|
|
5
|
-
* a custom serializer (e.g. protobuf, msgpack, superjson, devalue).
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* ```ts
|
|
9
|
-
* import superjson from "superjson";
|
|
10
|
-
*
|
|
11
|
-
* const superJsonSerializer: Serializer = {
|
|
12
|
-
* contentType: "application/json",
|
|
13
|
-
* serialize: (data) => superjson.stringify(data),
|
|
14
|
-
* deserialize: (raw) => superjson.parse(raw as string),
|
|
15
|
-
* };
|
|
16
|
-
* ```
|
|
17
|
-
*/
|
|
18
|
-
export interface Serializer {
|
|
19
|
-
/**
|
|
20
|
-
* Content-Type header value for the serialized format.
|
|
21
|
-
* Defaults to `"application/json"` when not specified.
|
|
22
|
-
*/
|
|
23
|
-
contentType?: string;
|
|
24
|
-
/** Serialize a JS value for transmission. */
|
|
25
|
-
serialize(data: unknown): string | ArrayBuffer;
|
|
26
|
-
/** Deserialize a raw payload back to a JS value. */
|
|
27
|
-
deserialize(raw: string | ArrayBuffer): unknown;
|
|
28
|
-
}
|
|
29
|
-
/** Built-in JSON serializer (the default). */
|
|
30
|
-
export declare const jsonSerializer: Serializer;
|
|
31
|
-
//# sourceMappingURL=serializer.d.ts.map
|
package/esm/serializer.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"serializer.d.ts","sourceRoot":"","sources":["../src/serializer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,WAAW,UAAU;IACzB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,6CAA6C;IAC7C,SAAS,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,WAAW,CAAC;IAE/C,oDAAoD;IACpD,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,WAAW,GAAG,OAAO,CAAC;CACjD;AAED,8CAA8C;AAC9C,eAAO,MAAM,cAAc,EAAE,UAI5B,CAAC"}
|
package/esm/serializer.js
DELETED
package/esm/serializer.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"serializer.js","sourceRoot":"","sources":["../src/serializer.ts"],"names":[],"mappings":"AA+BA,8CAA8C;AAC9C,MAAM,CAAC,MAAM,cAAc,GAAe;IACxC,WAAW,EAAE,kBAAkB;IAC/B,SAAS,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;IACzC,WAAW,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,GAAa,CAAC;CAChD,CAAC"}
|