@infinia/plugin-dev
v1.2.0
Published
Vite plugin + simulator host for developing FengYu plugins in an IDE — replaces `fengyu plugin dev`.
Maintainers
Readme
@infinia/plugin-dev
The Vite dev plugin for FengYu plugin authors. It turns the Vite dev server into a FengYu host simulator, so you develop and debug a plugin's UI and worker directly in your IDE — no separate dev CLI process, no JDWP remote attach.
Replaces the former
fengyu plugin devcommand. The CLI now only scaffolds (create) and packages (build); development happens entirely through your editor + this Vite plugin.
What it does
- UI (this plugin) — injects
/__fengyu,/__fengyu/rpc,/__fengyu/ref, and/__fengyu/files/*middleware into Vite./__fengyuserves an iframe shell that runs your real plugin UI (with Vite HMR) and bridges@infinia/plugin-sdk'spostMessagecalls. - Files —
files.open,files.inputDirectory, andfiles.workspaceDirectoryuse the browser picker and snapshot selections into a temporary dev directory.files.outputDirectoryallocates a temporary writable directory andfiles.exportdownloads it as a zip. The simulator also keeps a manual absolute-path field for desktop-style in-place I/O testing. - Worker (separate process, your IDE) — forward
rpc.invoketo afengyu-plugin-devkitdev server you run viaPluginDevMain.main(). Breakpoints in your handlers fire directly.
Install
In your plugin's ui-src/:
npm install --save-dev @infinia/plugin-devFor a Java-worker plugin, also add the devkit as a test-scope Maven dependency in worker/pom.xml:
<dependency>
<groupId>fan.summer.fengyu.sdk</groupId>
<artifactId>fengyu-plugin-devkit</artifactId>
<version>1.1.0</version>
<scope>test</scope>
</dependency>Usage
ui-src/vite.config.ts:
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { fengyuPluginDev } from '@infinia/plugin-dev'
export default defineConfig({
base: './',
plugins: [
vue(),
fengyuPluginDev({
manifest: '../manifest.json',
workerEndpoint: { host: '127.0.0.1', port: 24057 },
}),
],
})Then:
cd ui-src && npm run dev # UI: http://127.0.0.1:5173/__fengyuFor the Java worker, run PluginDevMain.main() (scaffolded into worker/src/test/java/...) from
your IDE's Debug action — it starts the loopback TCP server at 127.0.0.1:24057. Set
breakpoints in your JsonRpcWorker handlers; they fire when the UI calls rpc.invoke.
When workerEndpoint is configured, an unavailable worker is returned as an RPC error. The
simulator never silently substitutes mock data, so a stopped Worker cannot produce a false-positive
frontend test. Use mockWorker: true only when stub responses are intentional.
Temporary file snapshots and output directories are removed when the Vite dev server closes. A browser-selected workspace is a writable copy, matching FengYu's production Web mode; use the manual path field when the Worker must modify the original local directory during desktop-focused debugging.
UI-only plugins
Drop workerEndpoint (or set mockWorker: true) — rpc.invoke returns a deterministic stub so
you can iterate the UI before the worker exists:
fengyuPluginDev({ manifest: './manifest.json', mockWorker: true })License
GPL-3.0
