@univerjs/rpc-node 0.12.2-nightly.202511241159 → 0.12.2-nightly.202511290732

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