@univerjs/rpc-node 0.16.1 → 0.17.0

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 CHANGED
@@ -1 +1 @@
1
- "use strict";var p=Object.defineProperty;var R=(n,e,r)=>e in n?p(n,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):n[e]=r;var l=(n,e,r)=>R(n,typeof e!="symbol"?e+"":e,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const S=require("node:child_process"),h=require("node:process"),c=require("@univerjs/core"),t=require("@univerjs/rpc"),g=require("rxjs"),N="rpc-node.main-thread.config",P={},I="rpc-node.worker-thread.config",v={};var m=Object.getOwnPropertyDescriptor,f=(n,e,r,o)=>{for(var s=o>1?void 0:o?m(e,r):e,i=n.length-1,a;i>=0;i--)(a=n[i])&&(s=a(s)||s);return s},d=(n,e)=>(r,o)=>e(r,o,n),u;exports.UniverRPCNodeMainPlugin=(u=class extends c.Plugin{constructor(r=P,o,s){super();l(this,"_child",null);this._config=r,this._injector=o,this._configService=s;const{...i}=c.merge({},P,this._config);this._configService.setConfig(N,i)}onStarting(){const{workerSrc:r}=this._config;if(!r)throw new Error("[UniverRPCNodeMainPlugin] workerSrc is required for UniverRPCNodeMainPlugin");const[o,s]=y(this._injector,r);[[t.IRPCChannelService,{useFactory:()=>new t.ChannelService(o)}],[t.DataSyncPrimaryController],[t.IRemoteSyncService,{useClass:t.RemoteSyncPrimaryService}]].forEach(a=>this._injector.add(a)),this._injector.get(t.DataSyncPrimaryController),this._child=s}dispose(){if(super.dispose(),this._child){try{this._child.kill()}catch(r){console.error("Failed to kill child process:",r)}this._child=null}}},l(u,"pluginName","UNIVER_RPC_NODE_MAIN_PLUGIN"),u);exports.UniverRPCNodeMainPlugin=f([d(1,c.Inject(c.Injector)),d(2,c.IConfigService)],exports.UniverRPCNodeMainPlugin);var _;exports.UniverRPCNodeWorkerPlugin=(_=class extends c.Plugin{constructor(e=v,r,o){super(),this._config=e,this._injector=r,this._configService=o;const{...s}=c.merge({},v,this._config);this._configService.setConfig(I,s)}onStarting(){[[t.DataSyncReplicaController],[t.IRPCChannelService,{useFactory:()=>new t.ChannelService(U())}],[t.IRemoteInstanceService,{useClass:t.WebWorkerRemoteInstanceService}]].forEach(e=>this._injector.add(e)),this._injector.get(t.DataSyncReplicaController)}},l(_,"pluginName","UNIVER_RPC_NODE_WORKER_PLUGIN"),_);exports.UniverRPCNodeWorkerPlugin=f([d(1,c.Inject(c.Injector)),d(2,c.IConfigService)],exports.UniverRPCNodeWorkerPlugin);function y(n,e){const r=n.get(c.ILogService),o=S.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 g.Observable(i=>{const a=C=>{i.next(C)};return o.on("message",a),()=>o.off("message",a)}).pipe(g.shareReplay(1))},o]}function U(){return{send(n){h.send(n)},onMessage:new g.Observable(n=>{const e=r=>{n.next(r)};return h.on("message",e),()=>h.off("message",e)}).pipe(g.shareReplay(1))}}
1
+ "use strict";var R=Object.defineProperty;var N=(n,e,r)=>e in n?R(n,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):n[e]=r;var a=(n,e,r)=>N(n,typeof e!="symbol"?e+"":e,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const S=require("node:child_process"),P=require("node:process"),c=require("@univerjs/core"),s=require("@univerjs/rpc"),u=require("rxjs"),m="@univerjs/rpc-node",I="0.17.0",h={name:m,version:I},y="rpc-node.main-thread.config",v={},U="rpc-node.worker-thread.config",p={};var j=Object.getOwnPropertyDescriptor,f=(n,e,r,o)=>{for(var t=o>1?void 0:o?j(e,r):e,i=n.length-1,l;i>=0;i--)(l=n[i])&&(t=l(t)||t);return t},_=(n,e)=>(r,o)=>e(r,o,n),g;exports.UniverRPCNodeMainPlugin=(g=class extends c.Plugin{constructor(r=v,o,t){super();a(this,"_child",null);this._config=r,this._injector=o,this._configService=t;const{...i}=c.merge({},v,this._config);this._configService.setConfig(y,i)}onStarting(){const{workerSrc:r}=this._config;if(!r)throw new Error("[UniverRPCNodeMainPlugin] workerSrc is required for UniverRPCNodeMainPlugin");const[o,t]=k(this._injector,r);[[s.IRPCChannelService,{useFactory:()=>new s.ChannelService(o)}],[s.DataSyncPrimaryController],[s.IRemoteSyncService,{useClass:s.RemoteSyncPrimaryService}]].forEach(l=>this._injector.add(l)),this._injector.get(s.DataSyncPrimaryController),this._child=t}dispose(){if(super.dispose(),this._child){try{this._child.kill()}catch(r){console.error("Failed to kill child process:",r)}this._child=null}}},a(g,"pluginName","UNIVER_RPC_NODE_MAIN_PLUGIN"),a(g,"packageName",h.name),a(g,"version",h.version),g);exports.UniverRPCNodeMainPlugin=f([_(1,c.Inject(c.Injector)),_(2,c.IConfigService)],exports.UniverRPCNodeMainPlugin);var d;exports.UniverRPCNodeWorkerPlugin=(d=class extends c.Plugin{constructor(e=p,r,o){super(),this._config=e,this._injector=r,this._configService=o;const{...t}=c.merge({},p,this._config);this._configService.setConfig(U,t)}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)}},a(d,"pluginName","UNIVER_RPC_NODE_WORKER_PLUGIN"),a(d,"packageName",h.name),a(d,"version",h.version),d);exports.UniverRPCNodeWorkerPlugin=f([_(1,c.Inject(c.Injector)),_(2,c.IConfigService)],exports.UniverRPCNodeWorkerPlugin);function k(n,e){const r=n.get(c.ILogService),o=S.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 u.Observable(i=>{const l=C=>{i.next(C)};return o.on("message",l),()=>o.off("message",l)}).pipe(u.shareReplay(1))},o]}function M(){return{send(n){P.send(n)},onMessage:new u.Observable(n=>{const e=r=>{n.next(r)};return P.on("message",e),()=>P.off("message",e)}).pipe(u.shareReplay(1))}}
package/lib/es/index.js CHANGED
@@ -1,41 +1,45 @@
1
- var O = Object.defineProperty;
2
- var j = (r, e, o) => e in r ? O(r, e, { enumerable: !0, configurable: !0, writable: !0, value: o }) : r[e] = o;
3
- var c = (r, e, o) => j(r, typeof e != "symbol" ? e + "" : e, o);
1
+ var M = Object.defineProperty;
2
+ var O = (r, e, n) => e in r ? M(r, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : r[e] = n;
3
+ var s = (r, e, n) => O(r, typeof e != "symbol" ? e + "" : e, n);
4
4
  import { fork as U } from "node:child_process";
5
- import l from "node:process";
6
- import { Inject as P, Injector as v, IConfigService as C, Plugin as R, merge as S, ILogService as k } from "@univerjs/core";
7
- import { IRPCChannelService as N, ChannelService as I, DataSyncPrimaryController as h, IRemoteSyncService as D, RemoteSyncPrimaryService as W, DataSyncReplicaController as _, IRemoteInstanceService as G, WebWorkerRemoteInstanceService as x } from "@univerjs/rpc";
8
- import { Observable as w, shareReplay as E } from "rxjs";
9
- const F = "rpc-node.main-thread.config", f = {}, L = "rpc-node.worker-thread.config", p = {};
10
- var b = Object.getOwnPropertyDescriptor, y = (r, e, o, n) => {
11
- for (var i = n > 1 ? void 0 : n ? b(e, o) : e, t = r.length - 1, s; t >= 0; t--)
12
- (s = r[t]) && (i = s(i) || i);
5
+ import h from "node:process";
6
+ import { Inject as P, Injector as C, IConfigService as N, Plugin as R, merge as S, ILogService as D } from "@univerjs/core";
7
+ import { IRPCChannelService as I, ChannelService as w, DataSyncPrimaryController as _, IRemoteSyncService as W, RemoteSyncPrimaryService as G, DataSyncReplicaController as f, IRemoteInstanceService as x, WebWorkerRemoteInstanceService as F } from "@univerjs/rpc";
8
+ import { Observable as E, shareReplay as k } from "rxjs";
9
+ const L = "@univerjs/rpc-node", b = "0.17.0", g = {
10
+ name: L,
11
+ version: b
12
+ }, A = "rpc-node.main-thread.config", p = {}, K = "rpc-node.worker-thread.config", m = {};
13
+ var T = Object.getOwnPropertyDescriptor, j = (r, e, n, o) => {
14
+ for (var i = o > 1 ? void 0 : o ? T(e, n) : e, t = r.length - 1, c; t >= 0; t--)
15
+ (c = r[t]) && (i = c(i) || i);
13
16
  return i;
14
- }, a = (r, e) => (o, n) => e(o, n, r), g;
15
- let u = (g = class extends R {
16
- constructor(e = f, o, n) {
17
+ }, d = (r, e) => (n, o) => e(n, o, r), a;
18
+ let u = (a = class extends R {
19
+ constructor(e = p, n, o) {
17
20
  super();
18
- c(this, "_child", null);
19
- this._config = e, this._injector = o, this._configService = n;
21
+ s(this, "_child", null);
22
+ this._config = e, this._injector = n, this._configService = o;
20
23
  const { ...i } = S(
21
24
  {},
22
- f,
25
+ p,
23
26
  this._config
24
27
  );
25
- this._configService.setConfig(F, i);
28
+ this._configService.setConfig(A, i);
26
29
  }
27
30
  onStarting() {
28
31
  const { workerSrc: e } = this._config;
29
32
  if (!e)
30
33
  throw new Error("[UniverRPCNodeMainPlugin] workerSrc is required for UniverRPCNodeMainPlugin");
31
- const [o, n] = A(this._injector, e);
34
+ const [n, o] = H(this._injector, e);
32
35
  [
33
- [N, {
34
- useFactory: () => new I(o)
36
+ [I, {
37
+ // eslint-disable-next-line react/no-unnecessary-use-prefix
38
+ useFactory: () => new w(n)
35
39
  }],
36
- [h],
37
- [D, { useClass: W }]
38
- ].forEach((t) => this._injector.add(t)), this._injector.get(h), this._child = n;
40
+ [_],
41
+ [W, { useClass: G }]
42
+ ].forEach((t) => this._injector.add(t)), this._injector.get(_), this._child = o;
39
43
  }
40
44
  dispose() {
41
45
  if (super.dispose(), this._child) {
@@ -47,64 +51,65 @@ let u = (g = class extends R {
47
51
  this._child = null;
48
52
  }
49
53
  }
50
- }, c(g, "pluginName", "UNIVER_RPC_NODE_MAIN_PLUGIN"), g);
51
- u = y([
52
- a(1, P(v)),
53
- a(2, C)
54
+ }, s(a, "pluginName", "UNIVER_RPC_NODE_MAIN_PLUGIN"), s(a, "packageName", g.name), s(a, "version", g.version), a);
55
+ u = j([
56
+ d(1, P(C)),
57
+ d(2, N)
54
58
  ], u);
55
- var d;
56
- let m = (d = class extends R {
57
- constructor(r = p, e, o) {
58
- super(), this._config = r, this._injector = e, this._configService = o;
59
- const { ...n } = S(
59
+ var l;
60
+ let v = (l = class extends R {
61
+ constructor(r = m, e, n) {
62
+ super(), this._config = r, this._injector = e, this._configService = n;
63
+ const { ...o } = S(
60
64
  {},
61
- p,
65
+ m,
62
66
  this._config
63
67
  );
64
- this._configService.setConfig(L, n);
68
+ this._configService.setConfig(K, o);
65
69
  }
66
70
  onStarting() {
67
71
  [
68
- [_],
69
- [N, {
70
- useFactory: () => new I(K())
72
+ [f],
73
+ [I, {
74
+ // eslint-disable-next-line react/no-unnecessary-use-prefix
75
+ useFactory: () => new w(V())
71
76
  }],
72
- [G, { useClass: x }]
73
- ].forEach((r) => this._injector.add(r)), this._injector.get(_);
77
+ [x, { useClass: F }]
78
+ ].forEach((r) => this._injector.add(r)), this._injector.get(f);
74
79
  }
75
- }, c(d, "pluginName", "UNIVER_RPC_NODE_WORKER_PLUGIN"), d);
76
- m = y([
77
- a(1, P(v)),
78
- a(2, C)
79
- ], m);
80
- function A(r, e) {
81
- const o = r.get(k), n = U(e);
82
- return n.on("spawn", () => o.log("Child computing process spawned!")), n.on("error", (t) => o.error(t)), [{
80
+ }, s(l, "pluginName", "UNIVER_RPC_NODE_WORKER_PLUGIN"), s(l, "packageName", g.name), s(l, "version", g.version), l);
81
+ v = j([
82
+ d(1, P(C)),
83
+ d(2, N)
84
+ ], v);
85
+ function H(r, e) {
86
+ const n = r.get(D), o = U(e);
87
+ return o.on("spawn", () => n.log("Child computing process spawned!")), o.on("error", (t) => n.error(t)), [{
83
88
  send(t) {
84
- n.send(t);
89
+ o.send(t);
85
90
  },
86
- onMessage: new w((t) => {
87
- const s = (M) => {
88
- t.next(M);
91
+ onMessage: new E((t) => {
92
+ const c = (y) => {
93
+ t.next(y);
89
94
  };
90
- return n.on("message", s), () => n.off("message", s);
91
- }).pipe(E(1))
92
- }, n];
95
+ return o.on("message", c), () => o.off("message", c);
96
+ }).pipe(k(1))
97
+ }, o];
93
98
  }
94
- function K() {
99
+ function V() {
95
100
  return {
96
101
  send(r) {
97
- l.send(r);
102
+ h.send(r);
98
103
  },
99
- onMessage: new w((r) => {
100
- const e = (o) => {
101
- r.next(o);
104
+ onMessage: new E((r) => {
105
+ const e = (n) => {
106
+ r.next(n);
102
107
  };
103
- return l.on("message", e), () => l.off("message", e);
104
- }).pipe(E(1))
108
+ return h.on("message", e), () => h.off("message", e);
109
+ }).pipe(k(1))
105
110
  };
106
111
  }
107
112
  export {
108
113
  u as UniverRPCNodeMainPlugin,
109
- m as UniverRPCNodeWorkerPlugin
114
+ v as UniverRPCNodeWorkerPlugin
110
115
  };
package/lib/index.js CHANGED
@@ -1,41 +1,45 @@
1
- var O = Object.defineProperty;
2
- var j = (r, e, o) => e in r ? O(r, e, { enumerable: !0, configurable: !0, writable: !0, value: o }) : r[e] = o;
3
- var c = (r, e, o) => j(r, typeof e != "symbol" ? e + "" : e, o);
1
+ var M = Object.defineProperty;
2
+ var O = (r, e, n) => e in r ? M(r, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : r[e] = n;
3
+ var s = (r, e, n) => O(r, typeof e != "symbol" ? e + "" : e, n);
4
4
  import { fork as U } from "node:child_process";
5
- import l from "node:process";
6
- import { Inject as P, Injector as v, IConfigService as C, Plugin as R, merge as S, ILogService as k } from "@univerjs/core";
7
- import { IRPCChannelService as N, ChannelService as I, DataSyncPrimaryController as h, IRemoteSyncService as D, RemoteSyncPrimaryService as W, DataSyncReplicaController as _, IRemoteInstanceService as G, WebWorkerRemoteInstanceService as x } from "@univerjs/rpc";
8
- import { Observable as w, shareReplay as E } from "rxjs";
9
- const F = "rpc-node.main-thread.config", f = {}, L = "rpc-node.worker-thread.config", p = {};
10
- var b = Object.getOwnPropertyDescriptor, y = (r, e, o, n) => {
11
- for (var i = n > 1 ? void 0 : n ? b(e, o) : e, t = r.length - 1, s; t >= 0; t--)
12
- (s = r[t]) && (i = s(i) || i);
5
+ import h from "node:process";
6
+ import { Inject as P, Injector as C, IConfigService as N, Plugin as R, merge as S, ILogService as D } from "@univerjs/core";
7
+ import { IRPCChannelService as I, ChannelService as w, DataSyncPrimaryController as _, IRemoteSyncService as W, RemoteSyncPrimaryService as G, DataSyncReplicaController as f, IRemoteInstanceService as x, WebWorkerRemoteInstanceService as F } from "@univerjs/rpc";
8
+ import { Observable as E, shareReplay as k } from "rxjs";
9
+ const L = "@univerjs/rpc-node", b = "0.17.0", g = {
10
+ name: L,
11
+ version: b
12
+ }, A = "rpc-node.main-thread.config", p = {}, K = "rpc-node.worker-thread.config", m = {};
13
+ var T = Object.getOwnPropertyDescriptor, j = (r, e, n, o) => {
14
+ for (var i = o > 1 ? void 0 : o ? T(e, n) : e, t = r.length - 1, c; t >= 0; t--)
15
+ (c = r[t]) && (i = c(i) || i);
13
16
  return i;
14
- }, a = (r, e) => (o, n) => e(o, n, r), g;
15
- let u = (g = class extends R {
16
- constructor(e = f, o, n) {
17
+ }, d = (r, e) => (n, o) => e(n, o, r), a;
18
+ let u = (a = class extends R {
19
+ constructor(e = p, n, o) {
17
20
  super();
18
- c(this, "_child", null);
19
- this._config = e, this._injector = o, this._configService = n;
21
+ s(this, "_child", null);
22
+ this._config = e, this._injector = n, this._configService = o;
20
23
  const { ...i } = S(
21
24
  {},
22
- f,
25
+ p,
23
26
  this._config
24
27
  );
25
- this._configService.setConfig(F, i);
28
+ this._configService.setConfig(A, i);
26
29
  }
27
30
  onStarting() {
28
31
  const { workerSrc: e } = this._config;
29
32
  if (!e)
30
33
  throw new Error("[UniverRPCNodeMainPlugin] workerSrc is required for UniverRPCNodeMainPlugin");
31
- const [o, n] = A(this._injector, e);
34
+ const [n, o] = H(this._injector, e);
32
35
  [
33
- [N, {
34
- useFactory: () => new I(o)
36
+ [I, {
37
+ // eslint-disable-next-line react/no-unnecessary-use-prefix
38
+ useFactory: () => new w(n)
35
39
  }],
36
- [h],
37
- [D, { useClass: W }]
38
- ].forEach((t) => this._injector.add(t)), this._injector.get(h), this._child = n;
40
+ [_],
41
+ [W, { useClass: G }]
42
+ ].forEach((t) => this._injector.add(t)), this._injector.get(_), this._child = o;
39
43
  }
40
44
  dispose() {
41
45
  if (super.dispose(), this._child) {
@@ -47,64 +51,65 @@ let u = (g = class extends R {
47
51
  this._child = null;
48
52
  }
49
53
  }
50
- }, c(g, "pluginName", "UNIVER_RPC_NODE_MAIN_PLUGIN"), g);
51
- u = y([
52
- a(1, P(v)),
53
- a(2, C)
54
+ }, s(a, "pluginName", "UNIVER_RPC_NODE_MAIN_PLUGIN"), s(a, "packageName", g.name), s(a, "version", g.version), a);
55
+ u = j([
56
+ d(1, P(C)),
57
+ d(2, N)
54
58
  ], u);
55
- var d;
56
- let m = (d = class extends R {
57
- constructor(r = p, e, o) {
58
- super(), this._config = r, this._injector = e, this._configService = o;
59
- const { ...n } = S(
59
+ var l;
60
+ let v = (l = class extends R {
61
+ constructor(r = m, e, n) {
62
+ super(), this._config = r, this._injector = e, this._configService = n;
63
+ const { ...o } = S(
60
64
  {},
61
- p,
65
+ m,
62
66
  this._config
63
67
  );
64
- this._configService.setConfig(L, n);
68
+ this._configService.setConfig(K, o);
65
69
  }
66
70
  onStarting() {
67
71
  [
68
- [_],
69
- [N, {
70
- useFactory: () => new I(K())
72
+ [f],
73
+ [I, {
74
+ // eslint-disable-next-line react/no-unnecessary-use-prefix
75
+ useFactory: () => new w(V())
71
76
  }],
72
- [G, { useClass: x }]
73
- ].forEach((r) => this._injector.add(r)), this._injector.get(_);
77
+ [x, { useClass: F }]
78
+ ].forEach((r) => this._injector.add(r)), this._injector.get(f);
74
79
  }
75
- }, c(d, "pluginName", "UNIVER_RPC_NODE_WORKER_PLUGIN"), d);
76
- m = y([
77
- a(1, P(v)),
78
- a(2, C)
79
- ], m);
80
- function A(r, e) {
81
- const o = r.get(k), n = U(e);
82
- return n.on("spawn", () => o.log("Child computing process spawned!")), n.on("error", (t) => o.error(t)), [{
80
+ }, s(l, "pluginName", "UNIVER_RPC_NODE_WORKER_PLUGIN"), s(l, "packageName", g.name), s(l, "version", g.version), l);
81
+ v = j([
82
+ d(1, P(C)),
83
+ d(2, N)
84
+ ], v);
85
+ function H(r, e) {
86
+ const n = r.get(D), o = U(e);
87
+ return o.on("spawn", () => n.log("Child computing process spawned!")), o.on("error", (t) => n.error(t)), [{
83
88
  send(t) {
84
- n.send(t);
89
+ o.send(t);
85
90
  },
86
- onMessage: new w((t) => {
87
- const s = (M) => {
88
- t.next(M);
91
+ onMessage: new E((t) => {
92
+ const c = (y) => {
93
+ t.next(y);
89
94
  };
90
- return n.on("message", s), () => n.off("message", s);
91
- }).pipe(E(1))
92
- }, n];
95
+ return o.on("message", c), () => o.off("message", c);
96
+ }).pipe(k(1))
97
+ }, o];
93
98
  }
94
- function K() {
99
+ function V() {
95
100
  return {
96
101
  send(r) {
97
- l.send(r);
102
+ h.send(r);
98
103
  },
99
- onMessage: new w((r) => {
100
- const e = (o) => {
101
- r.next(o);
104
+ onMessage: new E((r) => {
105
+ const e = (n) => {
106
+ r.next(n);
102
107
  };
103
- return l.on("message", e), () => l.off("message", e);
104
- }).pipe(E(1))
108
+ return h.on("message", e), () => h.off("message", e);
109
+ }).pipe(k(1))
105
110
  };
106
111
  }
107
112
  export {
108
113
  u as UniverRPCNodeMainPlugin,
109
- m as UniverRPCNodeWorkerPlugin
114
+ v as UniverRPCNodeWorkerPlugin
110
115
  };
@@ -1,10 +1,12 @@
1
- import { IUniverRPCNodeMainConfig, IUniverRPCNodeWorkerThreadConfig } from './controllers/config.schema';
1
+ import { IUniverRPCNodeMainConfig, IUniverRPCNodeWorkerThreadConfig } from './config/config';
2
2
  import { IConfigService, Injector, Plugin } from '@univerjs/core';
3
3
  export declare class UniverRPCNodeMainPlugin extends Plugin {
4
4
  private readonly _config;
5
5
  protected readonly _injector: Injector;
6
6
  private readonly _configService;
7
7
  static pluginName: string;
8
+ static packageName: string;
9
+ static version: string;
8
10
  private _child;
9
11
  constructor(_config: Partial<IUniverRPCNodeMainConfig> | undefined, _injector: Injector, _configService: IConfigService);
10
12
  onStarting(): void;
@@ -15,6 +17,8 @@ export declare class UniverRPCNodeWorkerPlugin extends Plugin {
15
17
  protected readonly _injector: Injector;
16
18
  private readonly _configService;
17
19
  static pluginName: string;
20
+ static packageName: string;
21
+ static version: string;
18
22
  constructor(_config: Partial<IUniverRPCNodeWorkerThreadConfig> | undefined, _injector: Injector, _configService: IConfigService);
19
23
  onStarting(): void;
20
24
  }
package/lib/umd/index.js CHANGED
@@ -1 +1 @@
1
- (function(e,o){typeof exports=="object"&&typeof module<"u"?o(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"],o):(e=typeof globalThis<"u"?globalThis:e||self,o(e.UniverRpcNode={},e.node_child_process,e.process,e.UniverCore,e.UniverRpc,e.rxjs))})(this,(function(e,o,l,a,s,g){"use strict";var U=Object.defineProperty;var j=(e,o,l)=>o in e?U(e,o,{enumerable:!0,configurable:!0,writable:!0,value:l}):e[o]=l;var _=(e,o,l)=>j(e,typeof o!="symbol"?o+"":o,l);var f,P;const S="rpc-node.main-thread.config",v={},N="rpc-node.worker-thread.config",C={};var p=Object.getOwnPropertyDescriptor,R=(t,r,n,i)=>{for(var d=i>1?void 0:i?p(r,n):r,c=t.length-1,u;c>=0;c--)(u=t[c])&&(d=u(d)||d);return d},h=(t,r)=>(n,i)=>r(n,i,t);e.UniverRPCNodeMainPlugin=(f=class extends a.Plugin{constructor(n=v,i,d){super();_(this,"_child",null);this._config=n,this._injector=i,this._configService=d;const{...c}=a.merge({},v,this._config);this._configService.setConfig(S,c)}onStarting(){const{workerSrc:n}=this._config;if(!n)throw new Error("[UniverRPCNodeMainPlugin] workerSrc is required for UniverRPCNodeMainPlugin");const[i,d]=m(this._injector,n);[[s.IRPCChannelService,{useFactory:()=>new s.ChannelService(i)}],[s.DataSyncPrimaryController],[s.IRemoteSyncService,{useClass:s.RemoteSyncPrimaryService}]].forEach(u=>this._injector.add(u)),this._injector.get(s.DataSyncPrimaryController),this._child=d}dispose(){if(super.dispose(),this._child){try{this._child.kill()}catch(n){console.error("Failed to kill child process:",n)}this._child=null}}},_(f,"pluginName","UNIVER_RPC_NODE_MAIN_PLUGIN"),f),e.UniverRPCNodeMainPlugin=R([h(1,a.Inject(a.Injector)),h(2,a.IConfigService)],e.UniverRPCNodeMainPlugin),e.UniverRPCNodeWorkerPlugin=(P=class extends a.Plugin{constructor(r=C,n,i){super(),this._config=r,this._injector=n,this._configService=i;const{...d}=a.merge({},C,this._config);this._configService.setConfig(N,d)}onStarting(){[[s.DataSyncReplicaController],[s.IRPCChannelService,{useFactory:()=>new s.ChannelService(I())}],[s.IRemoteInstanceService,{useClass:s.WebWorkerRemoteInstanceService}]].forEach(r=>this._injector.add(r)),this._injector.get(s.DataSyncReplicaController)}},_(P,"pluginName","UNIVER_RPC_NODE_WORKER_PLUGIN"),P),e.UniverRPCNodeWorkerPlugin=R([h(1,a.Inject(a.Injector)),h(2,a.IConfigService)],e.UniverRPCNodeWorkerPlugin);function m(t,r){const n=t.get(a.ILogService),i=o.fork(r);return i.on("spawn",()=>n.log("Child computing process spawned!")),i.on("error",c=>n.error(c)),[{send(c){i.send(c)},onMessage:new g.Observable(c=>{const u=y=>{c.next(y)};return i.on("message",u),()=>i.off("message",u)}).pipe(g.shareReplay(1))},i]}function I(){return{send(t){l.send(t)},onMessage:new g.Observable(t=>{const r=n=>{t.next(n)};return l.on("message",r),()=>l.off("message",r)}).pipe(g.shareReplay(1))}}Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})}));
1
+ (function(e,o){typeof exports=="object"&&typeof module<"u"?o(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"],o):(e=typeof globalThis<"u"?globalThis:e||self,o(e.UniverRpcNode={},e.node_child_process,e.process,e.UniverCore,e.UniverRpc,e.rxjs))})(this,(function(e,o,l,a,s,_){"use strict";var U=Object.defineProperty;var k=(e,o,l)=>o in e?U(e,o,{enumerable:!0,configurable:!0,writable:!0,value:l}):e[o]=l;var u=(e,o,l)=>k(e,typeof o!="symbol"?o+"":o,l);var h,v;const f={name:"@univerjs/rpc-node",version:"0.17.0"},p="rpc-node.main-thread.config",C={},N="rpc-node.worker-thread.config",R={};var S=Object.getOwnPropertyDescriptor,m=(t,r,n,i)=>{for(var d=i>1?void 0:i?S(r,n):r,c=t.length-1,g;c>=0;c--)(g=t[c])&&(d=g(d)||d);return d},P=(t,r)=>(n,i)=>r(n,i,t);e.UniverRPCNodeMainPlugin=(h=class extends a.Plugin{constructor(n=C,i,d){super();u(this,"_child",null);this._config=n,this._injector=i,this._configService=d;const{...c}=a.merge({},C,this._config);this._configService.setConfig(p,c)}onStarting(){const{workerSrc:n}=this._config;if(!n)throw new Error("[UniverRPCNodeMainPlugin] workerSrc is required for UniverRPCNodeMainPlugin");const[i,d]=I(this._injector,n);[[s.IRPCChannelService,{useFactory:()=>new s.ChannelService(i)}],[s.DataSyncPrimaryController],[s.IRemoteSyncService,{useClass:s.RemoteSyncPrimaryService}]].forEach(g=>this._injector.add(g)),this._injector.get(s.DataSyncPrimaryController),this._child=d}dispose(){if(super.dispose(),this._child){try{this._child.kill()}catch(n){console.error("Failed to kill child process:",n)}this._child=null}}},u(h,"pluginName","UNIVER_RPC_NODE_MAIN_PLUGIN"),u(h,"packageName",f.name),u(h,"version",f.version),h),e.UniverRPCNodeMainPlugin=m([P(1,a.Inject(a.Injector)),P(2,a.IConfigService)],e.UniverRPCNodeMainPlugin),e.UniverRPCNodeWorkerPlugin=(v=class extends a.Plugin{constructor(r=R,n,i){super(),this._config=r,this._injector=n,this._configService=i;const{...d}=a.merge({},R,this._config);this._configService.setConfig(N,d)}onStarting(){[[s.DataSyncReplicaController],[s.IRPCChannelService,{useFactory:()=>new s.ChannelService(j())}],[s.IRemoteInstanceService,{useClass:s.WebWorkerRemoteInstanceService}]].forEach(r=>this._injector.add(r)),this._injector.get(s.DataSyncReplicaController)}},u(v,"pluginName","UNIVER_RPC_NODE_WORKER_PLUGIN"),u(v,"packageName",f.name),u(v,"version",f.version),v),e.UniverRPCNodeWorkerPlugin=m([P(1,a.Inject(a.Injector)),P(2,a.IConfigService)],e.UniverRPCNodeWorkerPlugin);function I(t,r){const n=t.get(a.ILogService),i=o.fork(r);return i.on("spawn",()=>n.log("Child computing process spawned!")),i.on("error",c=>n.error(c)),[{send(c){i.send(c)},onMessage:new _.Observable(c=>{const g=y=>{c.next(y)};return i.on("message",g),()=>i.off("message",g)}).pipe(_.shareReplay(1))},i]}function j(){return{send(t){l.send(t)},onMessage:new _.Observable(t=>{const r=n=>{t.next(n)};return l.on("message",r),()=>l.off("message",r)}).pipe(_.shareReplay(1))}}Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/rpc-node",
3
- "version": "0.16.1",
3
+ "version": "0.17.0",
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.16.1",
50
- "@univerjs/rpc": "0.16.1"
49
+ "@univerjs/core": "0.17.0",
50
+ "@univerjs/rpc": "0.17.0"
51
51
  },
52
52
  "devDependencies": {
53
53
  "rxjs": "^7.8.2",
54
54
  "typescript": "^5.9.3",
55
55
  "vite": "^7.3.1",
56
56
  "vitest": "^4.0.18",
57
- "@univerjs-infra/shared": "0.16.1"
57
+ "@univerjs-infra/shared": "0.17.0"
58
58
  },
59
59
  "scripts": {
60
60
  "test": "vitest run",