|
1 | | -import { launchEditor } from 'devframe/utils/launch-editor' |
2 | | -import { open } from 'devframe/utils/open' |
3 | | -import * as v from 'valibot' |
4 | | -import { defineRpcFunction } from '../rpc/define' |
| 1 | +// Deprecated compatibility shim for the open helpers recipe. |
| 2 | +// |
| 3 | +// Prefer the canonical `devframe/recipes/common-rpc-functions` entry. This |
| 4 | +// module re-exports the same implementation under the historical name so |
| 5 | +// existing imports keep working. It will be removed in a future major |
| 6 | +// release. |
| 7 | +import { commonRpcFunctions } from './common-rpc-functions' |
5 | 8 |
|
6 | | -/** |
7 | | - * Prebuilt RPC action that opens a file in the user's configured editor. |
8 | | - * |
9 | | - * Registered name: `devframe:open-in-editor`. |
10 | | - * |
11 | | - * ```ts |
12 | | - * import { openInEditor } from 'devframe/recipes/open-helpers' |
13 | | - * |
14 | | - * defineDevframe({ |
15 | | - * id: 'my-tool', |
16 | | - * name: 'My Tool', |
17 | | - * setup(ctx) { |
18 | | - * ctx.rpc.register(openInEditor) |
19 | | - * }, |
20 | | - * }) |
21 | | - * ``` |
22 | | - */ |
23 | | -export const openInEditor = defineRpcFunction({ |
24 | | - name: 'devframe:open-in-editor', |
25 | | - type: 'action', |
26 | | - jsonSerializable: true, |
27 | | - args: [v.string()], |
28 | | - returns: v.void(), |
29 | | - async handler(filename: string) { |
30 | | - launchEditor(filename) |
31 | | - }, |
32 | | -}) |
| 9 | +export { openInEditor, openInFinder } from './common-rpc-functions' |
33 | 10 |
|
34 | | -/** |
35 | | - * Prebuilt RPC action that reveals a path in the OS file explorer. |
36 | | - * |
37 | | - * Registered name: `devframe:open-in-finder`. |
38 | | - * |
39 | | - * ```ts |
40 | | - * import { openInFinder } from 'devframe/recipes/open-helpers' |
41 | | - * |
42 | | - * ctx.rpc.register(openInFinder) |
43 | | - * ``` |
44 | | - */ |
45 | | -export const openInFinder = defineRpcFunction({ |
46 | | - name: 'devframe:open-in-finder', |
47 | | - type: 'action', |
48 | | - jsonSerializable: true, |
49 | | - args: [v.string()], |
50 | | - returns: v.void(), |
51 | | - async handler(path: string) { |
52 | | - await open(path) |
53 | | - }, |
54 | | -}) |
55 | | - |
56 | | -/** |
57 | | - * Convenience array bundling both helpers so callers can register them |
58 | | - * in a single `forEach`. |
59 | | - * |
60 | | - * ```ts |
61 | | - * import { openHelpers } from 'devframe/recipes/open-helpers' |
62 | | - * |
63 | | - * openHelpers.forEach(fn => ctx.rpc.register(fn)) |
64 | | - * ``` |
65 | | - */ |
66 | | -export const openHelpers = [openInEditor, openInFinder] as const |
| 11 | +/** @deprecated Use `commonRpcFunctions` from `devframe/recipes/common-rpc-functions` instead. */ |
| 12 | +export const openHelpers: typeof commonRpcFunctions = commonRpcFunctions |
0 commit comments