@evjs/runtime 0.0.1-alpha.7 → 0.0.1-alpha.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 +66 -0
- package/esm/client/context.d.ts +25 -0
- package/esm/client/context.d.ts.map +1 -0
- package/esm/client/context.js +21 -0
- package/esm/client/context.js.map +1 -0
- package/esm/client/create-app.d.ts.map +1 -1
- package/esm/client/create-app.js +1 -0
- package/esm/client/create-app.js.map +1 -1
- package/esm/client/index.d.ts +2 -0
- package/esm/client/index.d.ts.map +1 -1
- package/esm/client/index.js +1 -0
- package/esm/client/index.js.map +1 -1
- package/package.json +3 -2
package/AGENT.md
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# @evjs/runtime
|
|
2
|
+
|
|
3
|
+
Core runtime for the ev React framework. Provides client-side routing, data fetching, and server-side handling.
|
|
4
|
+
|
|
5
|
+
## Client API (`@evjs/runtime/client`)
|
|
6
|
+
|
|
7
|
+
### App Bootstrap
|
|
8
|
+
- `createApp({ routeTree, routerOptions?, queryClientConfig? })` — Bootstrap Router + Query + DOM. Injects `queryClient` into router context.
|
|
9
|
+
- `createAppRootRoute(options)` — Create root route with typed `context.queryClient` for route loaders.
|
|
10
|
+
|
|
11
|
+
### Server Function Proxies
|
|
12
|
+
Always use these instead of raw `useQuery`/`useMutation` for server functions:
|
|
13
|
+
|
|
14
|
+
```tsx
|
|
15
|
+
import { query, mutation, createQueryProxy, createMutationProxy } from "@evjs/runtime/client";
|
|
16
|
+
import { getUsers, createUser } from "./api/users.server";
|
|
17
|
+
|
|
18
|
+
// Direct wrapper
|
|
19
|
+
const { data } = query(getUsers).useQuery([]);
|
|
20
|
+
const { mutate } = mutation(createUser).useMutation();
|
|
21
|
+
|
|
22
|
+
// Module proxy
|
|
23
|
+
const api = { query: createQueryProxy({ getUsers }), mutation: createMutationProxy({ createUser }) };
|
|
24
|
+
api.query.getUsers.useQuery([]);
|
|
25
|
+
|
|
26
|
+
// queryOptions (for loaders, prefetch)
|
|
27
|
+
const opts = query(getUsers).queryOptions([]);
|
|
28
|
+
queryClient.ensureQueryData(opts);
|
|
29
|
+
|
|
30
|
+
// Query key (for invalidation)
|
|
31
|
+
queryClient.invalidateQueries({ queryKey: query(getUsers).queryKey() });
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Route Loader Pattern
|
|
35
|
+
```tsx
|
|
36
|
+
const rootRoute = createAppRootRoute({ component: Root });
|
|
37
|
+
const usersRoute = createRoute({
|
|
38
|
+
getParentRoute: () => rootRoute,
|
|
39
|
+
path: "/users",
|
|
40
|
+
loader: ({ context }) =>
|
|
41
|
+
context.queryClient.ensureQueryData(query(getUsers).queryOptions([])),
|
|
42
|
+
component: UsersPage,
|
|
43
|
+
});
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Routing (re-exports from @tanstack/react-router)
|
|
47
|
+
`createRootRoute`, `createRoute`, `createRouter`, `Link`, `Outlet`, `Navigate`, `useParams`, `useSearch`, `useNavigate`, `useLocation`, `useMatch`, `useLoaderData`, `redirect`, `notFound`, `lazyRouteComponent`
|
|
48
|
+
|
|
49
|
+
### Data (re-exports from @tanstack/react-query)
|
|
50
|
+
`useQuery`, `useMutation`, `useQueryClient`, `useSuspenseQuery`, `QueryClient`, `QueryClientProvider`
|
|
51
|
+
|
|
52
|
+
### Transport
|
|
53
|
+
```tsx
|
|
54
|
+
import { configureTransport } from "@evjs/runtime/client";
|
|
55
|
+
configureTransport({ transport: { send: async (fnId, args) => { /* custom */ } } });
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Server API (`@evjs/runtime/server`)
|
|
59
|
+
|
|
60
|
+
- `createApp(options?)` — Create Hono app with RPC middleware.
|
|
61
|
+
- `runNodeServer(app, { port?, host? })` — Start on Node.js (default port 3001).
|
|
62
|
+
- `registerServerFn(fnId, fn)` — Register server function (called by build-tools).
|
|
63
|
+
- `createRpcMiddleware()` — Standalone Hono RPC sub-app.
|
|
64
|
+
|
|
65
|
+
## Server Functions
|
|
66
|
+
Files must start with `"use server";`, use named async exports, and end in `.server.ts`.
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { QueryClient } from "@tanstack/react-query";
|
|
2
|
+
/** Default context available in route loaders. */
|
|
3
|
+
export interface AppRouteContext {
|
|
4
|
+
queryClient: QueryClient;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Create a root route with the app's default context (queryClient).
|
|
8
|
+
*
|
|
9
|
+
* Use this instead of `createRootRoute` when you want typed access
|
|
10
|
+
* to `context.queryClient` in `loader` / `beforeLoad`.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```tsx
|
|
14
|
+
* const rootRoute = createAppRootRoute({ component: Root });
|
|
15
|
+
*
|
|
16
|
+
* const usersRoute = createRoute({
|
|
17
|
+
* getParentRoute: () => rootRoute,
|
|
18
|
+
* path: "/users",
|
|
19
|
+
* loader: ({ context }) =>
|
|
20
|
+
* context.queryClient.ensureQueryData(query(getUsers).queryOptions([])),
|
|
21
|
+
* });
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare const createAppRootRoute: <TRegister = import("@tanstack/router-core").Register, TRouteContextFn = import("@tanstack/router-core").AnyContext, TBeforeLoadFn = import("@tanstack/router-core").AnyContext, TSearchValidator = undefined, TLoaderDeps extends Record<string, any> = {}, TLoaderFn = undefined, TSSR = unknown, TServerMiddlewares = unknown>(options?: import("@tanstack/router-core").RootRouteOptions<TRegister, TSearchValidator, AppRouteContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn, TSSR, TServerMiddlewares, undefined> | undefined) => import("@tanstack/react-router").RootRoute<TRegister, TSearchValidator, AppRouteContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn, unknown, unknown, TSSR, TServerMiddlewares, undefined>;
|
|
25
|
+
//# sourceMappingURL=context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/client/context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAGzD,kDAAkD;AAClD,MAAM,WAAW,eAAe;IAC9B,WAAW,EAAE,WAAW,CAAC;CAC1B;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,kBAAkB,iuBAAgD,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { createRootRouteWithContext } from "@tanstack/react-router";
|
|
2
|
+
/**
|
|
3
|
+
* Create a root route with the app's default context (queryClient).
|
|
4
|
+
*
|
|
5
|
+
* Use this instead of `createRootRoute` when you want typed access
|
|
6
|
+
* to `context.queryClient` in `loader` / `beforeLoad`.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```tsx
|
|
10
|
+
* const rootRoute = createAppRootRoute({ component: Root });
|
|
11
|
+
*
|
|
12
|
+
* const usersRoute = createRoute({
|
|
13
|
+
* getParentRoute: () => rootRoute,
|
|
14
|
+
* path: "/users",
|
|
15
|
+
* loader: ({ context }) =>
|
|
16
|
+
* context.queryClient.ensureQueryData(query(getUsers).queryOptions([])),
|
|
17
|
+
* });
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export const createAppRootRoute = createRootRouteWithContext();
|
|
21
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/client/context.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,0BAA0B,EAAE,MAAM,wBAAwB,CAAC;AAOpE;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,0BAA0B,EAAmB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-app.d.ts","sourceRoot":"","sources":["../../src/client/create-app.tsx"],"names":[],"mappings":"AAA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AAW,CACZ,CAAC;IACF;;OAEG;IACH,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;CACvC;AAED;;GAEG;AACH,MAAM,WAAW,GAAG;IAClB,oCAAoC;IACpC,MAAM,EAAE,SAAS,CAAC;IAClB,0CAA0C;IAC1C,WAAW,EAAE,WAAW,CAAC;IACzB;;;OAGG;IACH,MAAM,CAAC,SAAS,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI,CAAC;CAC/C;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,SAAS,CAAC,UAAU,SAAS,QAAQ,EACnD,OAAO,EAAE,gBAAgB,CAAC,UAAU,CAAC,GACpC,GAAG,CAgCL"}
|
package/esm/client/create-app.js
CHANGED
|
@@ -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;AAoC9C;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,SAAS,CACvB,OAAqC;IAErC,MAAM,EAAE,SAAS,EAAE,aAAa,EAAE,iBAAiB,EAAE,GAAG,OAAO,CAAC;IAEhE,MAAM,WAAW,GAAG,IAAI,WAAW,CAAC,iBAAiB,CAAC,CAAC;IAEvD,MAAM,MAAM,GAAG,YAAY,CAAC;QAC1B,GAAG,aAAa;QAChB,SAAS;
|
|
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;AAoC9C;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,SAAS,CACvB,OAAqC;IAErC,MAAM,EAAE,SAAS,EAAE,aAAa,EAAE,iBAAiB,EAAE,GAAG,OAAO,CAAC;IAEhE,MAAM,WAAW,GAAG,IAAI,WAAW,CAAC,iBAAiB,CAAC,CAAC;IAEvD,MAAM,MAAM,GAAG,YAAY,CAAC;QAC1B,GAAG,aAAa;QAChB,SAAS;QACT,OAAO,EAAE,EAAE,WAAW,EAAE,GAAG,aAAa,EAAE,OAAO,EAAE;KACd,CAAC,CAAC;IAEzC,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/index.d.ts
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
* Client-side runtime utilities.
|
|
3
3
|
*/
|
|
4
4
|
export * from "@tanstack/react-query";
|
|
5
|
+
export type { AppRouteContext } from "./context";
|
|
6
|
+
export { createAppRootRoute } from "./context";
|
|
5
7
|
export type { App, CreateAppOptions } from "./create-app";
|
|
6
8
|
export { createApp } from "./create-app";
|
|
7
9
|
export * from "./query";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,uBAAuB,CAAC;AACtC,YAAY,EAAE,GAAG,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,YAAY,EACV,cAAc,EACd,eAAe,EACf,gBAAgB,GACjB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,uBAAuB,CAAC;AACtC,YAAY,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAC/C,YAAY,EAAE,GAAG,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,YAAY,EACV,cAAc,EACd,eAAe,EACf,gBAAgB,GACjB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC"}
|
package/esm/client/index.js
CHANGED
package/esm/client/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,uBAAuB,CAAC;AAEtC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AAMxB,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,uBAAuB,CAAC;AAEtC,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAE/C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AAMxB,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@evjs/runtime",
|
|
3
|
-
"version": "0.0.1-alpha.
|
|
3
|
+
"version": "0.0.1-alpha.8",
|
|
4
4
|
"description": "",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@hono/node-server": "^1.19.11",
|
|
@@ -54,6 +54,7 @@
|
|
|
54
54
|
"prepublishOnly": "npm run build"
|
|
55
55
|
},
|
|
56
56
|
"files": [
|
|
57
|
-
"esm"
|
|
57
|
+
"esm",
|
|
58
|
+
"AGENT.md"
|
|
58
59
|
]
|
|
59
60
|
}
|