@univerjs/rpc-node 0.4.2-nightly.202411061606 → 0.4.2-nightly.202411081606
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 -0
- package/lib/es/index.js +64 -67
- package/package.json +11 -7
package/lib/cjs/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var C=Object.defineProperty;var h=(n,e,r)=>e in n?C(n,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):n[e]=r;var g=(n,e,r)=>h(n,typeof e!="symbol"?e+"":e,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const R=require("node:child_process"),P=require("node:process"),c=require("@univerjs/core"),s=require("@univerjs/rpc"),l=require("rxjs");var f=Object.defineProperty,N=Object.getOwnPropertyDescriptor,v=(n,e,r,o)=>{for(var t=o>1?void 0:o?N(e,r):e,i=n.length-1,a;i>=0;i--)(a=n[i])&&(t=(o?a(e,r,t):a(t))||t);return o&&t&&f(e,r,t),t},d=(n,e)=>(r,o)=>e(r,o,n);const S="node-rpc.main.config";var u;exports.UniverRPCNodeMainPlugin=(u=class extends c.Plugin{constructor(e,r,o){super(),this._config=e,this._injector=r,this._configService=o,this._configService.setConfig(S,this._config)}onStarting(){const{workerSrc:e}=this._config,r=I(this._injector,e);[[s.IRPCChannelService,{useFactory:()=>new s.ChannelService(r)}],[s.DataSyncPrimaryController],[s.IRemoteSyncService,{useClass:s.RemoteSyncPrimaryService}]].forEach(t=>this._injector.add(t)),this._injector.get(s.DataSyncPrimaryController)}},g(u,"pluginName","UNIVER_RPC_NODE_MAIN_PLUGIN"),u);exports.UniverRPCNodeMainPlugin=v([d(1,c.Inject(c.Injector)),d(2,c.IConfigService)],exports.UniverRPCNodeMainPlugin);var _;exports.UniverRPCNodeWorkerPlugin=(_=class extends c.Plugin{constructor(e,r){super(),this._config=e,this._injector=r}onStarting(){[[s.DataSyncReplicaController],[s.IRPCChannelService,{useFactory:()=>new s.ChannelService(m())}],[s.IRemoteInstanceService,{useClass:s.WebWorkerRemoteInstanceService}]].forEach(e=>this._injector.add(e)),this._injector.get(s.DataSyncReplicaController)}},g(_,"pluginName","UNIVER_RPC_NODE_WORKER_PLUGIN"),_);exports.UniverRPCNodeWorkerPlugin=v([d(1,c.Inject(c.Injector))],exports.UniverRPCNodeWorkerPlugin);function I(n,e){const r=n.get(c.ILogService),o=R.fork(e);return o.on("spawn",()=>r.log("Child computing process spawned!")),o.on("error",i=>r.error(i)),{send(i){o.send(i)},onMessage:new l.Observable(i=>{const a=p=>{i.next(p)};return o.on("message",a),()=>o.off("message",a)}).pipe(l.shareReplay(1))}}function m(){return{send(n){P.send(n)},onMessage:new l.Observable(n=>{const e=r=>{n.next(r)};return P.on("message",e),()=>P.off("message",e)}).pipe(l.shareReplay(1))}}
|
package/lib/es/index.js
CHANGED
|
@@ -1,86 +1,83 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
var
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
super(), this._config = _config, this._injector = _injector, this._configService = _configService, this._configService.setConfig(UNIVER_RPC_NODE_MAIN_PLUGIN_CONFIG_KEY, this._config);
|
|
1
|
+
var j = Object.defineProperty;
|
|
2
|
+
var O = (r, e, o) => e in r ? j(r, e, { enumerable: !0, configurable: !0, writable: !0, value: o }) : r[e] = o;
|
|
3
|
+
var i = (r, e, o) => O(r, typeof e != "symbol" ? e + "" : e, o);
|
|
4
|
+
import { fork as E } from "node:child_process";
|
|
5
|
+
import a from "node:process";
|
|
6
|
+
import { Inject as d, Injector as h, Plugin as u, IConfigService as w, ILogService as y } from "@univerjs/core";
|
|
7
|
+
import { DataSyncPrimaryController as p, DataSyncReplicaController as f, IRPCChannelService as v, ChannelService as I, IRemoteInstanceService as M, WebWorkerRemoteInstanceService as U, IRemoteSyncService as D, RemoteSyncPrimaryService as b } from "@univerjs/rpc";
|
|
8
|
+
import { Observable as N, shareReplay as S } from "rxjs";
|
|
9
|
+
var x = Object.defineProperty, W = Object.getOwnPropertyDescriptor, C = (r, e, o, n) => {
|
|
10
|
+
for (var s = n > 1 ? void 0 : n ? W(e, o) : e, t = r.length - 1, c; t >= 0; t--)
|
|
11
|
+
(c = r[t]) && (s = (n ? c(e, o, s) : c(s)) || s);
|
|
12
|
+
return n && s && x(e, o, s), s;
|
|
13
|
+
}, l = (r, e) => (o, n) => e(o, n, r);
|
|
14
|
+
const G = "node-rpc.main.config";
|
|
15
|
+
var _;
|
|
16
|
+
let m = (_ = class extends u {
|
|
17
|
+
constructor(r, e, o) {
|
|
18
|
+
super(), this._config = r, this._injector = e, this._configService = o, this._configService.setConfig(G, this._config);
|
|
20
19
|
}
|
|
21
20
|
onStarting() {
|
|
22
|
-
const { workerSrc } = this._config,
|
|
21
|
+
const { workerSrc: r } = this._config, e = L(this._injector, r);
|
|
23
22
|
[
|
|
24
|
-
[
|
|
25
|
-
useFactory:
|
|
23
|
+
[v, {
|
|
24
|
+
useFactory: () => new I(e)
|
|
26
25
|
}],
|
|
27
|
-
[
|
|
28
|
-
[
|
|
29
|
-
].forEach((
|
|
26
|
+
[p],
|
|
27
|
+
[D, { useClass: b }]
|
|
28
|
+
].forEach((n) => this._injector.add(n)), this._injector.get(p);
|
|
30
29
|
}
|
|
31
|
-
},
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
],
|
|
36
|
-
var
|
|
37
|
-
let
|
|
38
|
-
constructor(
|
|
39
|
-
super(), this._config =
|
|
30
|
+
}, i(_, "pluginName", "UNIVER_RPC_NODE_MAIN_PLUGIN"), _);
|
|
31
|
+
m = C([
|
|
32
|
+
l(1, d(h)),
|
|
33
|
+
l(2, w)
|
|
34
|
+
], m);
|
|
35
|
+
var g;
|
|
36
|
+
let P = (g = class extends u {
|
|
37
|
+
constructor(r, e) {
|
|
38
|
+
super(), this._config = r, this._injector = e;
|
|
40
39
|
}
|
|
41
40
|
onStarting() {
|
|
42
41
|
[
|
|
43
|
-
[
|
|
44
|
-
[
|
|
45
|
-
useFactory:
|
|
42
|
+
[f],
|
|
43
|
+
[v, {
|
|
44
|
+
useFactory: () => new I(F())
|
|
46
45
|
}],
|
|
47
|
-
[
|
|
48
|
-
].forEach((
|
|
46
|
+
[M, { useClass: U }]
|
|
47
|
+
].forEach((r) => this._injector.add(r)), this._injector.get(f);
|
|
49
48
|
}
|
|
50
|
-
},
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
],
|
|
54
|
-
function
|
|
55
|
-
const
|
|
56
|
-
return
|
|
57
|
-
send(
|
|
58
|
-
|
|
49
|
+
}, i(g, "pluginName", "UNIVER_RPC_NODE_WORKER_PLUGIN"), g);
|
|
50
|
+
P = C([
|
|
51
|
+
l(1, d(h))
|
|
52
|
+
], P);
|
|
53
|
+
function L(r, e) {
|
|
54
|
+
const o = r.get(y), n = E(e);
|
|
55
|
+
return n.on("spawn", () => o.log("Child computing process spawned!")), n.on("error", (t) => o.error(t)), {
|
|
56
|
+
send(t) {
|
|
57
|
+
n.send(t);
|
|
59
58
|
},
|
|
60
|
-
onMessage: new
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
return
|
|
65
|
-
}).pipe(
|
|
59
|
+
onMessage: new N((t) => {
|
|
60
|
+
const c = (R) => {
|
|
61
|
+
t.next(R);
|
|
62
|
+
};
|
|
63
|
+
return n.on("message", c), () => n.off("message", c);
|
|
64
|
+
}).pipe(S(1))
|
|
66
65
|
};
|
|
67
66
|
}
|
|
68
|
-
|
|
69
|
-
function createNodeWorkerMessageProtocol() {
|
|
67
|
+
function F() {
|
|
70
68
|
return {
|
|
71
|
-
send(
|
|
72
|
-
|
|
69
|
+
send(r) {
|
|
70
|
+
a.send(r);
|
|
73
71
|
},
|
|
74
|
-
onMessage: new
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
return
|
|
79
|
-
}).pipe(
|
|
72
|
+
onMessage: new N((r) => {
|
|
73
|
+
const e = (o) => {
|
|
74
|
+
r.next(o);
|
|
75
|
+
};
|
|
76
|
+
return a.on("message", e), () => a.off("message", e);
|
|
77
|
+
}).pipe(S(1))
|
|
80
78
|
};
|
|
81
79
|
}
|
|
82
|
-
__name(createNodeWorkerMessageProtocol, "createNodeWorkerMessageProtocol");
|
|
83
80
|
export {
|
|
84
|
-
UniverRPCNodeMainPlugin,
|
|
85
|
-
UniverRPCNodeWorkerPlugin
|
|
81
|
+
m as UniverRPCNodeMainPlugin,
|
|
82
|
+
P as UniverRPCNodeWorkerPlugin
|
|
86
83
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/rpc-node",
|
|
3
|
-
"version": "0.4.2-nightly.
|
|
3
|
+
"version": "0.4.2-nightly.202411081606",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -21,10 +21,12 @@
|
|
|
21
21
|
"exports": {
|
|
22
22
|
".": {
|
|
23
23
|
"import": "./lib/es/index.js",
|
|
24
|
+
"require": "./lib/cjs/index.js",
|
|
24
25
|
"types": "./lib/types/index.d.ts"
|
|
25
26
|
},
|
|
26
27
|
"./*": {
|
|
27
28
|
"import": "./lib/es/*",
|
|
29
|
+
"require": "./lib/cjs/*",
|
|
28
30
|
"types": "./lib/types/index.d.ts"
|
|
29
31
|
},
|
|
30
32
|
"./lib/*": "./lib/*"
|
|
@@ -44,8 +46,8 @@
|
|
|
44
46
|
"rxjs": ">=7.0.0"
|
|
45
47
|
},
|
|
46
48
|
"dependencies": {
|
|
47
|
-
"@univerjs/core": "0.4.2-nightly.
|
|
48
|
-
"@univerjs/rpc": "0.4.2-nightly.
|
|
49
|
+
"@univerjs/core": "0.4.2-nightly.202411081606",
|
|
50
|
+
"@univerjs/rpc": "0.4.2-nightly.202411081606"
|
|
49
51
|
},
|
|
50
52
|
"devDependencies": {
|
|
51
53
|
"rxjs": "^7.8.1",
|
|
@@ -53,16 +55,18 @@
|
|
|
53
55
|
"vite": "^5.4.10",
|
|
54
56
|
"vitest": "^2.1.4",
|
|
55
57
|
"@univerjs-infra/shared": "0.4.2",
|
|
56
|
-
"@univerjs/
|
|
57
|
-
"@univerjs/
|
|
58
|
+
"@univerjs/rpc": "0.4.2-nightly.202411081606",
|
|
59
|
+
"@univerjs/core": "0.4.2-nightly.202411081606"
|
|
58
60
|
},
|
|
59
|
-
"
|
|
61
|
+
"space": {
|
|
60
62
|
".": {
|
|
61
63
|
"import": "./lib/es/index.js",
|
|
64
|
+
"require": "./lib/cjs/index.js",
|
|
62
65
|
"types": "./lib/types/index.d.ts"
|
|
63
66
|
},
|
|
64
67
|
"./*": {
|
|
65
68
|
"import": "./lib/es/*",
|
|
69
|
+
"require": "./lib/cjs/*",
|
|
66
70
|
"types": "./lib/types/index.d.ts"
|
|
67
71
|
},
|
|
68
72
|
"./lib/*": "./lib/*"
|
|
@@ -72,7 +76,7 @@
|
|
|
72
76
|
"test:watch": "vitest",
|
|
73
77
|
"coverage": "vitest run --coverage",
|
|
74
78
|
"lint:types": "tsc --noEmit",
|
|
75
|
-
"build": "
|
|
79
|
+
"build": "tsx build.ts"
|
|
76
80
|
},
|
|
77
81
|
"module": "./lib/es/index.js"
|
|
78
82
|
}
|