You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(recipes): validate openInEditor's editor arg against known editors
Load devframe/utils/launch-editor and devframe/utils/open lazily via
dynamic import in the openInEditor/openInFinder handlers instead of a
top-level import.
openInEditor gains an optional second argument to pick the editor
command explicitly. It's validated against a new KNOWN_EDITORS
constant (and KnownEditor type) via v.picklist, so the RPC surface
can't be used to spawn an arbitrary command.
|`openInEditor`|`devframe:open-in-editor`|`action`|`[filename: string]`| Open the file in the user's editor via [`launchEditor`](./utilities#devframe-utils-launch-editor). Accepts `file`, `file:line`, or `file:line:column`. |
25
+
|`openInEditor`|`devframe:open-in-editor`|`action`|`[filename: string, editor?: KnownEditor]`| Open the file in the user's editor via [`launchEditor`](./utilities#devframe-utils-launch-editor). `filename` accepts `file`, `file:line`, or `file:line:column`. The optional `editor` picks the editor command explicitly instead of relying on auto-detection. |
26
26
|`openInFinder`|`devframe:open-in-finder`|`action`|`[path: string]`| Reveal the path in the OS file explorer via [`open`](./utilities#devframe-utils-open). |
|`KnownEditor`| — | type | — | Union of `KNOWN_EDITORS`. |
28
30
29
-
Both functions are `action`-type RPCs returning `void` and use `valibot` schemas (`v.string()`) for their single argument.
31
+
Both functions are `action`-type RPCs returning `void` and use `valibot` schemas for their arguments — `openInEditor`'s `editor` argument is `v.optional(v.picklist(KNOWN_EDITORS))`, so a value outside `KNOWN_EDITORS` fails validation rather than reaching the underlying `launch-editor` process spawn. Both handlers dynamically `import()`their underlying `devframe/utils/*` implementation, so the `launch-editor` and `open` dependencies only load when the recipe actually runs.
30
32
31
33
The `devframe/recipes/open-helpers` entry (`openHelpers`) remains as a deprecated alias for this module — new code should import `commonRpcFunctions` from `devframe/recipes/common-rpc-functions`.
32
34
@@ -52,7 +54,8 @@ The SPA calls these like any other RPC:
`launchEditor`'s editor auto-detection reads the `LAUNCH_EDITOR` environment variable on the server side — there is no client-side configuration.
61
+
`launchEditor`'s editor auto-detection reads the `LAUNCH_EDITOR` environment variable on the server side when no `editor` argument is passed — there is no client-side configuration.
0 commit comments