Some checks failed
📦 Build / build (push) Has been cancelled
🧪 CI Test / test shard (1/4) (push) Has been cancelled
🧪 CI Test / test shard (2/4) (push) Has been cancelled
🧪 CI Test / test shard (3/4) (push) Has been cancelled
🧪 CI Test / test shard (4/4) (push) Has been cancelled
🧪 CI Test / test (push) Has been cancelled
🧪 CI Test / eslint (push) Has been cancelled
🧪 CI Test / typecheck (push) Has been cancelled
🔫 Sync to Pro / dispatch-sync (push) Has been cancelled
🔮 Sync Mirror / sync (push) Has been cancelled
47 lines
1.6 KiB
Markdown
47 lines
1.6 KiB
Markdown
# @univerjs/rpc-node
|
|
|
|
[](https://npmjs.com/package/@univerjs/rpc-node)
|
|
[](https://npmjs.com/package/@univerjs/rpc-node)
|
|
[](https://npmjs.com/package/@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 |
|
|
| --- | --- | :---: | :---: | :---: |
|
|
| `@univerjs/rpc-node` | `UniverRpcNode` | No | No | No |
|
|
|
|
## Installation
|
|
|
|
```sh
|
|
pnpm add @univerjs/rpc-node
|
|
# or
|
|
npm install @univerjs/rpc-node
|
|
```
|
|
|
|
Keep all `@univerjs/*` packages on the same version.
|
|
|
|
## Usage
|
|
|
|
```ts
|
|
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 });
|
|
```
|
|
|
|
The referenced worker module must create its own Univer instance and register `UniverRPCNodeWorkerPlugin`; see the [Node.js worker example](../../examples/src/node/sdk/worker.ts).
|
|
|
|
Exported plugin classes:
|
|
|
|
- `UniverRPCNodeMainPlugin`
|
|
- `UniverRPCNodeWorkerPlugin`
|
|
|
|
## Resources
|
|
|
|
- [Documentation](https://docs.univer.ai)
|
|
- [NPM package](https://npmjs.com/package/@univerjs/rpc-node)
|
|
- [GitHub repository](https://github.com/dream-num/univer)
|