@univerjs/rpc-node
v1.5.2
Published
Node.js RPC plugins for Univer main-thread and worker communication.
Readme
@univerjs/rpc-node
@univerjs/rpc-node provides the Node.js counterpart for Univer RPC scenarios, allowing main-thread and worker-side plugins to communicate outside the browser.
Package Overview
| Package | UMD global | CSS | Locales | Facade entry | Worker entry |
| --- | --- | :---: | :---: | :---: | :---: |
| @univerjs/rpc-node | UniverRpcNode | No | No | No | Yes |
Installation
pnpm add @univerjs/rpc-node
# or
npm install @univerjs/rpc-nodeUsage
Start with the integration setup for your document type, including its required plugins, styles, and locale resources. The snippet below assumes that setup is complete.
import { fileURLToPath } from 'node:url';
import { UniverRPCNodeMainPlugin } from '@univerjs/rpc-node';
const workerSrc = fileURLToPath(new URL('./worker.js', import.meta.url));
univer.registerPlugin(UniverRPCNodeMainPlugin, { workerSrc });Main-thread plugin classes:
UniverRPCNodeMainPlugin
Worker usage
On the main thread, import UniverRPCNodeMainPlugin from @univerjs/rpc-node. Set workerSrc to the worker module path.
In the worker entry, import UniverRPCNodeWorkerPlugin from @univerjs/rpc-node/worker:
import { UniverRPCNodeWorkerPlugin } from '@univerjs/rpc-node/worker';
univer.registerPlugin(UniverRPCNodeWorkerPlugin);