@univerjs/rpc-node 0.6.7 → 0.6.9
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/index.js +83 -0
- package/package.json +4 -4
package/lib/index.js
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
var j = Object.defineProperty;
|
|
2
|
+
var y = (e, r, o) => r in e ? j(e, r, { enumerable: !0, configurable: !0, writable: !0, value: o }) : e[r] = o;
|
|
3
|
+
var i = (e, r, o) => y(e, typeof r != "symbol" ? r + "" : r, o);
|
|
4
|
+
import { fork as E } from "node:child_process";
|
|
5
|
+
import a from "node:process";
|
|
6
|
+
import { Inject as h, Injector as u, IConfigService as O, Plugin as P, ILogService as w } from "@univerjs/core";
|
|
7
|
+
import { IRPCChannelService as v, ChannelService as I, DataSyncPrimaryController as m, IRemoteSyncService as M, RemoteSyncPrimaryService as U, DataSyncReplicaController as p, IRemoteInstanceService as D, WebWorkerRemoteInstanceService as x } from "@univerjs/rpc";
|
|
8
|
+
import { Observable as N, shareReplay as S } from "rxjs";
|
|
9
|
+
var W = Object.getOwnPropertyDescriptor, C = (e, r, o, n) => {
|
|
10
|
+
for (var s = n > 1 ? void 0 : n ? W(r, o) : r, t = e.length - 1, c; t >= 0; t--)
|
|
11
|
+
(c = e[t]) && (s = c(s) || s);
|
|
12
|
+
return s;
|
|
13
|
+
}, _ = (e, r) => (o, n) => r(o, n, e);
|
|
14
|
+
const b = "node-rpc.main.config";
|
|
15
|
+
var g;
|
|
16
|
+
let f = (g = class extends P {
|
|
17
|
+
constructor(e, r, o) {
|
|
18
|
+
super(), this._config = e, this._injector = r, this._configService = o, this._configService.setConfig(b, this._config);
|
|
19
|
+
}
|
|
20
|
+
onStarting() {
|
|
21
|
+
const { workerSrc: e } = this._config, r = k(this._injector, e);
|
|
22
|
+
[
|
|
23
|
+
[v, {
|
|
24
|
+
useFactory: () => new I(r)
|
|
25
|
+
}],
|
|
26
|
+
[m],
|
|
27
|
+
[M, { useClass: U }]
|
|
28
|
+
].forEach((n) => this._injector.add(n)), this._injector.get(m);
|
|
29
|
+
}
|
|
30
|
+
}, i(g, "pluginName", "UNIVER_RPC_NODE_MAIN_PLUGIN"), g);
|
|
31
|
+
f = C([
|
|
32
|
+
_(1, h(u)),
|
|
33
|
+
_(2, O)
|
|
34
|
+
], f);
|
|
35
|
+
var l;
|
|
36
|
+
let d = (l = class extends P {
|
|
37
|
+
constructor(e, r) {
|
|
38
|
+
super(), this._config = e, this._injector = r;
|
|
39
|
+
}
|
|
40
|
+
onStarting() {
|
|
41
|
+
[
|
|
42
|
+
[p],
|
|
43
|
+
[v, {
|
|
44
|
+
useFactory: () => new I(G())
|
|
45
|
+
}],
|
|
46
|
+
[D, { useClass: x }]
|
|
47
|
+
].forEach((e) => this._injector.add(e)), this._injector.get(p);
|
|
48
|
+
}
|
|
49
|
+
}, i(l, "pluginName", "UNIVER_RPC_NODE_WORKER_PLUGIN"), l);
|
|
50
|
+
d = C([
|
|
51
|
+
_(1, h(u))
|
|
52
|
+
], d);
|
|
53
|
+
function k(e, r) {
|
|
54
|
+
const o = e.get(w), n = E(r);
|
|
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);
|
|
58
|
+
},
|
|
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))
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
function G() {
|
|
68
|
+
return {
|
|
69
|
+
send(e) {
|
|
70
|
+
a.send(e);
|
|
71
|
+
},
|
|
72
|
+
onMessage: new N((e) => {
|
|
73
|
+
const r = (o) => {
|
|
74
|
+
e.next(o);
|
|
75
|
+
};
|
|
76
|
+
return a.on("message", r), () => a.off("message", r);
|
|
77
|
+
}).pipe(S(1))
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
export {
|
|
81
|
+
f as UniverRPCNodeMainPlugin,
|
|
82
|
+
d as UniverRPCNodeWorkerPlugin
|
|
83
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/rpc-node",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.9",
|
|
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/core": "0.6.
|
|
50
|
-
"@univerjs/rpc": "0.6.
|
|
49
|
+
"@univerjs/core": "0.6.9",
|
|
50
|
+
"@univerjs/rpc": "0.6.9"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"rxjs": "^7.8.1",
|
|
54
54
|
"typescript": "^5.8.2",
|
|
55
55
|
"vite": "^6.2.3",
|
|
56
56
|
"vitest": "^3.0.9",
|
|
57
|
-
"@univerjs-infra/shared": "0.6.
|
|
57
|
+
"@univerjs-infra/shared": "0.6.9"
|
|
58
58
|
},
|
|
59
59
|
"scripts": {
|
|
60
60
|
"test": "vitest run",
|