Skip to content

Commit d56cee4

Browse files
committed
refactor: nest per-rpc files under rpc/functions/
Mirrors @vitejs/devtools-kit conventions and leaves room for sibling files like rpc/utils.ts next to rpc/index.ts as the rpc surface grows.
1 parent 3575a68 commit d56cee4

14 files changed

Lines changed: 23 additions & 23 deletions

File tree

docs/guide/rpc.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ Register it in `setup`:
4242

4343
```ts
4444
import { defineDevframe } from 'devframe'
45-
import { getModules } from './rpc/get-modules'
45+
import { getModules } from './rpc/functions/get-modules'
4646

4747
export default defineDevframe({
4848
id: 'my-devframe',
@@ -53,7 +53,7 @@ export default defineDevframe({
5353
})
5454
```
5555

56-
Place each function in its own file under `src/rpc/`, and barrel them in `src/rpc/index.ts` as `const serverFunctions = [...] as const`. The same array feeds the [type-safe client registry](#type-safe-client-registry) and keeps registration order explicit. When per-file functions need to share setup-time state (channels, shared state handles, loaders), expose it through a `WeakMap<DevToolsNodeContext, T>` in a sibling `src/context.ts`.
56+
Place each function in its own file under `src/rpc/functions/`, and barrel them in `src/rpc/index.ts` as `const serverFunctions = [...] as const`. The same array feeds the [type-safe client registry](#type-safe-client-registry) and keeps registration order explicit. When per-file functions need to share setup-time state (channels, shared state handles, loaders), expose it through a `WeakMap<DevToolsNodeContext, T>` in a sibling `src/context.ts`.
5757

5858
### Naming convention
5959

File renamed without changes.
File renamed without changes.

examples/files-inspector/src/rpc/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { RpcDefinitionsToFunctions } from 'devframe/rpc'
2-
import { getCwd } from './get-cwd'
3-
import { listFiles } from './list-files'
2+
import { getCwd } from './functions/get-cwd'
3+
import { listFiles } from './functions/list-files'
44

55
export const serverFunctions = [getCwd, listFiles] as const
66

examples/next-runtime-snapshot/src/devframe.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import { fileURLToPath } from 'node:url'
22
import { defineDevframe } from 'devframe/types'
33
import { serverFunctions } from './rpc'
44

5-
export type { EnvEntry, EnvSnapshot } from './rpc/env'
6-
export type { MemorySnapshot } from './rpc/memory'
7-
export type { SystemInfo } from './rpc/system'
5+
export type { EnvEntry, EnvSnapshot } from './rpc/functions/env'
6+
export type { MemorySnapshot } from './rpc/functions/memory'
7+
export type { SystemInfo } from './rpc/functions/system'
88

99
const BASE_PATH = '/__next-runtime-snapshot/'
1010
const distDir = fileURLToPath(new URL('../dist/client', import.meta.url))
File renamed without changes.
File renamed without changes.
File renamed without changes.

examples/next-runtime-snapshot/src/rpc/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { RpcDefinitionsToFunctions } from 'devframe/rpc'
2-
import { env } from './env'
3-
import { memory } from './memory'
4-
import { system } from './system'
2+
import { env } from './functions/env'
3+
import { memory } from './functions/memory'
4+
import { system } from './functions/system'
55

66
export const serverFunctions = [system, memory, env] as const
77

examples/streaming-chat/src/rpc/clear.ts renamed to examples/streaming-chat/src/rpc/functions/clear.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { defineRpcFunction } from 'devframe'
2-
import { getStreamingChatContext } from '../context'
2+
import { getStreamingChatContext } from '../../context'
33

44
export const clear = defineRpcFunction({
55
name: 'devframe-streaming-chat:clear',

0 commit comments

Comments
 (0)