@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.
@@ -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 __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);
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, messageProtocol = createNodeMessagePortOnMain(this._injector, workerSrc);
21
+ const { workerSrc: r } = this._config, e = L(this._injector, r);
23
22
  [
24
- [IRPCChannelService, {
25
- useFactory: /* @__PURE__ */ __name(() => new ChannelService(messageProtocol), "useFactory")
23
+ [v, {
24
+ useFactory: () => new I(e)
26
25
  }],
27
- [DataSyncPrimaryController],
28
- [IRemoteSyncService, { useClass: RemoteSyncPrimaryService }]
29
- ].forEach((dependency) => this._injector.add(dependency)), this._injector.get(DataSyncPrimaryController);
26
+ [p],
27
+ [D, { useClass: b }]
28
+ ].forEach((n) => this._injector.add(n)), this._injector.get(p);
30
29
  }
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;
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
- [DataSyncReplicaController],
44
- [IRPCChannelService, {
45
- useFactory: /* @__PURE__ */ __name(() => new ChannelService(createNodeWorkerMessageProtocol()), "useFactory")
42
+ [f],
43
+ [v, {
44
+ useFactory: () => new I(F())
46
45
  }],
47
- [IRemoteInstanceService, { useClass: WebWorkerRemoteInstanceService }]
48
- ].forEach((d) => this._injector.add(d)), this._injector.get(DataSyncReplicaController);
46
+ [M, { useClass: U }]
47
+ ].forEach((r) => this._injector.add(r)), this._injector.get(f);
49
48
  }
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);
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 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))
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
- __name(createNodeMessagePortOnMain, "createNodeMessagePortOnMain");
69
- function createNodeWorkerMessageProtocol() {
67
+ function F() {
70
68
  return {
71
- send(message) {
72
- process.send(message);
69
+ send(r) {
70
+ a.send(r);
73
71
  },
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))
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.202411061606",
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.202411061606",
48
- "@univerjs/rpc": "0.4.2-nightly.202411061606"
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/core": "0.4.2-nightly.202411061606",
57
- "@univerjs/rpc": "0.4.2-nightly.202411061606"
58
+ "@univerjs/rpc": "0.4.2-nightly.202411081606",
59
+ "@univerjs/core": "0.4.2-nightly.202411081606"
58
60
  },
59
- "univerSpace": {
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": "tsc && vite build"
79
+ "build": "tsx build.ts"
76
80
  },
77
81
  "module": "./lib/es/index.js"
78
82
  }