Skip to content

Latest commit

 

History

History

rpc-node

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

README.md

@univerjs/rpc-node

npm version license downloads

@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-node

Usage

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);

Resources