@univerjs/rpc-node 0.24.0 → 0.25.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 +15 -9
- package/lib/es/index.js +15 -9
- package/lib/index.js +15 -9
- package/lib/umd/index.js +1 -1
- package/package.json +5 -5
package/lib/cjs/index.js
CHANGED
|
@@ -35,7 +35,7 @@ let rxjs = require("rxjs");
|
|
|
35
35
|
|
|
36
36
|
//#region package.json
|
|
37
37
|
var name = "@univerjs/rpc-node";
|
|
38
|
-
var version = "0.
|
|
38
|
+
var version = "0.25.0";
|
|
39
39
|
|
|
40
40
|
//#endregion
|
|
41
41
|
//#region src/config/config.ts
|
|
@@ -62,7 +62,7 @@ const configSymbolWorkerThread = Symbol(PLUGIN_CONFIG_KEY_WORKER_THREAD);
|
|
|
62
62
|
const defaultPluginWorkerThreadConfig = {};
|
|
63
63
|
|
|
64
64
|
//#endregion
|
|
65
|
-
//#region \0@oxc-project+runtime@0.
|
|
65
|
+
//#region \0@oxc-project+runtime@0.133.0/helpers/esm/typeof.js
|
|
66
66
|
function _typeof(o) {
|
|
67
67
|
"@babel/helpers - typeof";
|
|
68
68
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -73,7 +73,7 @@ function _typeof(o) {
|
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
//#endregion
|
|
76
|
-
//#region \0@oxc-project+runtime@0.
|
|
76
|
+
//#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPrimitive.js
|
|
77
77
|
function toPrimitive(t, r) {
|
|
78
78
|
if ("object" != _typeof(t) || !t) return t;
|
|
79
79
|
var e = t[Symbol.toPrimitive];
|
|
@@ -86,14 +86,14 @@ function toPrimitive(t, r) {
|
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
//#endregion
|
|
89
|
-
//#region \0@oxc-project+runtime@0.
|
|
89
|
+
//#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPropertyKey.js
|
|
90
90
|
function toPropertyKey(t) {
|
|
91
91
|
var i = toPrimitive(t, "string");
|
|
92
92
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
//#endregion
|
|
96
|
-
//#region \0@oxc-project+runtime@0.
|
|
96
|
+
//#region \0@oxc-project+runtime@0.133.0/helpers/esm/defineProperty.js
|
|
97
97
|
function _defineProperty(e, r, t) {
|
|
98
98
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
99
99
|
value: t,
|
|
@@ -104,7 +104,7 @@ function _defineProperty(e, r, t) {
|
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
//#endregion
|
|
107
|
-
//#region \0@oxc-project+runtime@0.
|
|
107
|
+
//#region \0@oxc-project+runtime@0.133.0/helpers/esm/decorateParam.js
|
|
108
108
|
function __decorateParam(paramIndex, decorator) {
|
|
109
109
|
return function(target, key) {
|
|
110
110
|
decorator(target, key, paramIndex);
|
|
@@ -112,7 +112,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
112
112
|
}
|
|
113
113
|
|
|
114
114
|
//#endregion
|
|
115
|
-
//#region \0@oxc-project+runtime@0.
|
|
115
|
+
//#region \0@oxc-project+runtime@0.133.0/helpers/esm/decorate.js
|
|
116
116
|
function __decorate(decorators, target, key, desc) {
|
|
117
117
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
118
118
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -197,7 +197,10 @@ function createNodeMessagePortOnMain(injector, path) {
|
|
|
197
197
|
};
|
|
198
198
|
child.on("message", handler);
|
|
199
199
|
return () => child.off("message", handler);
|
|
200
|
-
}).pipe((0, rxjs.shareReplay)(
|
|
200
|
+
}).pipe((0, rxjs.shareReplay)({
|
|
201
|
+
bufferSize: 1,
|
|
202
|
+
refCount: true
|
|
203
|
+
}))
|
|
201
204
|
}, child];
|
|
202
205
|
}
|
|
203
206
|
function createNodeWorkerMessageProtocol() {
|
|
@@ -211,7 +214,10 @@ function createNodeWorkerMessageProtocol() {
|
|
|
211
214
|
};
|
|
212
215
|
node_process.default.on("message", handler);
|
|
213
216
|
return () => node_process.default.off("message", handler);
|
|
214
|
-
}).pipe((0, rxjs.shareReplay)(
|
|
217
|
+
}).pipe((0, rxjs.shareReplay)({
|
|
218
|
+
bufferSize: 1,
|
|
219
|
+
refCount: true
|
|
220
|
+
}))
|
|
215
221
|
};
|
|
216
222
|
}
|
|
217
223
|
|
package/lib/es/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import { Observable, shareReplay } from "rxjs";
|
|
|
6
6
|
|
|
7
7
|
//#region package.json
|
|
8
8
|
var name = "@univerjs/rpc-node";
|
|
9
|
-
var version = "0.
|
|
9
|
+
var version = "0.25.0";
|
|
10
10
|
|
|
11
11
|
//#endregion
|
|
12
12
|
//#region src/config/config.ts
|
|
@@ -33,7 +33,7 @@ const configSymbolWorkerThread = Symbol(PLUGIN_CONFIG_KEY_WORKER_THREAD);
|
|
|
33
33
|
const defaultPluginWorkerThreadConfig = {};
|
|
34
34
|
|
|
35
35
|
//#endregion
|
|
36
|
-
//#region \0@oxc-project+runtime@0.
|
|
36
|
+
//#region \0@oxc-project+runtime@0.133.0/helpers/esm/typeof.js
|
|
37
37
|
function _typeof(o) {
|
|
38
38
|
"@babel/helpers - typeof";
|
|
39
39
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -44,7 +44,7 @@ function _typeof(o) {
|
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
//#endregion
|
|
47
|
-
//#region \0@oxc-project+runtime@0.
|
|
47
|
+
//#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPrimitive.js
|
|
48
48
|
function toPrimitive(t, r) {
|
|
49
49
|
if ("object" != _typeof(t) || !t) return t;
|
|
50
50
|
var e = t[Symbol.toPrimitive];
|
|
@@ -57,14 +57,14 @@ function toPrimitive(t, r) {
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
//#endregion
|
|
60
|
-
//#region \0@oxc-project+runtime@0.
|
|
60
|
+
//#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPropertyKey.js
|
|
61
61
|
function toPropertyKey(t) {
|
|
62
62
|
var i = toPrimitive(t, "string");
|
|
63
63
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
//#endregion
|
|
67
|
-
//#region \0@oxc-project+runtime@0.
|
|
67
|
+
//#region \0@oxc-project+runtime@0.133.0/helpers/esm/defineProperty.js
|
|
68
68
|
function _defineProperty(e, r, t) {
|
|
69
69
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
70
70
|
value: t,
|
|
@@ -75,7 +75,7 @@ function _defineProperty(e, r, t) {
|
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
//#endregion
|
|
78
|
-
//#region \0@oxc-project+runtime@0.
|
|
78
|
+
//#region \0@oxc-project+runtime@0.133.0/helpers/esm/decorateParam.js
|
|
79
79
|
function __decorateParam(paramIndex, decorator) {
|
|
80
80
|
return function(target, key) {
|
|
81
81
|
decorator(target, key, paramIndex);
|
|
@@ -83,7 +83,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
//#endregion
|
|
86
|
-
//#region \0@oxc-project+runtime@0.
|
|
86
|
+
//#region \0@oxc-project+runtime@0.133.0/helpers/esm/decorate.js
|
|
87
87
|
function __decorate(decorators, target, key, desc) {
|
|
88
88
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
89
89
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -168,7 +168,10 @@ function createNodeMessagePortOnMain(injector, path) {
|
|
|
168
168
|
};
|
|
169
169
|
child.on("message", handler);
|
|
170
170
|
return () => child.off("message", handler);
|
|
171
|
-
}).pipe(shareReplay(
|
|
171
|
+
}).pipe(shareReplay({
|
|
172
|
+
bufferSize: 1,
|
|
173
|
+
refCount: true
|
|
174
|
+
}))
|
|
172
175
|
}, child];
|
|
173
176
|
}
|
|
174
177
|
function createNodeWorkerMessageProtocol() {
|
|
@@ -182,7 +185,10 @@ function createNodeWorkerMessageProtocol() {
|
|
|
182
185
|
};
|
|
183
186
|
process.on("message", handler);
|
|
184
187
|
return () => process.off("message", handler);
|
|
185
|
-
}).pipe(shareReplay(
|
|
188
|
+
}).pipe(shareReplay({
|
|
189
|
+
bufferSize: 1,
|
|
190
|
+
refCount: true
|
|
191
|
+
}))
|
|
186
192
|
};
|
|
187
193
|
}
|
|
188
194
|
|
package/lib/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import { Observable, shareReplay } from "rxjs";
|
|
|
6
6
|
|
|
7
7
|
//#region package.json
|
|
8
8
|
var name = "@univerjs/rpc-node";
|
|
9
|
-
var version = "0.
|
|
9
|
+
var version = "0.25.0";
|
|
10
10
|
|
|
11
11
|
//#endregion
|
|
12
12
|
//#region src/config/config.ts
|
|
@@ -33,7 +33,7 @@ const configSymbolWorkerThread = Symbol(PLUGIN_CONFIG_KEY_WORKER_THREAD);
|
|
|
33
33
|
const defaultPluginWorkerThreadConfig = {};
|
|
34
34
|
|
|
35
35
|
//#endregion
|
|
36
|
-
//#region \0@oxc-project+runtime@0.
|
|
36
|
+
//#region \0@oxc-project+runtime@0.133.0/helpers/esm/typeof.js
|
|
37
37
|
function _typeof(o) {
|
|
38
38
|
"@babel/helpers - typeof";
|
|
39
39
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -44,7 +44,7 @@ function _typeof(o) {
|
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
//#endregion
|
|
47
|
-
//#region \0@oxc-project+runtime@0.
|
|
47
|
+
//#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPrimitive.js
|
|
48
48
|
function toPrimitive(t, r) {
|
|
49
49
|
if ("object" != _typeof(t) || !t) return t;
|
|
50
50
|
var e = t[Symbol.toPrimitive];
|
|
@@ -57,14 +57,14 @@ function toPrimitive(t, r) {
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
//#endregion
|
|
60
|
-
//#region \0@oxc-project+runtime@0.
|
|
60
|
+
//#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPropertyKey.js
|
|
61
61
|
function toPropertyKey(t) {
|
|
62
62
|
var i = toPrimitive(t, "string");
|
|
63
63
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
//#endregion
|
|
67
|
-
//#region \0@oxc-project+runtime@0.
|
|
67
|
+
//#region \0@oxc-project+runtime@0.133.0/helpers/esm/defineProperty.js
|
|
68
68
|
function _defineProperty(e, r, t) {
|
|
69
69
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
70
70
|
value: t,
|
|
@@ -75,7 +75,7 @@ function _defineProperty(e, r, t) {
|
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
//#endregion
|
|
78
|
-
//#region \0@oxc-project+runtime@0.
|
|
78
|
+
//#region \0@oxc-project+runtime@0.133.0/helpers/esm/decorateParam.js
|
|
79
79
|
function __decorateParam(paramIndex, decorator) {
|
|
80
80
|
return function(target, key) {
|
|
81
81
|
decorator(target, key, paramIndex);
|
|
@@ -83,7 +83,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
//#endregion
|
|
86
|
-
//#region \0@oxc-project+runtime@0.
|
|
86
|
+
//#region \0@oxc-project+runtime@0.133.0/helpers/esm/decorate.js
|
|
87
87
|
function __decorate(decorators, target, key, desc) {
|
|
88
88
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
89
89
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -168,7 +168,10 @@ function createNodeMessagePortOnMain(injector, path) {
|
|
|
168
168
|
};
|
|
169
169
|
child.on("message", handler);
|
|
170
170
|
return () => child.off("message", handler);
|
|
171
|
-
}).pipe(shareReplay(
|
|
171
|
+
}).pipe(shareReplay({
|
|
172
|
+
bufferSize: 1,
|
|
173
|
+
refCount: true
|
|
174
|
+
}))
|
|
172
175
|
}, child];
|
|
173
176
|
}
|
|
174
177
|
function createNodeWorkerMessageProtocol() {
|
|
@@ -182,7 +185,10 @@ function createNodeWorkerMessageProtocol() {
|
|
|
182
185
|
};
|
|
183
186
|
process.on("message", handler);
|
|
184
187
|
return () => process.off("message", handler);
|
|
185
|
-
}).pipe(shareReplay(
|
|
188
|
+
}).pipe(shareReplay({
|
|
189
|
+
bufferSize: 1,
|
|
190
|
+
refCount: true
|
|
191
|
+
}))
|
|
186
192
|
};
|
|
187
193
|
}
|
|
188
194
|
|
package/lib/umd/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(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`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverRpcNode={},e[`Node:child_process`],e[`Node:process`],e.UniverCore,e.UniverRpc,e.rxjs))})(this,function(e,t,n,r,i,a){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var o=Object.create,s=Object.defineProperty,c=Object.getOwnPropertyDescriptor,l=Object.getOwnPropertyNames,u=Object.getPrototypeOf,d=Object.prototype.hasOwnProperty,f=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=l(t),a=0,o=i.length,u;a<o;a++)u=i[a],!d.call(e,u)&&u!==n&&s(e,u,{get:(e=>t[e]).bind(null,u),enumerable:!(r=c(t,u))||r.enumerable});return e};n=((e,t,n)=>(n=e==null?{}:o(u(e)),f(t||!e||!e.__esModule?s(n,`default`,{value:e,enumerable:!0}):n,e)))(n);var p=`@univerjs/rpc-node`,m=`0.25.0`;let h={},g={};function _(e){"@babel/helpers - typeof";return _=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},_(e)}function v(e,t){if(_(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(_(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function y(e){var t=v(e,`string`);return _(t)==`symbol`?t:t+``}function b(e,t,n){return(t=y(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function x(e,t){return function(n,r){t(n,r,e)}}function S(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}let C=class extends r.Plugin{constructor(e=h,t,n){super(),this._config=e,this._injector=t,this._configService=n,b(this,`_child`,null);let{...i}=(0,r.merge)({},h,this._config);this._configService.setConfig(`rpc-node.main-thread.config`,i)}onStarting(){let{workerSrc:e}=this._config;if(!e)throw Error(`[UniverRPCNodeMainPlugin] workerSrc is required for UniverRPCNodeMainPlugin`);let[t,n]=T(this._injector,e);[[i.IRPCChannelService,{useFactory:()=>new i.ChannelService(t)}],[i.DataSyncPrimaryController],[i.IRemoteSyncService,{useClass:i.RemoteSyncPrimaryService}]].forEach(e=>this._injector.add(e)),this._injector.get(i.DataSyncPrimaryController),this._child=n}dispose(){if(super.dispose(),this._child){try{this._child.kill()}catch(e){console.error(`Failed to kill child process:`,e)}this._child=null}}};b(C,`pluginName`,`UNIVER_RPC_NODE_MAIN_PLUGIN`),b(C,`packageName`,p),b(C,`version`,m),C=S([x(1,(0,r.Inject)(r.Injector)),x(2,r.IConfigService)],C);let w=class extends r.Plugin{constructor(e=g,t,n){super(),this._config=e,this._injector=t,this._configService=n;let{...i}=(0,r.merge)({},g,this._config);this._configService.setConfig(`rpc-node.worker-thread.config`,i)}onStarting(){[[i.DataSyncReplicaController],[i.IRPCChannelService,{useFactory:()=>new i.ChannelService(E())}],[i.IRemoteInstanceService,{useClass:i.WebWorkerRemoteInstanceService}]].forEach(e=>this._injector.add(e)),this._injector.get(i.DataSyncReplicaController)}};b(w,`pluginName`,`UNIVER_RPC_NODE_WORKER_PLUGIN`),b(w,`packageName`,p),b(w,`version`,m),w=S([x(1,(0,r.Inject)(r.Injector)),x(2,r.IConfigService)],w);function T(e,n){let i=e.get(r.ILogService),o=(0,t.fork)(n);return o.on(`spawn`,()=>i.log(`Child computing process spawned!`)),o.on(`error`,e=>i.error(e)),[{send(e){o.send(e)},onMessage:new a.Observable(e=>{let t=t=>{e.next(t)};return o.on(`message`,t),()=>o.off(`message`,t)}).pipe((0,a.shareReplay)({bufferSize:1,refCount:!0}))},o]}function E(){return{send(e){n.default.send(e)},onMessage:new a.Observable(e=>{let t=t=>{e.next(t)};return n.default.on(`message`,t),()=>n.default.off(`message`,t)}).pipe((0,a.shareReplay)({bufferSize:1,refCount:!0}))}}Object.defineProperty(e,"UniverRPCNodeMainPlugin",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"UniverRPCNodeWorkerPlugin",{enumerable:!0,get:function(){return w}})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/rpc-node",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.25.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Node.js RPC plugins for Univer main-thread and worker communication.",
|
|
6
6
|
"author": "DreamNum Co., Ltd. <developer@univer.ai>",
|
|
@@ -52,14 +52,14 @@
|
|
|
52
52
|
"rxjs": ">=7.0.0"
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@univerjs/
|
|
56
|
-
"@univerjs/
|
|
55
|
+
"@univerjs/rpc": "0.25.0",
|
|
56
|
+
"@univerjs/core": "0.25.0"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"rxjs": "^7.8.2",
|
|
60
60
|
"typescript": "^6.0.3",
|
|
61
|
-
"vitest": "^4.1.
|
|
62
|
-
"@univerjs-infra/shared": "0.
|
|
61
|
+
"vitest": "^4.1.7",
|
|
62
|
+
"@univerjs-infra/shared": "0.25.0"
|
|
63
63
|
},
|
|
64
64
|
"scripts": {
|
|
65
65
|
"test": "vitest run",
|