Skip to content

Commit f52a035

Browse files
committed
refactor(examples): prefix devframe RPC/command namespaces with example:
Standardize every example's devframe id (and the RPC/command names, scoped-context namespaces, and hub-level hand-rolled RPC/command names derived from it) under a single example: prefix, replacing the inconsistent devframe-* prefix (files-inspector, streaming-chat) and bare ids (json-render, next-runtime-snapshot, and the demo devframes mounted by the two hub examples) used before. Mount paths, cli.command names, and the postMessage frameId protocol stay decoupled and unprefixed, matching how basePath already worked.
1 parent e1cb53c commit f52a035

36 files changed

Lines changed: 78 additions & 78 deletions

docs/examples/streaming-chat.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Package: `streaming-chat-example` · framework: **Preact + Vite**
1010

1111
## What it shows
1212

13-
- A scoped context (`ctx.scope('devframe-streaming-chat')`) auto-namespaces every id.
13+
- A scoped context (`ctx.scope('example:streaming-chat')`) auto-namespaces every id.
1414
- `my.rpc.streaming.create('tokens', …)` registers a streaming channel for low-latency token rendering.
1515
- `my.rpc.sharedState('history', …)` keeps the message log on the server; each `send` appends a user + assistant pair atomically.
1616
- The producer streams tokens live, then commits the joined content back to shared state when done — so refreshes and new clients see the finished message immediately.

examples/files-inspector/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# devframe-files-inspector
1+
# files-inspector
22

33
A simplified [node-modules-inspector](https://github.com/antfu/node-modules-inspector)-style example built on [devframe](../../packages/devframe). Lists files in the current working directory and renders them through a Preact SPA. Exercises every devframe surface end-to-end:
44

examples/files-inspector/src/client/app.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { nav, navBrand, tab as tabClass, tabsList } from './design'
55
import { About } from './routes/about'
66
import { Home } from './routes/home'
77

8-
const NAMESPACE = 'devframe-files-inspector'
8+
const NAMESPACE = 'example:files-inspector'
99
export type InspectorCtx = DevframeScopedClientContext<typeof NAMESPACE>
1010

1111
const NAV_ITEMS = [

examples/files-inspector/src/client/routes/home.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export function Home({ ctx }: { ctx: InspectorCtx }) {
99
async function refresh() {
1010
setLoading(true)
1111
try {
12-
// Scoped call — `list-files` resolves to `devframe-files-inspector:list-files`.
12+
// Scoped call — `list-files` resolves to `example:files-inspector:list-files`.
1313
const result = await ctx.rpc.call('list-files')
1414
setFiles(result)
1515
}

examples/files-inspector/src/devframe.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const BASE_PATH = '/__devframe-files-inspector/'
77
const distDir = fileURLToPath(new URL('../dist/client', import.meta.url))
88

99
export default defineDevframe({
10-
id: 'devframe-files-inspector',
10+
id: 'example:files-inspector',
1111
name: 'Files Inspector',
1212
version: pkg.version,
1313
packageName: pkg.name,

examples/files-inspector/src/rpc/functions/get-cwd.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import process from 'node:process'
22
import { defineRpcFunction } from 'devframe'
33

44
export const getCwd = defineRpcFunction({
5-
name: 'get-cwd', // scoped registration namespaces it to `devframe-files-inspector:get-cwd`
5+
name: 'get-cwd', // scoped registration namespaces it to `example:files-inspector:get-cwd`
66
type: 'static',
77
jsonSerializable: true,
88
setup: ctx => ({

examples/files-inspector/src/rpc/functions/list-files.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { defineRpcFunction } from 'devframe'
33
import { glob } from 'tinyglobby'
44

55
export const listFiles = defineRpcFunction({
6-
name: 'list-files', // scoped registration namespaces it to `devframe-files-inspector:list-files`
6+
name: 'list-files', // scoped registration namespaces it to `example:files-inspector:list-files`
77
type: 'query',
88
jsonSerializable: true,
99
snapshot: true,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { RpcDefinitionsToFunctionsWithNamespace } from 'devframe/rpc'
22
import { getCwd } from './functions/get-cwd.ts'
33
import { listFiles } from './functions/list-files.ts'
44

5-
export const NAMESPACE = 'devframe-files-inspector'
5+
export const NAMESPACE = 'example:files-inspector'
66

77
export const serverFunctions = [getCwd, listFiles] as const
88

examples/files-inspector/tests/_utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export const CLIENT_DIST = resolve(HERE, '../dist/client')
2929
export function assertClientBuilt(): void {
3030
if (!existsSync(path.join(CLIENT_DIST, 'index.html'))) {
3131
throw new Error(
32-
`[devframe-files-inspector] dist/client missing — run \`pnpm -C examples/files-inspector run build\` first.`,
32+
`[example:files-inspector] dist/client missing — run \`pnpm -C examples/files-inspector run build\` first.`,
3333
)
3434
}
3535
}

examples/files-inspector/tests/dev-server.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ describe('dev-server (CLI surface)', () => {
5959
})
6060
const rpc = createRpcClient<any, any>({}, { channel })
6161

62-
const cwdResult = await rpc.$call('devframe-files-inspector:get-cwd')
62+
const cwdResult = await rpc.$call('example:files-inspector:get-cwd')
6363
expect(cwdResult).toEqual({ cwd })
6464

65-
const files = await rpc.$call('devframe-files-inspector:list-files')
65+
const files = await rpc.$call('example:files-inspector:list-files')
6666
expect(files).toEqual(['README.md', 'package.json', 'sample.txt'])
6767
})
6868
})

0 commit comments

Comments
 (0)