@evjs/runtime 0.0.1-alpha.9 → 0.0.1-rc.2
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 +13 -1
- package/README.md +18 -1
- package/esm/client/index.d.ts +2 -1
- package/esm/client/index.d.ts.map +1 -1
- package/esm/client/index.js +1 -1
- package/esm/client/index.js.map +1 -1
- package/esm/client/query.d.ts +2 -8
- package/esm/client/query.d.ts.map +1 -1
- package/esm/client/query.js +5 -7
- package/esm/client/query.js.map +1 -1
- package/esm/client/transport.d.ts +5 -0
- package/esm/client/transport.d.ts.map +1 -1
- package/esm/client/transport.js +23 -6
- package/esm/client/transport.js.map +1 -1
- package/esm/index.d.ts +3 -4
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +6 -4
- package/esm/index.js.map +1 -1
- package/esm/server/app.d.ts +0 -2
- package/esm/server/app.d.ts.map +1 -1
- package/esm/server/app.js +2 -0
- package/esm/server/app.js.map +1 -1
- package/esm/server/environments/ecma.d.ts +19 -0
- package/esm/server/environments/ecma.d.ts.map +1 -0
- package/esm/server/environments/ecma.js +20 -0
- package/esm/server/environments/ecma.js.map +1 -0
- package/esm/server/environments/node.d.ts +3 -0
- package/esm/server/environments/node.d.ts.map +1 -1
- package/esm/server/environments/node.js +13 -1
- package/esm/server/environments/node.js.map +1 -1
- package/esm/server/handler.d.ts +0 -11
- package/esm/server/handler.d.ts.map +1 -1
- package/esm/server/handler.js +8 -16
- package/esm/server/handler.js.map +1 -1
- package/esm/server/index.d.ts +11 -4
- package/esm/server/index.d.ts.map +1 -1
- package/esm/server/index.js +10 -3
- package/esm/server/index.js.map +1 -1
- package/esm/server/register.d.ts +22 -0
- package/esm/server/register.d.ts.map +1 -0
- package/esm/server/register.js +22 -0
- package/esm/server/register.js.map +1 -0
- package/package.json +27 -8
package/AGENT.md
CHANGED
|
@@ -52,15 +52,27 @@ const usersRoute = createRoute({
|
|
|
52
52
|
### Transport
|
|
53
53
|
```tsx
|
|
54
54
|
import { configureTransport } from "@evjs/runtime/client";
|
|
55
|
+
|
|
56
|
+
// Simple: custom base URL and endpoint path
|
|
57
|
+
configureTransport({
|
|
58
|
+
baseUrl: "https://api.example.com",
|
|
59
|
+
endpoint: "/server-function", // default: "/api/rpc"
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
// Advanced: fully custom transport
|
|
55
63
|
configureTransport({ transport: { send: async (fnId, args) => { /* custom */ } } });
|
|
56
64
|
```
|
|
57
65
|
|
|
58
66
|
## Server API (`@evjs/runtime/server`)
|
|
59
67
|
|
|
60
|
-
- `createApp(options?)` — Create Hono app with RPC middleware.
|
|
68
|
+
- `createApp(options?)` — Create Hono app with RPC middleware. Options: `{ rpcEndpoint?: string, port?: number }`. Default RPC path: `/api/rpc`.
|
|
61
69
|
- `runNodeServer(app, { port?, host? })` — Start on Node.js (default port 3001).
|
|
62
70
|
- `registerServerFn(fnId, fn)` — Register server function (called by build-tools).
|
|
63
71
|
- `createRpcMiddleware()` — Standalone Hono RPC sub-app.
|
|
64
72
|
|
|
73
|
+
## ECMA Adapter (`@evjs/runtime/server/ecma`)
|
|
74
|
+
|
|
75
|
+
- `createHandler(app)` — Wraps a Hono app for deployment to Deno, Bun, Cloudflare Workers, or any Fetch API-compatible runtime.
|
|
76
|
+
|
|
65
77
|
## Server Functions
|
|
66
78
|
Files must start with `"use server";`, use named async exports, and end in `.server.ts`.
|
package/README.md
CHANGED
|
@@ -27,11 +27,17 @@ npm install @evjs/runtime
|
|
|
27
27
|
|
|
28
28
|
| Export | Description |
|
|
29
29
|
|--------|-------------|
|
|
30
|
-
| `createApp` | Create a Hono app with RPC middleware |
|
|
30
|
+
| `createApp` | Create a Hono app with RPC middleware (`rpcEndpoint` option) |
|
|
31
31
|
| `runNodeServer` | Start the app on Node.js (default port 3001) |
|
|
32
32
|
| `registerServerFn` | Register a server function in the RPC registry |
|
|
33
33
|
| `createRpcMiddleware` | Standalone Hono sub-app for RPC dispatch |
|
|
34
34
|
|
|
35
|
+
### `@evjs/runtime/server/ecma`
|
|
36
|
+
|
|
37
|
+
| Export | Description |
|
|
38
|
+
|--------|-------------|
|
|
39
|
+
| `createHandler` | Wrap Hono app for Deno, Bun, Cloudflare Workers |
|
|
40
|
+
|
|
35
41
|
## Usage
|
|
36
42
|
|
|
37
43
|
### Client
|
|
@@ -63,6 +69,17 @@ runNodeServer(app, { port: 3001 });
|
|
|
63
69
|
|
|
64
70
|
In development, `ev dev` with `runner` configured in `EvWebpackPlugin` handles this automatically.
|
|
65
71
|
|
|
72
|
+
### Custom Endpoint
|
|
73
|
+
|
|
74
|
+
```ts
|
|
75
|
+
import { configureTransport } from "@evjs/runtime/client";
|
|
76
|
+
|
|
77
|
+
configureTransport({
|
|
78
|
+
baseUrl: "https://api.example.com",
|
|
79
|
+
endpoint: "/server-function", // default: "/api/rpc"
|
|
80
|
+
});
|
|
81
|
+
```
|
|
82
|
+
|
|
66
83
|
### Custom Transport
|
|
67
84
|
|
|
68
85
|
```ts
|
package/esm/client/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Client-side runtime utilities.
|
|
3
3
|
*/
|
|
4
|
-
export
|
|
4
|
+
export type { QueryClientConfig, QueryKey, UseInfiniteQueryOptions, UseInfiniteQueryResult, UseMutationOptions, UseMutationResult, UseQueryOptions, UseQueryResult, UseSuspenseQueryOptions, UseSuspenseQueryResult, } from "@tanstack/react-query";
|
|
5
|
+
export { keepPreviousData, QueryClient, QueryClientProvider, useInfiniteQuery, useIsFetching, useMutation, usePrefetchQuery, useQuery, useQueryClient, useSuspenseQuery, } from "@tanstack/react-query";
|
|
5
6
|
export type { AppRouteContext } from "./context";
|
|
6
7
|
export { createAppRootRoute } from "./context";
|
|
7
8
|
export type { App, CreateAppOptions } from "./create-app";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA;;GAEG;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,YAAY,EACV,iBAAiB,EACjB,QAAQ,EACR,uBAAuB,EACvB,sBAAsB,EACtB,kBAAkB,EAClB,iBAAiB,EACjB,eAAe,EACf,cAAc,EACd,uBAAuB,EACvB,sBAAsB,GACvB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,gBAAgB,EAChB,WAAW,EACX,mBAAmB,EACnB,gBAAgB,EAChB,aAAa,EACb,WAAW,EACX,gBAAgB,EAChB,QAAQ,EACR,cAAc,EACd,gBAAgB,GACjB,MAAM,uBAAuB,CAAC;AAC/B,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
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Client-side runtime utilities.
|
|
3
3
|
*/
|
|
4
|
-
export
|
|
4
|
+
export { keepPreviousData, QueryClient, QueryClientProvider, useInfiniteQuery, useIsFetching, useMutation, usePrefetchQuery, useQuery, useQueryClient, useSuspenseQuery, } from "@tanstack/react-query";
|
|
5
5
|
export { createAppRootRoute } from "./context";
|
|
6
6
|
export { createApp } from "./create-app";
|
|
7
7
|
export * from "./query";
|
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;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAeH,OAAO,EACL,gBAAgB,EAChB,WAAW,EACX,mBAAmB,EACnB,gBAAgB,EAChB,aAAa,EACb,WAAW,EACX,gBAAgB,EAChB,QAAQ,EACR,cAAc,EACd,gBAAgB,GACjB,MAAM,uBAAuB,CAAC;AAE/B,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/esm/client/query.d.ts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { type UseMutationOptions, type UseMutationResult, type UseQueryOptions, type UseQueryResult, type UseSuspenseQueryOptions, type UseSuspenseQueryResult } from "@tanstack/react-query";
|
|
2
2
|
/**
|
|
3
|
-
* A server function stub as generated by the
|
|
3
|
+
* A server function stub as generated by the build-tools loader.
|
|
4
4
|
*/
|
|
5
|
-
export type ServerFunction<TArgs extends unknown[], TResponse> = (
|
|
6
|
-
_evId?: string;
|
|
7
|
-
};
|
|
5
|
+
export type ServerFunction<TArgs extends unknown[], TResponse> = (...args: TArgs) => Promise<TResponse>;
|
|
8
6
|
/**
|
|
9
7
|
* The interface for a single server function's query proxy.
|
|
10
8
|
*/
|
|
@@ -22,8 +20,6 @@ export interface QueryProxyHandler<TArgs extends unknown[], TResponse> {
|
|
|
22
20
|
};
|
|
23
21
|
/** Returns the query key for this function and arguments. */
|
|
24
22
|
queryKey(args?: TArgs): unknown[];
|
|
25
|
-
/** The stable function ID (internal). */
|
|
26
|
-
_evId: string;
|
|
27
23
|
}
|
|
28
24
|
/**
|
|
29
25
|
* The interface for a single server function's mutation proxy.
|
|
@@ -37,8 +33,6 @@ export interface MutationProxyHandler<TVariables, TResponse> {
|
|
|
37
33
|
mutationOptions(options?: Omit<UseMutationOptions<TResponse, Error, TVariables>, "mutationFn">): UseMutationOptions<TResponse, Error, TVariables> & {
|
|
38
34
|
mutationFn: (variables: TVariables) => Promise<TResponse>;
|
|
39
35
|
};
|
|
40
|
-
/** The stable function ID (internal). */
|
|
41
|
-
_evId: string;
|
|
42
36
|
}
|
|
43
37
|
/**
|
|
44
38
|
* A recursive proxy that maps property access to server function stubs.
|
|
@@ -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,EAI5B,MAAM,uBAAuB,CAAC;
|
|
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,EAI5B,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,SAAS;IACnE,yCAAyC;IACzC,CAAC,GAAG,IAAI,EAAE,KAAK,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;IAErC,wCAAwC;IACxC,QAAQ,CACN,IAAI,EAAE,KAAK,EACX,OAAO,CAAC,EAAE,IAAI,CAAC,eAAe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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
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import { useMutation, useQuery, useSuspenseQuery, } from "@tanstack/react-query";
|
|
2
|
+
import { getFnId } from "./transport";
|
|
2
3
|
function createHandler(fn, path) {
|
|
3
4
|
return {
|
|
4
5
|
useQuery: (args = [], options) => {
|
|
5
6
|
return useQuery({
|
|
6
7
|
...options,
|
|
7
|
-
queryKey: [fn
|
|
8
|
+
queryKey: [getFnId(fn) || path.join("."), ...args],
|
|
8
9
|
queryFn: () => fn(...args),
|
|
9
10
|
});
|
|
10
11
|
},
|
|
11
12
|
useSuspenseQuery: (args = [], options) => {
|
|
12
13
|
return useSuspenseQuery({
|
|
13
14
|
...options,
|
|
14
|
-
queryKey: [fn
|
|
15
|
+
queryKey: [getFnId(fn) || path.join("."), ...args],
|
|
15
16
|
queryFn: () => fn(...args),
|
|
16
17
|
});
|
|
17
18
|
},
|
|
@@ -24,7 +25,7 @@ function createHandler(fn, path) {
|
|
|
24
25
|
queryOptions: (args = [], options) => {
|
|
25
26
|
return {
|
|
26
27
|
...options,
|
|
27
|
-
queryKey: [fn
|
|
28
|
+
queryKey: [getFnId(fn) || path.join("."), ...args],
|
|
28
29
|
queryFn: () => fn(...args),
|
|
29
30
|
};
|
|
30
31
|
},
|
|
@@ -35,9 +36,8 @@ function createHandler(fn, path) {
|
|
|
35
36
|
};
|
|
36
37
|
},
|
|
37
38
|
queryKey: (args = []) => {
|
|
38
|
-
return [fn
|
|
39
|
+
return [getFnId(fn) || path.join("."), ...args];
|
|
39
40
|
},
|
|
40
|
-
_evId: fn._evId,
|
|
41
41
|
path: path.join("."),
|
|
42
42
|
};
|
|
43
43
|
}
|
|
@@ -45,8 +45,6 @@ function createProxy(type, source, path = []) {
|
|
|
45
45
|
const target = source ?? (() => { });
|
|
46
46
|
return new Proxy(target, {
|
|
47
47
|
get(_target, prop) {
|
|
48
|
-
if (prop === "_evId")
|
|
49
|
-
return _target._evId;
|
|
50
48
|
const newPath = [...path, prop];
|
|
51
49
|
const val = source
|
|
52
50
|
? source[prop]
|
package/esm/client/query.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query.js","sourceRoot":"","sources":["../../src/client/query.ts"],"names":[],"mappings":"AAAA,OAAO,EAOL,WAAW,EACX,QAAQ,EACR,gBAAgB,GACjB,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"query.js","sourceRoot":"","sources":["../../src/client/query.ts"],"names":[],"mappings":"AAAA,OAAO,EAOL,WAAW,EACX,QAAQ,EACR,gBAAgB,GACjB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AA2FtC,SAAS,aAAa,CAAC,EAAsC,EAAE,IAAc;IAC3E,OAAO;QACL,QAAQ,EAAE,CACR,OAAkB,EAAE,EACpB,OAAuE,EACvE,EAAE;YACF,OAAO,QAAQ,CAAC;gBACd,GAAG,OAAO;gBACV,QAAQ,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,IAAI,CAAC;gBAClD,OAAO,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC;aAC3B,CAAC,CAAC;QACL,CAAC;QACD,gBAAgB,EAAE,CAChB,OAAkB,EAAE,EACpB,OAGC,EACD,EAAE;YACF,OAAO,gBAAgB,CAAC;gBACtB,GAAG,OAAO;gBACV,QAAQ,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,IAAI,CAAC;gBAClD,OAAO,EAAE,GAAG,EAAE,C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,EAAE,IAAI,CAAC,CAAC;YAChC,MAAM,GAAG,GAAG,MAAM;gBAChB,CAAC,CAAE,MAAkC,CAAC,IAAI,CAAC;gBAC3C,CAAC,CAAC,SAAS,CAAC;YAEd,iEAAiE;YACjE,IAAI,OAAO,GAAG,KAAK,UAAU,EAAE,CAAC;gBAC9B,OAAO,aAAa,CAClB,GAAoD,EACpD,OAAO,CACR,CAAC;YACJ,CAAC;YAED,kCAAkC;YAClC,OAAO,WAAW,CAAC,IAAI,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;QACzC,CAAC;QACD,KAAK,CAAC,OAAO,EAAE,QAAQ,EAAE,IAAI;YAC3B,MAAM,EAAE,GAAG,IAAI,CAAC,CAAC,CAAkD,CAAC;YACpE,IAAI,OAAO,EAAE,KAAK,UAAU,EAAE,CAAC;gBAC7B,OAAO,aAAa,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;YACjC,CAAC;YACD,OAAO,EAAE,CAAC,CAAC,WAAW;QACxB,CAAC;KACF,CAAC,CAAC;AACL,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAI,MAAU;IAC5C,OAAO,WAAW,CAAC,OAAO,EAAE,MAAM,CAAkB,CAAC;AACvD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,mBAAmB,CAAI,MAAU;IAC/C,OAAO,WAAW,CAAC,UAAU,EAAE,MAAM,CAAqB,CAAC;AAC7D,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,WAAW,CAAC,OAAO,CAMH,CAAC;AAEtC;;;GAGG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,WAAW,CAAC,UAAU,CAGN,CAAC"}
|
|
@@ -47,4 +47,9 @@ export interface TransportOptions {
|
|
|
47
47
|
* customise the endpoint URL or provide a custom transport.
|
|
48
48
|
*/
|
|
49
49
|
export declare function configureTransport(options: TransportOptions): void;
|
|
50
|
+
/**
|
|
51
|
+
* Look up the internal function ID for a server function stub.
|
|
52
|
+
* Returns undefined if the function is not a registered server function.
|
|
53
|
+
*/
|
|
54
|
+
export declare function getFnId(fn: (...args: any[]) => any): string | undefined;
|
|
50
55
|
//# sourceMappingURL=transport.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../../src/client/transport.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH;;;;;;GAMG;AACH,MAAM,WAAW,cAAc;IAC7B,oGAAoG;IACpG,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,uCAAuC;IACvC,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B,2DAA2D;IAC3D,IAAI,CACF,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,OAAO,EAAE,EACf,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,OAAO,CAAC,CAAC;IAEpB;;;;;;OAMG;IACH,MAAM,CAAC,CACL,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,OAAO,EAAE,EACf,OAAO,CAAC,EAAE,cAAc,GACvB,cAAc,CAAC,UAAU,CAAC,CAAC;CAC/B;AAED,MAAM,WAAW,gBAAgB;IAC/B,qEAAqE;IACrE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,gEAAgE;IAChE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,6EAA6E;IAC7E,SAAS,CAAC,EAAE,eAAe,CAAC;CAC7B;AAwDD;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,gBAAgB,GAAG,IAAI,CASlE"}
|
|
1
|
+
{"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../../src/client/transport.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH;;;;;;GAMG;AACH,MAAM,WAAW,cAAc;IAC7B,oGAAoG;IACpG,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,uCAAuC;IACvC,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B,2DAA2D;IAC3D,IAAI,CACF,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,OAAO,EAAE,EACf,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,OAAO,CAAC,CAAC;IAEpB;;;;;;OAMG;IACH,MAAM,CAAC,CACL,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,OAAO,EAAE,EACf,OAAO,CAAC,EAAE,cAAc,GACvB,cAAc,CAAC,UAAU,CAAC,CAAC;CAC/B;AAED,MAAM,WAAW,gBAAgB;IAC/B,qEAAqE;IACrE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,gEAAgE;IAChE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,6EAA6E;IAC7E,SAAS,CAAC,EAAE,eAAe,CAAC;CAC7B;AAwDD;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,gBAAgB,GAAG,IAAI,CASlE;AAiCD;;;GAGG;AAEH,wBAAgB,OAAO,CAAC,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,GAAG,MAAM,GAAG,SAAS,CAEvE"}
|
package/esm/client/transport.js
CHANGED
|
@@ -58,14 +58,31 @@ export function configureTransport(options) {
|
|
|
58
58
|
*
|
|
59
59
|
* @internal This function is auto-injected by the Webpack loader.
|
|
60
60
|
* Do not call directly — use server functions as normal imports instead.
|
|
61
|
-
*
|
|
62
|
-
* @param fnId - The unique identifier assigned to the server function by the
|
|
63
|
-
* Webpack loader (e.g. `"user_server_getUser"`).
|
|
64
|
-
* @param args - The arguments to pass to the server function. Must be
|
|
65
|
-
* JSON-serializable.
|
|
66
|
-
* @returns A promise that resolves with the server function's return value.
|
|
67
61
|
*/
|
|
68
62
|
export async function __ev_call(fnId, args, context) {
|
|
69
63
|
return getTransport().send(fnId, args, context);
|
|
70
64
|
}
|
|
65
|
+
/**
|
|
66
|
+
* Internal registry mapping server function references to their IDs.
|
|
67
|
+
* Uses WeakMap so function stubs can be garbage collected.
|
|
68
|
+
*/
|
|
69
|
+
// biome-ignore lint/suspicious/noExplicitAny: must accept any function shape
|
|
70
|
+
const fnIdRegistry = new WeakMap();
|
|
71
|
+
/**
|
|
72
|
+
* Register a server function stub with its ID.
|
|
73
|
+
*
|
|
74
|
+
* @internal Called by build-tools codegen. Do not use directly.
|
|
75
|
+
*/
|
|
76
|
+
// biome-ignore lint/suspicious/noExplicitAny: must accept any function shape
|
|
77
|
+
export function __ev_register(fn, fnId) {
|
|
78
|
+
fnIdRegistry.set(fn, fnId);
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Look up the internal function ID for a server function stub.
|
|
82
|
+
* Returns undefined if the function is not a registered server function.
|
|
83
|
+
*/
|
|
84
|
+
// biome-ignore lint/suspicious/noExplicitAny: must accept any function shape
|
|
85
|
+
export function getFnId(fn) {
|
|
86
|
+
return fnIdRegistry.get(fn);
|
|
87
|
+
}
|
|
71
88
|
//# sourceMappingURL=transport.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transport.js","sourceRoot":"","sources":["../../src/client/transport.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAmDpD;;GAEG;AACH,SAAS,oBAAoB,CAC3B,OAAe,EACf,QAAgB;IAEhB,OAAO;QACL,KAAK,CAAC,IAAI,CACR,IAAY,EACZ,IAAe,EACf,OAAwB;YAExB,MAAM,GAAG,GAAG,GAAG,OAAO,GAAG,QAAQ,EAAE,CAAC;YAEpC,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE;gBAC3B,MAAM,EAAE,MAAM;gBACd,OAAO,EAAE;oBACP,cAAc,EAAE,kBAAkB;oB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
|
|
7
|
-
export * as client from "./client/index";
|
|
8
|
-
export * as server from "./server/index";
|
|
9
8
|
//# sourceMappingURL=index.d.ts.map
|
package/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}
|
package/esm/index.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/**
|
|
2
3
|
* @evjs/runtime
|
|
3
4
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
5
|
+
* Import from subpaths instead:
|
|
6
|
+
* - @evjs/runtime/client
|
|
7
|
+
* - @evjs/runtime/server
|
|
6
8
|
*/
|
|
7
|
-
|
|
8
|
-
|
|
9
|
+
throw new Error('[ev] Do not import from "@evjs/runtime" directly. ' +
|
|
10
|
+
'Use "@evjs/runtime/client" or "@evjs/runtime/server" instead.');
|
|
9
11
|
//# sourceMappingURL=index.js.map
|
package/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;AAEH,MAAM,IAAI,KAAK,CACb,oDAAoD;IAClD,+DAA+D,CAClE,CAAC"}
|
package/esm/server/app.d.ts
CHANGED
package/esm/server/app.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../src/server/app.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAI5B,6BAA6B;AAC7B,MAAM,WAAW,gBAAgB;IAC/B,
|
|
1
|
+
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../src/server/app.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAI5B,6BAA6B;AAC7B,MAAM,WAAW,gBAAgB;IAC/B,iDAAiD;IACjD,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CAAC,OAAO,CAAC,EAAE,gBAAgB,GAAG,IAAI,CAY1D"}
|
package/esm/server/app.js
CHANGED
|
@@ -19,6 +19,8 @@ import { createRpcMiddleware } from "./handler";
|
|
|
19
19
|
export function createApp(options) {
|
|
20
20
|
const { rpcEndpoint = DEFAULT_RPC_ENDPOINT } = options ?? {};
|
|
21
21
|
const app = new Hono();
|
|
22
|
+
// Health check for load balancers / container orchestrators
|
|
23
|
+
app.get("/health", (c) => c.json({ status: "ok" }));
|
|
22
24
|
// Mount RPC endpoint
|
|
23
25
|
app.route(rpcEndpoint, createRpcMiddleware());
|
|
24
26
|
return app;
|
package/esm/server/app.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.js","sourceRoot":"","sources":["../../src/server/app.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"app.js","sourceRoot":"","sources":["../../src/server/app.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAQhD;;;;;;;;GAQG;AACH,MAAM,UAAU,SAAS,CAAC,OAA0B;IAClD,MAAM,EAAE,WAAW,GAAG,oBAAoB,EAAE,GAAG,OAAO,IAAI,EAAE,CAAC;IAE7D,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC;IAEvB,4DAA4D;IAC5D,GAAG,CAAC,GAAG,CAAC,SAAS,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IAEpD,qBAAqB;IACrB,GAAG,CAAC,KAAK,CAAC,WAAW,EAAE,mBAAmB,EAAE,CAAC,CAAC;IAE9C,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Hono } from "hono";
|
|
2
|
+
/**
|
|
3
|
+
* ECMA-standard environment adapter.
|
|
4
|
+
*
|
|
5
|
+
* Exports the Hono app's fetch handler as a standard ECMA-compatible
|
|
6
|
+
* module. Works in any runtime that supports the Fetch API standard
|
|
7
|
+
* (Deno, Bun, Cloudflare Workers, Vercel Edge, etc.).
|
|
8
|
+
*
|
|
9
|
+
* Usage:
|
|
10
|
+
* ```ts
|
|
11
|
+
* import app from "./dist/server/index.js";
|
|
12
|
+
* import { createHandler } from "@evjs/runtime/server/ecma";
|
|
13
|
+
* export default createHandler(app);
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export declare function createHandler(app: Hono): {
|
|
17
|
+
fetch: (request: Request, Env?: unknown, executionCtx?: import("hono").ExecutionContext) => Response | Promise<Response>;
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=ecma.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ecma.d.ts","sourceRoot":"","sources":["../../../src/server/environments/ecma.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAEjC;;;;;;;;;;;;;GAaG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,IAAI;;EAItC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ECMA-standard environment adapter.
|
|
3
|
+
*
|
|
4
|
+
* Exports the Hono app's fetch handler as a standard ECMA-compatible
|
|
5
|
+
* module. Works in any runtime that supports the Fetch API standard
|
|
6
|
+
* (Deno, Bun, Cloudflare Workers, Vercel Edge, etc.).
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
* ```ts
|
|
10
|
+
* import app from "./dist/server/index.js";
|
|
11
|
+
* import { createHandler } from "@evjs/runtime/server/ecma";
|
|
12
|
+
* export default createHandler(app);
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export function createHandler(app) {
|
|
16
|
+
return {
|
|
17
|
+
fetch: app.fetch,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=ecma.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ecma.js","sourceRoot":"","sources":["../../../src/server/environments/ecma.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,aAAa,CAAC,GAAS;IACrC,OAAO;QACL,KAAK,EAAE,GAAG,CAAC,KAAK;KACjB,CAAC;AACJ,CAAC"}
|
|
@@ -6,6 +6,9 @@ export interface NodeRunnerOptions {
|
|
|
6
6
|
/**
|
|
7
7
|
* Runner plugin for Node.js environments.
|
|
8
8
|
* Takes a compiled Hono app and starts a native Node HTTP server.
|
|
9
|
+
*
|
|
10
|
+
* Port resolution order: options.port → PORT env → 3001 default.
|
|
11
|
+
* Registers SIGTERM/SIGINT handlers for graceful shutdown.
|
|
9
12
|
*/
|
|
10
13
|
export declare function runNodeServer(app: Hono, options?: NodeRunnerOptions): import("@hono/node-server").ServerType;
|
|
11
14
|
//# sourceMappingURL=node.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../../src/server/environments/node.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAIjC,MAAM,WAAW,iBAAiB;IAChC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED
|
|
1
|
+
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../../src/server/environments/node.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAIjC,MAAM,WAAW,iBAAiB;IAChC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,IAAI,EAAE,OAAO,CAAC,EAAE,iBAAiB,0CAsBnE"}
|
|
@@ -4,9 +4,12 @@ const logger = getLogger(["evjs", "server"]);
|
|
|
4
4
|
/**
|
|
5
5
|
* Runner plugin for Node.js environments.
|
|
6
6
|
* Takes a compiled Hono app and starts a native Node HTTP server.
|
|
7
|
+
*
|
|
8
|
+
* Port resolution order: options.port → PORT env → 3001 default.
|
|
9
|
+
* Registers SIGTERM/SIGINT handlers for graceful shutdown.
|
|
7
10
|
*/
|
|
8
11
|
export function runNodeServer(app, options) {
|
|
9
|
-
const port = options?.port || 3001;
|
|
12
|
+
const port = options?.port || Number(process.env.PORT) || 3001;
|
|
10
13
|
const hostname = options?.host;
|
|
11
14
|
const server = serve({ fetch: app.fetch, port, hostname }, (info) => {
|
|
12
15
|
const address = info.address === "0.0.0.0" || info.address === "::"
|
|
@@ -14,6 +17,15 @@ export function runNodeServer(app, options) {
|
|
|
14
17
|
: info.address;
|
|
15
18
|
logger.info `Server API ready at http://${address}:${info.port}`;
|
|
16
19
|
});
|
|
20
|
+
// Graceful shutdown for container/orchestrator environments
|
|
21
|
+
const shutdown = () => {
|
|
22
|
+
logger.info `Shutting down server...`;
|
|
23
|
+
server.close(() => process.exit(0));
|
|
24
|
+
// Force exit after 10 seconds if connections don't drain
|
|
25
|
+
setTimeout(() => process.exit(1), 10_000).unref();
|
|
26
|
+
};
|
|
27
|
+
process.on("SIGTERM", shutdown);
|
|
28
|
+
process.on("SIGINT", shutdown);
|
|
17
29
|
return server;
|
|
18
30
|
}
|
|
19
31
|
//# sourceMappingURL=node.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.js","sourceRoot":"","sources":["../../../src/server/environments/node.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAG7C,MAAM,MAAM,GAAG,SAAS,CAAC,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC;AAO7C
|
|
1
|
+
{"version":3,"file":"node.js","sourceRoot":"","sources":["../../../src/server/environments/node.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAG7C,MAAM,MAAM,GAAG,SAAS,CAAC,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC;AAO7C;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAAC,GAAS,EAAE,OAA2B;IAClE,MAAM,IAAI,GAAG,OAAO,EAAE,IAAI,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC;IAC/D,MAAM,QAAQ,GAAG,OAAO,EAAE,IAAI,CAAC;IAC/B,MAAM,MAAM,GAAG,KAAK,CAAC,EAAE,KAAK,EAAE,GAAG,CAAC,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,CAAC,IAAI,EAAE,EAAE;QAClE,MAAM,OAAO,GACX,IAAI,CAAC,OAAO,KAAK,SAAS,IAAI,IAAI,CAAC,OAAO,KAAK,IAAI;YACjD,CAAC,CAAC,WAAW;YACb,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC;QACnB,MAAM,CAAC,IAAI,CAAA,8BAA8B,OAAO,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;IAClE,CAAC,CAAC,CAAC;IAEH,4DAA4D;IAC5D,MAAM,QAAQ,GAAG,GAAG,EAAE;QACpB,MAAM,CAAC,IAAI,CAAA,yBAAyB,CAAC;QACrC,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;QACpC,yDAAyD;QACzD,UAAU,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,KAAK,EAAE,CAAC;IACpD,CAAC,CAAC;IACF,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;IAChC,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;IAE/B,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/esm/server/handler.d.ts
CHANGED
|
@@ -6,16 +6,6 @@
|
|
|
6
6
|
* `POST /api/rpc` requests and dispatches them to the correct function.
|
|
7
7
|
*/
|
|
8
8
|
import { Hono } from "hono";
|
|
9
|
-
/** A registered server function. */
|
|
10
|
-
type ServerFn = (...args: unknown[]) => Promise<unknown>;
|
|
11
|
-
/**
|
|
12
|
-
* Register a server function so it can be invoked via RPC.
|
|
13
|
-
* Called automatically by the Webpack-transformed server bundles at load time.
|
|
14
|
-
*
|
|
15
|
-
* @param fnId - The unique ID for this function.
|
|
16
|
-
* @param fn - The actual function implementation.
|
|
17
|
-
*/
|
|
18
|
-
export declare function registerServerFn(fnId: string, fn: ServerFn): void;
|
|
19
9
|
/**
|
|
20
10
|
* Create a Hono sub-app that handles RPC requests.
|
|
21
11
|
*
|
|
@@ -25,5 +15,4 @@ export declare function registerServerFn(fnId: string, fn: ServerFn): void;
|
|
|
25
15
|
* @returns A Hono app to be mounted at the desired path (e.g. `/api/rpc`).
|
|
26
16
|
*/
|
|
27
17
|
export declare function createRpcMiddleware(): Hono;
|
|
28
|
-
export {};
|
|
29
18
|
//# sourceMappingURL=handler.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../src/server/handler.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../src/server/handler.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAG5B;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,IAAI,IAAI,CA+B1C"}
|
package/esm/server/handler.js
CHANGED
|
@@ -6,18 +6,7 @@
|
|
|
6
6
|
* `POST /api/rpc` requests and dispatches them to the correct function.
|
|
7
7
|
*/
|
|
8
8
|
import { Hono } from "hono";
|
|
9
|
-
|
|
10
|
-
const registry = new Map();
|
|
11
|
-
/**
|
|
12
|
-
* Register a server function so it can be invoked via RPC.
|
|
13
|
-
* Called automatically by the Webpack-transformed server bundles at load time.
|
|
14
|
-
*
|
|
15
|
-
* @param fnId - The unique ID for this function.
|
|
16
|
-
* @param fn - The actual function implementation.
|
|
17
|
-
*/
|
|
18
|
-
export function registerServerFn(fnId, fn) {
|
|
19
|
-
registry.set(fnId, fn);
|
|
20
|
-
}
|
|
9
|
+
import { registry } from "./register";
|
|
21
10
|
/**
|
|
22
11
|
* Create a Hono sub-app that handles RPC requests.
|
|
23
12
|
*
|
|
@@ -29,13 +18,16 @@ export function registerServerFn(fnId, fn) {
|
|
|
29
18
|
export function createRpcMiddleware() {
|
|
30
19
|
const rpc = new Hono();
|
|
31
20
|
rpc.post("/", async (c) => {
|
|
32
|
-
const
|
|
33
|
-
|
|
21
|
+
const body = await c.req.json();
|
|
22
|
+
if (!body.fnId || typeof body.fnId !== "string") {
|
|
23
|
+
return c.json({ error: "Missing or invalid 'fnId' in request body" }, 400);
|
|
24
|
+
}
|
|
25
|
+
const fn = registry.get(body.fnId);
|
|
34
26
|
if (!fn) {
|
|
35
|
-
return c.json({ error: `Server function "${fnId}" not found` }, 404);
|
|
27
|
+
return c.json({ error: `Server function "${body.fnId}" not found` }, 404);
|
|
36
28
|
}
|
|
37
29
|
try {
|
|
38
|
-
const result = await fn(...(args ?? []));
|
|
30
|
+
const result = await fn(...(body.args ?? []));
|
|
39
31
|
return c.json({ result });
|
|
40
32
|
}
|
|
41
33
|
catch (err) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handler.js","sourceRoot":"","sources":["../../src/server/handler.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"handler.js","sourceRoot":"","sources":["../../src/server/handler.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC;;;;;;;GAOG;AACH,MAAM,UAAU,mBAAmB;IACjC,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC;IAEvB,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;QACxB,MAAM,IAAI,GAAG,MAAM,CAAC,CAAC,GAAG,CAAC,IAAI,EAGzB,CAAC;QAEL,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YAChD,OAAO,CAAC,CAAC,IAAI,CACX,EAAE,KAAK,EAAE,2CAA2C,EAAE,EACtD,GAAG,CACJ,CAAC;QACJ,CAAC;QAED,MAAM,EAAE,GAAG,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACnC,IAAI,CAAC,EAAE,EAAE,CAAC;YACR,OAAO,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,oBAAoB,IAAI,CAAC,IAAI,aAAa,EAAE,EAAE,GAAG,CAAC,CAAC;QAC5E,CAAC;QAED,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC;YAC9C,OAAO,CAAC,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;QAC5B,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,OAAO,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YACjE,OAAO,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,GAAG,CAAC,CAAC;QACzC,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,GAAG,CAAC;AACb,CAAC"}
|
package/esm/server/index.d.ts
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Server-side runtime utilities.
|
|
2
|
+
* Server-side runtime utilities (environment-agnostic).
|
|
3
|
+
*
|
|
4
|
+
* For environment-specific adapters, use:
|
|
5
|
+
* - @evjs/runtime/server/node
|
|
6
|
+
* - @evjs/runtime/server/ecma
|
|
7
|
+
*
|
|
8
|
+
* For minimal function registration (no Hono), use:
|
|
9
|
+
* - @evjs/runtime/server/register
|
|
3
10
|
*/
|
|
4
11
|
export type { CreateAppOptions } from "./app";
|
|
5
12
|
export { createApp } from "./app";
|
|
6
|
-
export
|
|
7
|
-
export {
|
|
8
|
-
export {
|
|
13
|
+
export { createRpcMiddleware } from "./handler";
|
|
14
|
+
export type { ServerFn } from "./register";
|
|
15
|
+
export { registerServerFn } from "./register";
|
|
9
16
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,YAAY,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAChD,YAAY,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC"}
|
package/esm/server/index.js
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Server-side runtime utilities.
|
|
2
|
+
* Server-side runtime utilities (environment-agnostic).
|
|
3
|
+
*
|
|
4
|
+
* For environment-specific adapters, use:
|
|
5
|
+
* - @evjs/runtime/server/node
|
|
6
|
+
* - @evjs/runtime/server/ecma
|
|
7
|
+
*
|
|
8
|
+
* For minimal function registration (no Hono), use:
|
|
9
|
+
* - @evjs/runtime/server/register
|
|
3
10
|
*/
|
|
4
11
|
export { createApp } from "./app";
|
|
5
|
-
export {
|
|
6
|
-
export {
|
|
12
|
+
export { createRpcMiddleware } from "./handler";
|
|
13
|
+
export { registerServerFn } from "./register";
|
|
7
14
|
//# sourceMappingURL=index.js.map
|
package/esm/server/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAEhD,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal server function registry.
|
|
3
|
+
*
|
|
4
|
+
* This module is intentionally decoupled from the framework runtime
|
|
5
|
+
* (Hono, RPC handler, etc.) so that the server bundle only contains
|
|
6
|
+
* user-defined functions + this tiny registry.
|
|
7
|
+
*
|
|
8
|
+
* The framework runtime imports FROM this module to read the registry.
|
|
9
|
+
*/
|
|
10
|
+
/** A registered server function. */
|
|
11
|
+
export type ServerFn = (...args: unknown[]) => Promise<unknown>;
|
|
12
|
+
/** Internal registry mapping function IDs to implementations. */
|
|
13
|
+
export declare const registry: Map<string, ServerFn>;
|
|
14
|
+
/**
|
|
15
|
+
* Register a server function so it can be invoked via RPC.
|
|
16
|
+
* Called automatically by the build-tools-transformed server bundles at load time.
|
|
17
|
+
*
|
|
18
|
+
* @param fnId - The unique ID for this function.
|
|
19
|
+
* @param fn - The actual function implementation.
|
|
20
|
+
*/
|
|
21
|
+
export declare function registerServerFn(fnId: string, fn: ServerFn): void;
|
|
22
|
+
//# sourceMappingURL=register.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../../src/server/register.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,oCAAoC;AACpC,MAAM,MAAM,QAAQ,GAAG,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;AAEhE,iEAAiE;AACjE,eAAO,MAAM,QAAQ,uBAA8B,CAAC;AAEpD;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,QAAQ,GAAG,IAAI,CAEjE"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal server function registry.
|
|
3
|
+
*
|
|
4
|
+
* This module is intentionally decoupled from the framework runtime
|
|
5
|
+
* (Hono, RPC handler, etc.) so that the server bundle only contains
|
|
6
|
+
* user-defined functions + this tiny registry.
|
|
7
|
+
*
|
|
8
|
+
* The framework runtime imports FROM this module to read the registry.
|
|
9
|
+
*/
|
|
10
|
+
/** Internal registry mapping function IDs to implementations. */
|
|
11
|
+
export const registry = new Map();
|
|
12
|
+
/**
|
|
13
|
+
* Register a server function so it can be invoked via RPC.
|
|
14
|
+
* Called automatically by the build-tools-transformed server bundles at load time.
|
|
15
|
+
*
|
|
16
|
+
* @param fnId - The unique ID for this function.
|
|
17
|
+
* @param fn - The actual function implementation.
|
|
18
|
+
*/
|
|
19
|
+
export function registerServerFn(fnId, fn) {
|
|
20
|
+
registry.set(fnId, fn);
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=register.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"register.js","sourceRoot":"","sources":["../../src/server/register.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAKH,iEAAiE;AACjE,MAAM,CAAC,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAoB,CAAC;AAEpD;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAY,EAAE,EAAY;IACzD,QAAQ,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;AACzB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@evjs/runtime",
|
|
3
|
-
"version": "0.0.1-
|
|
3
|
+
"version": "0.0.1-rc.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@hono/node-server": "^1.19.11",
|
|
@@ -16,13 +16,13 @@
|
|
|
16
16
|
"devDependencies": {
|
|
17
17
|
"typescript": "^5.7.3"
|
|
18
18
|
},
|
|
19
|
-
"homepage": "https://github.com/
|
|
19
|
+
"homepage": "https://github.com/evaijs/evjs#readme",
|
|
20
20
|
"bugs": {
|
|
21
|
-
"url": "https://github.com/
|
|
21
|
+
"url": "https://github.com/evaijs/evjs/issues"
|
|
22
22
|
},
|
|
23
23
|
"repository": {
|
|
24
24
|
"type": "git",
|
|
25
|
-
"url": "git+https://github.com/
|
|
25
|
+
"url": "git+https://github.com/evaijs/evjs.git"
|
|
26
26
|
},
|
|
27
27
|
"license": "MIT",
|
|
28
28
|
"author": "xusd320",
|
|
@@ -33,19 +33,38 @@
|
|
|
33
33
|
"exports": {
|
|
34
34
|
".": {
|
|
35
35
|
"types": "./esm/index.d.ts",
|
|
36
|
-
"import": "./esm/index.js"
|
|
36
|
+
"import": "./esm/index.js",
|
|
37
|
+
"default": "./esm/index.js"
|
|
37
38
|
},
|
|
38
39
|
"./client": {
|
|
39
40
|
"types": "./esm/client/index.d.ts",
|
|
40
|
-
"import": "./esm/client/index.js"
|
|
41
|
+
"import": "./esm/client/index.js",
|
|
42
|
+
"default": "./esm/client/index.js"
|
|
41
43
|
},
|
|
42
44
|
"./client/transport": {
|
|
43
45
|
"types": "./esm/client/transport.d.ts",
|
|
44
|
-
"import": "./esm/client/transport.js"
|
|
46
|
+
"import": "./esm/client/transport.js",
|
|
47
|
+
"default": "./esm/client/transport.js"
|
|
45
48
|
},
|
|
46
49
|
"./server": {
|
|
47
50
|
"types": "./esm/server/index.d.ts",
|
|
48
|
-
"import": "./esm/server/index.js"
|
|
51
|
+
"import": "./esm/server/index.js",
|
|
52
|
+
"default": "./esm/server/index.js"
|
|
53
|
+
},
|
|
54
|
+
"./server/register": {
|
|
55
|
+
"types": "./esm/server/register.d.ts",
|
|
56
|
+
"import": "./esm/server/register.js",
|
|
57
|
+
"default": "./esm/server/register.js"
|
|
58
|
+
},
|
|
59
|
+
"./server/node": {
|
|
60
|
+
"types": "./esm/server/environments/node.d.ts",
|
|
61
|
+
"import": "./esm/server/environments/node.js",
|
|
62
|
+
"default": "./esm/server/environments/node.js"
|
|
63
|
+
},
|
|
64
|
+
"./server/ecma": {
|
|
65
|
+
"types": "./esm/server/environments/ecma.d.ts",
|
|
66
|
+
"import": "./esm/server/environments/ecma.js",
|
|
67
|
+
"default": "./esm/server/environments/ecma.js"
|
|
49
68
|
}
|
|
50
69
|
},
|
|
51
70
|
"scripts": {
|