@univerjs/rpc-node 0.5.4-nightly.202501200849 → 0.5.5-experimental.20250122-3362a4a
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index.js +1 -1
- package/lib/es/index.js +67 -64
- package/lib/umd/index.js +1 -1
- package/package.json +4 -4
package/lib/cjs/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var __defProp=Object.defineProperty;var __defNormalProp=(obj,key,value)=>key in obj?__defProp(obj,key,{enumerable:!0,configurable:!0,writable:!0,value}):obj[key]=value;var __name=(target,value)=>__defProp(target,"name",{value,configurable:!0});var __publicField=(obj,key,value)=>__defNormalProp(obj,typeof key!="symbol"?key+"":key,value);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const node_child_process=require("node:child_process"),process=require("node:process"),core=require("@univerjs/core"),rpc=require("@univerjs/rpc"),rxjs=require("rxjs");var __defProp2=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__decorateClass=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp2(target,key,result),result},"__decorateClass"),__decorateParam=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam");const UNIVER_RPC_NODE_MAIN_PLUGIN_CONFIG_KEY="node-rpc.main.config";var _a;exports.UniverRPCNodeMainPlugin=(_a=class extends core.Plugin{constructor(_config,_injector,_configService){super(),this._config=_config,this._injector=_injector,this._configService=_configService,this._configService.setConfig(UNIVER_RPC_NODE_MAIN_PLUGIN_CONFIG_KEY,this._config)}onStarting(){const{workerSrc}=this._config,messageProtocol=createNodeMessagePortOnMain(this._injector,workerSrc);[[rpc.IRPCChannelService,{useFactory:__name(()=>new rpc.ChannelService(messageProtocol),"useFactory")}],[rpc.DataSyncPrimaryController],[rpc.IRemoteSyncService,{useClass:rpc.RemoteSyncPrimaryService}]].forEach(dependency=>this._injector.add(dependency)),this._injector.get(rpc.DataSyncPrimaryController)}},__name(_a,"UniverRPCNodeMainPlugin"),__publicField(_a,"pluginName","UNIVER_RPC_NODE_MAIN_PLUGIN"),_a);exports.UniverRPCNodeMainPlugin=__decorateClass([__decorateParam(1,core.Inject(core.Injector)),__decorateParam(2,core.IConfigService)],exports.UniverRPCNodeMainPlugin);var _a2;exports.UniverRPCNodeWorkerPlugin=(_a2=class extends core.Plugin{constructor(_config,_injector){super(),this._config=_config,this._injector=_injector}onStarting(){[[rpc.DataSyncReplicaController],[rpc.IRPCChannelService,{useFactory:__name(()=>new rpc.ChannelService(createNodeWorkerMessageProtocol()),"useFactory")}],[rpc.IRemoteInstanceService,{useClass:rpc.WebWorkerRemoteInstanceService}]].forEach(d=>this._injector.add(d)),this._injector.get(rpc.DataSyncReplicaController)}},__name(_a2,"UniverRPCNodeWorkerPlugin"),__publicField(_a2,"pluginName","UNIVER_RPC_NODE_WORKER_PLUGIN"),_a2);exports.UniverRPCNodeWorkerPlugin=__decorateClass([__decorateParam(1,core.Inject(core.Injector))],exports.UniverRPCNodeWorkerPlugin);function createNodeMessagePortOnMain(injector,path){const logService=injector.get(core.ILogService),child=node_child_process.fork(path);return child.on("spawn",()=>logService.log("Child computing process spawned!")),child.on("error",error=>logService.error(error)),{send(message){child.send(message)},onMessage:new rxjs.Observable(subscriber=>{const handler=__name(message=>{subscriber.next(message)},"handler");return child.on("message",handler),()=>child.off("message",handler)}).pipe(rxjs.shareReplay(1))}}__name(createNodeMessagePortOnMain,"createNodeMessagePortOnMain");function createNodeWorkerMessageProtocol(){return{send(message){process.send(message)},onMessage:new rxjs.Observable(subscriber=>{const handler=__name(event=>{subscriber.next(event)},"handler");return process.on("message",handler),()=>process.off("message",handler)}).pipe(rxjs.shareReplay(1))}}__name(createNodeWorkerMessageProtocol,"createNodeWorkerMessageProtocol");
|
package/lib/es/index.js
CHANGED
|
@@ -1,83 +1,86 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value;
|
|
3
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: !0 });
|
|
4
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key != "symbol" ? key + "" : key, value);
|
|
5
|
+
import { fork } from "node:child_process";
|
|
6
|
+
import process from "node:process";
|
|
7
|
+
import { Inject, Injector, Plugin, IConfigService, ILogService } from "@univerjs/core";
|
|
8
|
+
import { DataSyncPrimaryController, DataSyncReplicaController, IRPCChannelService, ChannelService, IRemoteInstanceService, WebWorkerRemoteInstanceService, IRemoteSyncService, RemoteSyncPrimaryService } from "@univerjs/rpc";
|
|
9
|
+
import { Observable, shareReplay } from "rxjs";
|
|
10
|
+
var __defProp2 = Object.defineProperty, __getOwnPropDesc = Object.getOwnPropertyDescriptor, __decorateClass = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
11
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
12
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
13
|
+
return kind && result && __defProp2(target, key, result), result;
|
|
14
|
+
}, "__decorateClass"), __decorateParam = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam");
|
|
15
|
+
const UNIVER_RPC_NODE_MAIN_PLUGIN_CONFIG_KEY = "node-rpc.main.config";
|
|
16
|
+
var _a;
|
|
17
|
+
let UniverRPCNodeMainPlugin = (_a = class extends Plugin {
|
|
18
|
+
constructor(_config, _injector, _configService) {
|
|
19
|
+
super(), this._config = _config, this._injector = _injector, this._configService = _configService, this._configService.setConfig(UNIVER_RPC_NODE_MAIN_PLUGIN_CONFIG_KEY, this._config);
|
|
19
20
|
}
|
|
20
21
|
onStarting() {
|
|
21
|
-
const { workerSrc
|
|
22
|
+
const { workerSrc } = this._config, messageProtocol = createNodeMessagePortOnMain(this._injector, workerSrc);
|
|
22
23
|
[
|
|
23
|
-
[
|
|
24
|
-
useFactory: () => new
|
|
24
|
+
[IRPCChannelService, {
|
|
25
|
+
useFactory: /* @__PURE__ */ __name(() => new ChannelService(messageProtocol), "useFactory")
|
|
25
26
|
}],
|
|
26
|
-
[
|
|
27
|
-
[
|
|
28
|
-
].forEach((
|
|
27
|
+
[DataSyncPrimaryController],
|
|
28
|
+
[IRemoteSyncService, { useClass: RemoteSyncPrimaryService }]
|
|
29
|
+
].forEach((dependency) => this._injector.add(dependency)), this._injector.get(DataSyncPrimaryController);
|
|
29
30
|
}
|
|
30
|
-
},
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
],
|
|
35
|
-
var
|
|
36
|
-
let
|
|
37
|
-
constructor(
|
|
38
|
-
super(), this._config =
|
|
31
|
+
}, __name(_a, "UniverRPCNodeMainPlugin"), __publicField(_a, "pluginName", "UNIVER_RPC_NODE_MAIN_PLUGIN"), _a);
|
|
32
|
+
UniverRPCNodeMainPlugin = __decorateClass([
|
|
33
|
+
__decorateParam(1, Inject(Injector)),
|
|
34
|
+
__decorateParam(2, IConfigService)
|
|
35
|
+
], UniverRPCNodeMainPlugin);
|
|
36
|
+
var _a2;
|
|
37
|
+
let UniverRPCNodeWorkerPlugin = (_a2 = class extends Plugin {
|
|
38
|
+
constructor(_config, _injector) {
|
|
39
|
+
super(), this._config = _config, this._injector = _injector;
|
|
39
40
|
}
|
|
40
41
|
onStarting() {
|
|
41
42
|
[
|
|
42
|
-
[
|
|
43
|
-
[
|
|
44
|
-
useFactory: () => new
|
|
43
|
+
[DataSyncReplicaController],
|
|
44
|
+
[IRPCChannelService, {
|
|
45
|
+
useFactory: /* @__PURE__ */ __name(() => new ChannelService(createNodeWorkerMessageProtocol()), "useFactory")
|
|
45
46
|
}],
|
|
46
|
-
[
|
|
47
|
-
].forEach((
|
|
47
|
+
[IRemoteInstanceService, { useClass: WebWorkerRemoteInstanceService }]
|
|
48
|
+
].forEach((d) => this._injector.add(d)), this._injector.get(DataSyncReplicaController);
|
|
48
49
|
}
|
|
49
|
-
},
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
],
|
|
53
|
-
function
|
|
54
|
-
const
|
|
55
|
-
return
|
|
56
|
-
send(
|
|
57
|
-
|
|
50
|
+
}, __name(_a2, "UniverRPCNodeWorkerPlugin"), __publicField(_a2, "pluginName", "UNIVER_RPC_NODE_WORKER_PLUGIN"), _a2);
|
|
51
|
+
UniverRPCNodeWorkerPlugin = __decorateClass([
|
|
52
|
+
__decorateParam(1, Inject(Injector))
|
|
53
|
+
], UniverRPCNodeWorkerPlugin);
|
|
54
|
+
function createNodeMessagePortOnMain(injector, path) {
|
|
55
|
+
const logService = injector.get(ILogService), child = fork(path);
|
|
56
|
+
return child.on("spawn", () => logService.log("Child computing process spawned!")), child.on("error", (error) => logService.error(error)), {
|
|
57
|
+
send(message) {
|
|
58
|
+
child.send(message);
|
|
58
59
|
},
|
|
59
|
-
onMessage: new
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
};
|
|
63
|
-
return
|
|
64
|
-
}).pipe(
|
|
60
|
+
onMessage: new Observable((subscriber) => {
|
|
61
|
+
const handler = /* @__PURE__ */ __name((message) => {
|
|
62
|
+
subscriber.next(message);
|
|
63
|
+
}, "handler");
|
|
64
|
+
return child.on("message", handler), () => child.off("message", handler);
|
|
65
|
+
}).pipe(shareReplay(1))
|
|
65
66
|
};
|
|
66
67
|
}
|
|
67
|
-
|
|
68
|
+
__name(createNodeMessagePortOnMain, "createNodeMessagePortOnMain");
|
|
69
|
+
function createNodeWorkerMessageProtocol() {
|
|
68
70
|
return {
|
|
69
|
-
send(
|
|
70
|
-
|
|
71
|
+
send(message) {
|
|
72
|
+
process.send(message);
|
|
71
73
|
},
|
|
72
|
-
onMessage: new
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
};
|
|
76
|
-
return
|
|
77
|
-
}).pipe(
|
|
74
|
+
onMessage: new Observable((subscriber) => {
|
|
75
|
+
const handler = /* @__PURE__ */ __name((event) => {
|
|
76
|
+
subscriber.next(event);
|
|
77
|
+
}, "handler");
|
|
78
|
+
return process.on("message", handler), () => process.off("message", handler);
|
|
79
|
+
}).pipe(shareReplay(1))
|
|
78
80
|
};
|
|
79
81
|
}
|
|
82
|
+
__name(createNodeWorkerMessageProtocol, "createNodeWorkerMessageProtocol");
|
|
80
83
|
export {
|
|
81
|
-
|
|
82
|
-
|
|
84
|
+
UniverRPCNodeMainPlugin,
|
|
85
|
+
UniverRPCNodeWorkerPlugin
|
|
83
86
|
};
|
package/lib/umd/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(global,factory){typeof exports=="object"&&typeof module<"u"?factory(exports,require("node:child_process"),require("node:process"),require("@univerjs/core"),require("@univerjs/rpc"),require("rxjs")):typeof define=="function"&&define.amd?define(["exports","node:child_process","node:process","@univerjs/core","@univerjs/rpc","rxjs"],factory):(global=typeof globalThis<"u"?globalThis:global||self,factory(global.UniverRpcNode={},global.node_child_process,global.process,global.UniverCore,global.UniverRpc,global.rxjs))})(this,function(exports2,node_child_process,process,core,rpc,rxjs){"use strict";var __defProp=Object.defineProperty;var __defNormalProp=(obj,key,value)=>key in obj?__defProp(obj,key,{enumerable:!0,configurable:!0,writable:!0,value}):obj[key]=value;var __name=(target,value)=>__defProp(target,"name",{value,configurable:!0});var __publicField=(obj,key,value)=>__defNormalProp(obj,typeof key!="symbol"?key+"":key,value);var _a,_b;var __defProp2=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__decorateClass=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp2(target,key,result),result},"__decorateClass"),__decorateParam=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam");const UNIVER_RPC_NODE_MAIN_PLUGIN_CONFIG_KEY="node-rpc.main.config";exports2.UniverRPCNodeMainPlugin=(_a=class extends core.Plugin{constructor(_config,_injector,_configService){super(),this._config=_config,this._injector=_injector,this._configService=_configService,this._configService.setConfig(UNIVER_RPC_NODE_MAIN_PLUGIN_CONFIG_KEY,this._config)}onStarting(){const{workerSrc}=this._config,messageProtocol=createNodeMessagePortOnMain(this._injector,workerSrc);[[rpc.IRPCChannelService,{useFactory:__name(()=>new rpc.ChannelService(messageProtocol),"useFactory")}],[rpc.DataSyncPrimaryController],[rpc.IRemoteSyncService,{useClass:rpc.RemoteSyncPrimaryService}]].forEach(dependency=>this._injector.add(dependency)),this._injector.get(rpc.DataSyncPrimaryController)}},__name(_a,"UniverRPCNodeMainPlugin"),__publicField(_a,"pluginName","UNIVER_RPC_NODE_MAIN_PLUGIN"),_a),exports2.UniverRPCNodeMainPlugin=__decorateClass([__decorateParam(1,core.Inject(core.Injector)),__decorateParam(2,core.IConfigService)],exports2.UniverRPCNodeMainPlugin),exports2.UniverRPCNodeWorkerPlugin=(_b=class extends core.Plugin{constructor(_config,_injector){super(),this._config=_config,this._injector=_injector}onStarting(){[[rpc.DataSyncReplicaController],[rpc.IRPCChannelService,{useFactory:__name(()=>new rpc.ChannelService(createNodeWorkerMessageProtocol()),"useFactory")}],[rpc.IRemoteInstanceService,{useClass:rpc.WebWorkerRemoteInstanceService}]].forEach(d=>this._injector.add(d)),this._injector.get(rpc.DataSyncReplicaController)}},__name(_b,"UniverRPCNodeWorkerPlugin"),__publicField(_b,"pluginName","UNIVER_RPC_NODE_WORKER_PLUGIN"),_b),exports2.UniverRPCNodeWorkerPlugin=__decorateClass([__decorateParam(1,core.Inject(core.Injector))],exports2.UniverRPCNodeWorkerPlugin);function createNodeMessagePortOnMain(injector,path){const logService=injector.get(core.ILogService),child=node_child_process.fork(path);return child.on("spawn",()=>logService.log("Child computing process spawned!")),child.on("error",error=>logService.error(error)),{send(message){child.send(message)},onMessage:new rxjs.Observable(subscriber=>{const handler=__name(message=>{subscriber.next(message)},"handler");return child.on("message",handler),()=>child.off("message",handler)}).pipe(rxjs.shareReplay(1))}}__name(createNodeMessagePortOnMain,"createNodeMessagePortOnMain");function createNodeWorkerMessageProtocol(){return{send(message){process.send(message)},onMessage:new rxjs.Observable(subscriber=>{const handler=__name(event=>{subscriber.next(event)},"handler");return process.on("message",handler),()=>process.off("message",handler)}).pipe(rxjs.shareReplay(1))}}__name(createNodeWorkerMessageProtocol,"createNodeWorkerMessageProtocol"),Object.defineProperty(exports2,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/rpc-node",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.5-experimental.20250122-3362a4a",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -46,15 +46,15 @@
|
|
|
46
46
|
"rxjs": ">=7.0.0"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@univerjs/
|
|
50
|
-
"@univerjs/
|
|
49
|
+
"@univerjs/rpc": "0.5.5-experimental.20250122-3362a4a",
|
|
50
|
+
"@univerjs/core": "0.5.5-experimental.20250122-3362a4a"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"rxjs": "^7.8.1",
|
|
54
54
|
"typescript": "^5.7.2",
|
|
55
55
|
"vite": "^6.0.7",
|
|
56
56
|
"vitest": "^2.1.8",
|
|
57
|
-
"@univerjs-infra/shared": "0.5.
|
|
57
|
+
"@univerjs-infra/shared": "0.5.5"
|
|
58
58
|
},
|
|
59
59
|
"scripts": {
|
|
60
60
|
"test": "vitest run",
|