@univerjs/rpc-node 1.4.0 → 1.5.1
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/README.md +18 -9
- package/lib/cjs/decorate-BGBv9V7T.js +134 -0
- package/lib/cjs/index.js +9 -15
- package/lib/cjs/worker.js +76 -2
- package/lib/decorate-BPmsIzEY.js +81 -0
- package/lib/es/decorate-BPmsIzEY.js +81 -0
- package/lib/es/index.js +2 -2
- package/lib/es/worker.js +48 -1
- package/lib/index.js +2 -2
- package/lib/types/index.d.ts +0 -3
- package/lib/umd/index.js +1 -1
- package/lib/worker.js +48 -1
- package/package.json +6 -6
- package/lib/cjs/worker-DRWxp0wy.js +0 -203
- package/lib/es/worker-C3wWR2ZL.js +0 -129
- package/lib/worker-C3wWR2ZL.js +0 -129
package/README.md
CHANGED
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
|
|
9
9
|
## Package Overview
|
|
10
10
|
|
|
11
|
-
| Package | UMD global | CSS | Locales | Facade entry |
|
|
12
|
-
| --- | --- | :---: | :---: | :---: |
|
|
13
|
-
| `@univerjs/rpc-node` | `UniverRpcNode` | No | No | No |
|
|
11
|
+
| Package | UMD global | CSS | Locales | Facade entry | Worker entry |
|
|
12
|
+
| --- | --- | :---: | :---: | :---: | :---: |
|
|
13
|
+
| `@univerjs/rpc-node` | `UniverRpcNode` | No | No | No | Yes |
|
|
14
14
|
|
|
15
15
|
## Installation
|
|
16
16
|
|
|
@@ -20,10 +20,10 @@ pnpm add @univerjs/rpc-node
|
|
|
20
20
|
npm install @univerjs/rpc-node
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
-
Keep all `@univerjs/*` packages on the same version.
|
|
24
|
-
|
|
25
23
|
## Usage
|
|
26
24
|
|
|
25
|
+
Start with the [integration setup](https://docs.univer.ai/) for your document type, including its required plugins, styles, and locale resources. The snippet below assumes that setup is complete.
|
|
26
|
+
|
|
27
27
|
```ts
|
|
28
28
|
import { fileURLToPath } from 'node:url';
|
|
29
29
|
import { UniverRPCNodeMainPlugin } from '@univerjs/rpc-node';
|
|
@@ -32,12 +32,21 @@ const workerSrc = fileURLToPath(new URL('./worker.js', import.meta.url));
|
|
|
32
32
|
univer.registerPlugin(UniverRPCNodeMainPlugin, { workerSrc });
|
|
33
33
|
```
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
Exported plugin classes:
|
|
35
|
+
Main-thread plugin classes:
|
|
38
36
|
|
|
39
37
|
- `UniverRPCNodeMainPlugin`
|
|
40
|
-
|
|
38
|
+
|
|
39
|
+
### Worker usage
|
|
40
|
+
|
|
41
|
+
On the main thread, import `UniverRPCNodeMainPlugin` from `@univerjs/rpc-node`. Set `workerSrc` to the worker module path.
|
|
42
|
+
|
|
43
|
+
In the worker entry, import `UniverRPCNodeWorkerPlugin` from `@univerjs/rpc-node/worker`:
|
|
44
|
+
|
|
45
|
+
```ts
|
|
46
|
+
import { UniverRPCNodeWorkerPlugin } from '@univerjs/rpc-node/worker';
|
|
47
|
+
|
|
48
|
+
univer.registerPlugin(UniverRPCNodeWorkerPlugin);
|
|
49
|
+
```
|
|
41
50
|
|
|
42
51
|
## Resources
|
|
43
52
|
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
// package.json
|
|
2
|
+
var name = "@univerjs/rpc-node";
|
|
3
|
+
var version = "1.5.1";
|
|
4
|
+
|
|
5
|
+
// src/config/config.ts
|
|
6
|
+
/**
|
|
7
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
8
|
+
*
|
|
9
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
10
|
+
* you may not use this file except in compliance with the License.
|
|
11
|
+
* You may obtain a copy of the License at
|
|
12
|
+
*
|
|
13
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
14
|
+
*
|
|
15
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
16
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
17
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
18
|
+
* See the License for the specific language governing permissions and
|
|
19
|
+
* limitations under the License.
|
|
20
|
+
*/
|
|
21
|
+
const PLUGIN_CONFIG_KEY_MAIN_THREAD = "rpc-node.main-thread.config";
|
|
22
|
+
const configSymbolMainThread = Symbol(PLUGIN_CONFIG_KEY_MAIN_THREAD);
|
|
23
|
+
const defaultPluginMainThreadConfig = {};
|
|
24
|
+
const PLUGIN_CONFIG_KEY_WORKER_THREAD = "rpc-node.worker-thread.config";
|
|
25
|
+
const configSymbolWorkerThread = Symbol(PLUGIN_CONFIG_KEY_WORKER_THREAD);
|
|
26
|
+
const defaultPluginWorkerThreadConfig = {};
|
|
27
|
+
|
|
28
|
+
// \0@oxc-project+runtime@0.157.0/helpers/esm/typeof.js
|
|
29
|
+
function _typeof(o) {
|
|
30
|
+
"@babel/helpers - typeof";
|
|
31
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
32
|
+
return typeof o;
|
|
33
|
+
} : function(o) {
|
|
34
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
35
|
+
}, _typeof(o);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// \0@oxc-project+runtime@0.157.0/helpers/esm/toPrimitive.js
|
|
39
|
+
function toPrimitive(t, e) {
|
|
40
|
+
if ("object" != _typeof(t) || !t) return t;
|
|
41
|
+
var r;
|
|
42
|
+
if ("undefined" != typeof Symbol && void 0 !== (r = t[Symbol.toPrimitive])) {
|
|
43
|
+
var i = r.call(t, e || "default");
|
|
44
|
+
if ("object" != _typeof(i)) return i;
|
|
45
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
46
|
+
}
|
|
47
|
+
return ("string" === e ? String : Number)(t);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// \0@oxc-project+runtime@0.157.0/helpers/esm/toPropertyKey.js
|
|
51
|
+
function toPropertyKey(t) {
|
|
52
|
+
var i = toPrimitive(t, "string");
|
|
53
|
+
return "symbol" == _typeof(i) ? i : i + "";
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// \0@oxc-project+runtime@0.157.0/helpers/esm/defineProperty.js
|
|
57
|
+
function _defineProperty(e, r, t) {
|
|
58
|
+
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
59
|
+
value: t,
|
|
60
|
+
enumerable: !0,
|
|
61
|
+
configurable: !0,
|
|
62
|
+
writable: !0
|
|
63
|
+
}) : e[r] = t, e;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// \0@oxc-project+runtime@0.157.0/helpers/esm/decorateParam.js
|
|
67
|
+
function __decorateParam(paramIndex, decorator) {
|
|
68
|
+
return function(target, key) {
|
|
69
|
+
decorator(target, key, paramIndex);
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// \0@oxc-project+runtime@0.157.0/helpers/esm/decorate.js
|
|
74
|
+
function __decorate(decorators, target, key, desc) {
|
|
75
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
76
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
77
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
78
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
Object.defineProperty(exports, "PLUGIN_CONFIG_KEY_MAIN_THREAD", {
|
|
82
|
+
enumerable: true,
|
|
83
|
+
get: function () {
|
|
84
|
+
return PLUGIN_CONFIG_KEY_MAIN_THREAD;
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
Object.defineProperty(exports, "PLUGIN_CONFIG_KEY_WORKER_THREAD", {
|
|
88
|
+
enumerable: true,
|
|
89
|
+
get: function () {
|
|
90
|
+
return PLUGIN_CONFIG_KEY_WORKER_THREAD;
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
Object.defineProperty(exports, "__decorate", {
|
|
94
|
+
enumerable: true,
|
|
95
|
+
get: function () {
|
|
96
|
+
return __decorate;
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
Object.defineProperty(exports, "__decorateParam", {
|
|
100
|
+
enumerable: true,
|
|
101
|
+
get: function () {
|
|
102
|
+
return __decorateParam;
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
Object.defineProperty(exports, "_defineProperty", {
|
|
106
|
+
enumerable: true,
|
|
107
|
+
get: function () {
|
|
108
|
+
return _defineProperty;
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
Object.defineProperty(exports, "defaultPluginMainThreadConfig", {
|
|
112
|
+
enumerable: true,
|
|
113
|
+
get: function () {
|
|
114
|
+
return defaultPluginMainThreadConfig;
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
Object.defineProperty(exports, "defaultPluginWorkerThreadConfig", {
|
|
118
|
+
enumerable: true,
|
|
119
|
+
get: function () {
|
|
120
|
+
return defaultPluginWorkerThreadConfig;
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
Object.defineProperty(exports, "name", {
|
|
124
|
+
enumerable: true,
|
|
125
|
+
get: function () {
|
|
126
|
+
return name;
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
Object.defineProperty(exports, "version", {
|
|
130
|
+
enumerable: true,
|
|
131
|
+
get: function () {
|
|
132
|
+
return version;
|
|
133
|
+
}
|
|
134
|
+
});
|
package/lib/cjs/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const
|
|
2
|
+
const require_decorate = require("./decorate-BGBv9V7T.js");
|
|
3
3
|
let _univerjs_core = require("@univerjs/core");
|
|
4
4
|
let _univerjs_rpc = require("@univerjs/rpc");
|
|
5
5
|
let node_child_process = require("node:child_process");
|
|
@@ -7,14 +7,14 @@ let rxjs = require("rxjs");
|
|
|
7
7
|
|
|
8
8
|
// src/plugin.ts
|
|
9
9
|
let UniverRPCNodeMainPlugin = class UniverRPCNodeMainPlugin extends _univerjs_core.Plugin {
|
|
10
|
-
constructor(_config =
|
|
10
|
+
constructor(_config = require_decorate.defaultPluginMainThreadConfig, _injector, _configService) {
|
|
11
11
|
super();
|
|
12
12
|
this._config = _config;
|
|
13
13
|
this._injector = _injector;
|
|
14
14
|
this._configService = _configService;
|
|
15
|
-
|
|
16
|
-
const { ...rest } = (0, _univerjs_core.merge)({},
|
|
17
|
-
this._configService.setConfig(
|
|
15
|
+
require_decorate._defineProperty(this, "_child", null);
|
|
16
|
+
const { ...rest } = (0, _univerjs_core.merge)({}, require_decorate.defaultPluginMainThreadConfig, this._config);
|
|
17
|
+
this._configService.setConfig(require_decorate.PLUGIN_CONFIG_KEY_MAIN_THREAD, rest);
|
|
18
18
|
}
|
|
19
19
|
onStarting() {
|
|
20
20
|
const { workerSrc } = this._config;
|
|
@@ -42,10 +42,10 @@ let UniverRPCNodeMainPlugin = class UniverRPCNodeMainPlugin extends _univerjs_co
|
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
};
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
UniverRPCNodeMainPlugin =
|
|
45
|
+
require_decorate._defineProperty(UniverRPCNodeMainPlugin, "pluginName", "UNIVER_RPC_NODE_MAIN_PLUGIN");
|
|
46
|
+
require_decorate._defineProperty(UniverRPCNodeMainPlugin, "packageName", require_decorate.name);
|
|
47
|
+
require_decorate._defineProperty(UniverRPCNodeMainPlugin, "version", require_decorate.version);
|
|
48
|
+
UniverRPCNodeMainPlugin = require_decorate.__decorate([require_decorate.__decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_core.Injector)), require_decorate.__decorateParam(2, _univerjs_core.IConfigService)], UniverRPCNodeMainPlugin);
|
|
49
49
|
function createNodeMessagePortOnMain(injector, path) {
|
|
50
50
|
const logService = injector.get(_univerjs_core.ILogService);
|
|
51
51
|
const child = (0, node_child_process.fork)(path);
|
|
@@ -73,10 +73,4 @@ Object.defineProperty(exports, "UniverRPCNodeMainPlugin", {
|
|
|
73
73
|
get: function () {
|
|
74
74
|
return UniverRPCNodeMainPlugin;
|
|
75
75
|
}
|
|
76
|
-
});
|
|
77
|
-
Object.defineProperty(exports, "UniverRPCNodeWorkerPlugin", {
|
|
78
|
-
enumerable: true,
|
|
79
|
-
get: function () {
|
|
80
|
-
return require_worker.UniverRPCNodeWorkerPlugin;
|
|
81
|
-
}
|
|
82
76
|
});
|
package/lib/cjs/worker.js
CHANGED
|
@@ -1,9 +1,83 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
|
|
2
|
+
// \0rolldown/runtime.js
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
12
|
+
key = keys[i];
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
14
|
+
__defProp(to, key, {
|
|
15
|
+
get: ((k) => from[k]).bind(null, key),
|
|
16
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
22
|
+
};
|
|
23
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
|
|
24
|
+
value: mod,
|
|
25
|
+
enumerable: true
|
|
26
|
+
}) : target, mod));
|
|
27
|
+
|
|
28
|
+
const require_decorate = require("./decorate-BGBv9V7T.js");
|
|
29
|
+
let _univerjs_core = require("@univerjs/core");
|
|
30
|
+
let _univerjs_rpc = require("@univerjs/rpc");
|
|
31
|
+
let rxjs = require("rxjs");
|
|
32
|
+
let node_process = require("node:process");
|
|
33
|
+
node_process = __toESM(node_process);
|
|
34
|
+
|
|
35
|
+
// src/worker.ts
|
|
36
|
+
let UniverRPCNodeWorkerPlugin = class UniverRPCNodeWorkerPlugin extends _univerjs_core.Plugin {
|
|
37
|
+
constructor(_config = require_decorate.defaultPluginWorkerThreadConfig, _injector, _configService) {
|
|
38
|
+
super();
|
|
39
|
+
this._config = _config;
|
|
40
|
+
this._injector = _injector;
|
|
41
|
+
this._configService = _configService;
|
|
42
|
+
const { ...rest } = (0, _univerjs_core.merge)({}, require_decorate.defaultPluginWorkerThreadConfig, this._config);
|
|
43
|
+
this._configService.setConfig(require_decorate.PLUGIN_CONFIG_KEY_WORKER_THREAD, rest);
|
|
44
|
+
}
|
|
45
|
+
onStarting() {
|
|
46
|
+
[
|
|
47
|
+
[_univerjs_rpc.DataSyncReplicaController],
|
|
48
|
+
[_univerjs_rpc.IRPCChannelService, { useFactory: function createChannelService() {
|
|
49
|
+
return new _univerjs_rpc.ChannelService(createNodeWorkerMessageProtocol());
|
|
50
|
+
} }],
|
|
51
|
+
[_univerjs_rpc.IRemoteInstanceService, { useClass: _univerjs_rpc.WebWorkerRemoteInstanceService }]
|
|
52
|
+
].forEach((d) => this._injector.add(d));
|
|
53
|
+
this._injector.get(_univerjs_rpc.DataSyncReplicaController);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
require_decorate._defineProperty(UniverRPCNodeWorkerPlugin, "pluginName", "UNIVER_RPC_NODE_WORKER_PLUGIN");
|
|
57
|
+
require_decorate._defineProperty(UniverRPCNodeWorkerPlugin, "packageName", require_decorate.name);
|
|
58
|
+
require_decorate._defineProperty(UniverRPCNodeWorkerPlugin, "version", require_decorate.version);
|
|
59
|
+
UniverRPCNodeWorkerPlugin = require_decorate.__decorate([require_decorate.__decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_core.Injector)), require_decorate.__decorateParam(2, _univerjs_core.IConfigService)], UniverRPCNodeWorkerPlugin);
|
|
60
|
+
function createNodeWorkerMessageProtocol() {
|
|
61
|
+
return {
|
|
62
|
+
send(message) {
|
|
63
|
+
node_process.default.send(message);
|
|
64
|
+
},
|
|
65
|
+
onMessage: new rxjs.Observable((subscriber) => {
|
|
66
|
+
const handler = (event) => {
|
|
67
|
+
subscriber.next(event);
|
|
68
|
+
};
|
|
69
|
+
node_process.default.on("message", handler);
|
|
70
|
+
return () => node_process.default.off("message", handler);
|
|
71
|
+
}).pipe((0, rxjs.shareReplay)({
|
|
72
|
+
bufferSize: 1,
|
|
73
|
+
refCount: true
|
|
74
|
+
}))
|
|
75
|
+
};
|
|
76
|
+
}
|
|
3
77
|
|
|
4
78
|
Object.defineProperty(exports, "UniverRPCNodeWorkerPlugin", {
|
|
5
79
|
enumerable: true,
|
|
6
80
|
get: function () {
|
|
7
|
-
return
|
|
81
|
+
return UniverRPCNodeWorkerPlugin;
|
|
8
82
|
}
|
|
9
83
|
});
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
// package.json
|
|
2
|
+
var name = "@univerjs/rpc-node";
|
|
3
|
+
var version = "1.5.1";
|
|
4
|
+
|
|
5
|
+
// src/config/config.ts
|
|
6
|
+
/**
|
|
7
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
8
|
+
*
|
|
9
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
10
|
+
* you may not use this file except in compliance with the License.
|
|
11
|
+
* You may obtain a copy of the License at
|
|
12
|
+
*
|
|
13
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
14
|
+
*
|
|
15
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
16
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
17
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
18
|
+
* See the License for the specific language governing permissions and
|
|
19
|
+
* limitations under the License.
|
|
20
|
+
*/
|
|
21
|
+
const PLUGIN_CONFIG_KEY_MAIN_THREAD = "rpc-node.main-thread.config";
|
|
22
|
+
const configSymbolMainThread = Symbol(PLUGIN_CONFIG_KEY_MAIN_THREAD);
|
|
23
|
+
const defaultPluginMainThreadConfig = {};
|
|
24
|
+
const PLUGIN_CONFIG_KEY_WORKER_THREAD = "rpc-node.worker-thread.config";
|
|
25
|
+
const configSymbolWorkerThread = Symbol(PLUGIN_CONFIG_KEY_WORKER_THREAD);
|
|
26
|
+
const defaultPluginWorkerThreadConfig = {};
|
|
27
|
+
|
|
28
|
+
// \0@oxc-project+runtime@0.157.0/helpers/esm/typeof.js
|
|
29
|
+
function _typeof(o) {
|
|
30
|
+
"@babel/helpers - typeof";
|
|
31
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
32
|
+
return typeof o;
|
|
33
|
+
} : function(o) {
|
|
34
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
35
|
+
}, _typeof(o);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// \0@oxc-project+runtime@0.157.0/helpers/esm/toPrimitive.js
|
|
39
|
+
function toPrimitive(t, e) {
|
|
40
|
+
if ("object" != _typeof(t) || !t) return t;
|
|
41
|
+
var r;
|
|
42
|
+
if ("undefined" != typeof Symbol && void 0 !== (r = t[Symbol.toPrimitive])) {
|
|
43
|
+
var i = r.call(t, e || "default");
|
|
44
|
+
if ("object" != _typeof(i)) return i;
|
|
45
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
46
|
+
}
|
|
47
|
+
return ("string" === e ? String : Number)(t);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// \0@oxc-project+runtime@0.157.0/helpers/esm/toPropertyKey.js
|
|
51
|
+
function toPropertyKey(t) {
|
|
52
|
+
var i = toPrimitive(t, "string");
|
|
53
|
+
return "symbol" == _typeof(i) ? i : i + "";
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// \0@oxc-project+runtime@0.157.0/helpers/esm/defineProperty.js
|
|
57
|
+
function _defineProperty(e, r, t) {
|
|
58
|
+
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
59
|
+
value: t,
|
|
60
|
+
enumerable: !0,
|
|
61
|
+
configurable: !0,
|
|
62
|
+
writable: !0
|
|
63
|
+
}) : e[r] = t, e;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// \0@oxc-project+runtime@0.157.0/helpers/esm/decorateParam.js
|
|
67
|
+
function __decorateParam(paramIndex, decorator) {
|
|
68
|
+
return function(target, key) {
|
|
69
|
+
decorator(target, key, paramIndex);
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// \0@oxc-project+runtime@0.157.0/helpers/esm/decorate.js
|
|
74
|
+
function __decorate(decorators, target, key, desc) {
|
|
75
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
76
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
77
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
78
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export { PLUGIN_CONFIG_KEY_WORKER_THREAD as a, name as c, PLUGIN_CONFIG_KEY_MAIN_THREAD as i, version as l, __decorateParam as n, defaultPluginMainThreadConfig as o, _defineProperty as r, defaultPluginWorkerThreadConfig as s, __decorate as t };
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
// package.json
|
|
2
|
+
var name = "@univerjs/rpc-node";
|
|
3
|
+
var version = "1.5.1";
|
|
4
|
+
|
|
5
|
+
// src/config/config.ts
|
|
6
|
+
/**
|
|
7
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
8
|
+
*
|
|
9
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
10
|
+
* you may not use this file except in compliance with the License.
|
|
11
|
+
* You may obtain a copy of the License at
|
|
12
|
+
*
|
|
13
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
14
|
+
*
|
|
15
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
16
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
17
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
18
|
+
* See the License for the specific language governing permissions and
|
|
19
|
+
* limitations under the License.
|
|
20
|
+
*/
|
|
21
|
+
const PLUGIN_CONFIG_KEY_MAIN_THREAD = "rpc-node.main-thread.config";
|
|
22
|
+
const configSymbolMainThread = Symbol(PLUGIN_CONFIG_KEY_MAIN_THREAD);
|
|
23
|
+
const defaultPluginMainThreadConfig = {};
|
|
24
|
+
const PLUGIN_CONFIG_KEY_WORKER_THREAD = "rpc-node.worker-thread.config";
|
|
25
|
+
const configSymbolWorkerThread = Symbol(PLUGIN_CONFIG_KEY_WORKER_THREAD);
|
|
26
|
+
const defaultPluginWorkerThreadConfig = {};
|
|
27
|
+
|
|
28
|
+
// \0@oxc-project+runtime@0.157.0/helpers/esm/typeof.js
|
|
29
|
+
function _typeof(o) {
|
|
30
|
+
"@babel/helpers - typeof";
|
|
31
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
32
|
+
return typeof o;
|
|
33
|
+
} : function(o) {
|
|
34
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
35
|
+
}, _typeof(o);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// \0@oxc-project+runtime@0.157.0/helpers/esm/toPrimitive.js
|
|
39
|
+
function toPrimitive(t, e) {
|
|
40
|
+
if ("object" != _typeof(t) || !t) return t;
|
|
41
|
+
var r;
|
|
42
|
+
if ("undefined" != typeof Symbol && void 0 !== (r = t[Symbol.toPrimitive])) {
|
|
43
|
+
var i = r.call(t, e || "default");
|
|
44
|
+
if ("object" != _typeof(i)) return i;
|
|
45
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
46
|
+
}
|
|
47
|
+
return ("string" === e ? String : Number)(t);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// \0@oxc-project+runtime@0.157.0/helpers/esm/toPropertyKey.js
|
|
51
|
+
function toPropertyKey(t) {
|
|
52
|
+
var i = toPrimitive(t, "string");
|
|
53
|
+
return "symbol" == _typeof(i) ? i : i + "";
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// \0@oxc-project+runtime@0.157.0/helpers/esm/defineProperty.js
|
|
57
|
+
function _defineProperty(e, r, t) {
|
|
58
|
+
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
59
|
+
value: t,
|
|
60
|
+
enumerable: !0,
|
|
61
|
+
configurable: !0,
|
|
62
|
+
writable: !0
|
|
63
|
+
}) : e[r] = t, e;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// \0@oxc-project+runtime@0.157.0/helpers/esm/decorateParam.js
|
|
67
|
+
function __decorateParam(paramIndex, decorator) {
|
|
68
|
+
return function(target, key) {
|
|
69
|
+
decorator(target, key, paramIndex);
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// \0@oxc-project+runtime@0.157.0/helpers/esm/decorate.js
|
|
74
|
+
function __decorate(decorators, target, key, desc) {
|
|
75
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
76
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
77
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
78
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export { PLUGIN_CONFIG_KEY_WORKER_THREAD as a, name as c, PLUGIN_CONFIG_KEY_MAIN_THREAD as i, version as l, __decorateParam as n, defaultPluginMainThreadConfig as o, _defineProperty as r, defaultPluginWorkerThreadConfig as s, __decorate as t };
|
package/lib/es/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { c as name, i as PLUGIN_CONFIG_KEY_MAIN_THREAD, l as version, n as __decorateParam, o as defaultPluginMainThreadConfig, r as _defineProperty, t as __decorate } from "./decorate-BPmsIzEY.js";
|
|
2
2
|
import { IConfigService, ILogService, Inject, Injector, Plugin, merge } from "@univerjs/core";
|
|
3
3
|
import { ChannelService, DataSyncPrimaryController, IRPCChannelService, IRemoteSyncService, RemoteSyncPrimaryService } from "@univerjs/rpc";
|
|
4
4
|
import { fork } from "node:child_process";
|
|
@@ -67,4 +67,4 @@ function createNodeMessagePortOnMain(injector, path) {
|
|
|
67
67
|
}, child];
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
export { UniverRPCNodeMainPlugin
|
|
70
|
+
export { UniverRPCNodeMainPlugin };
|
package/lib/es/worker.js
CHANGED
|
@@ -1,3 +1,50 @@
|
|
|
1
|
-
import { t as
|
|
1
|
+
import { a as PLUGIN_CONFIG_KEY_WORKER_THREAD, c as name, l as version, n as __decorateParam, r as _defineProperty, s as defaultPluginWorkerThreadConfig, t as __decorate } from "./decorate-BPmsIzEY.js";
|
|
2
|
+
import { IConfigService, Inject, Injector, Plugin, merge } from "@univerjs/core";
|
|
3
|
+
import { ChannelService, DataSyncReplicaController, IRPCChannelService, IRemoteInstanceService, WebWorkerRemoteInstanceService } from "@univerjs/rpc";
|
|
4
|
+
import { Observable, shareReplay } from "rxjs";
|
|
5
|
+
import process from "node:process";
|
|
6
|
+
|
|
7
|
+
// src/worker.ts
|
|
8
|
+
let UniverRPCNodeWorkerPlugin = class UniverRPCNodeWorkerPlugin extends Plugin {
|
|
9
|
+
constructor(_config = defaultPluginWorkerThreadConfig, _injector, _configService) {
|
|
10
|
+
super();
|
|
11
|
+
this._config = _config;
|
|
12
|
+
this._injector = _injector;
|
|
13
|
+
this._configService = _configService;
|
|
14
|
+
const { ...rest } = merge({}, defaultPluginWorkerThreadConfig, this._config);
|
|
15
|
+
this._configService.setConfig(PLUGIN_CONFIG_KEY_WORKER_THREAD, rest);
|
|
16
|
+
}
|
|
17
|
+
onStarting() {
|
|
18
|
+
[
|
|
19
|
+
[DataSyncReplicaController],
|
|
20
|
+
[IRPCChannelService, { useFactory: function createChannelService() {
|
|
21
|
+
return new ChannelService(createNodeWorkerMessageProtocol());
|
|
22
|
+
} }],
|
|
23
|
+
[IRemoteInstanceService, { useClass: WebWorkerRemoteInstanceService }]
|
|
24
|
+
].forEach((d) => this._injector.add(d));
|
|
25
|
+
this._injector.get(DataSyncReplicaController);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
_defineProperty(UniverRPCNodeWorkerPlugin, "pluginName", "UNIVER_RPC_NODE_WORKER_PLUGIN");
|
|
29
|
+
_defineProperty(UniverRPCNodeWorkerPlugin, "packageName", name);
|
|
30
|
+
_defineProperty(UniverRPCNodeWorkerPlugin, "version", version);
|
|
31
|
+
UniverRPCNodeWorkerPlugin = __decorate([__decorateParam(1, Inject(Injector)), __decorateParam(2, IConfigService)], UniverRPCNodeWorkerPlugin);
|
|
32
|
+
function createNodeWorkerMessageProtocol() {
|
|
33
|
+
return {
|
|
34
|
+
send(message) {
|
|
35
|
+
process.send(message);
|
|
36
|
+
},
|
|
37
|
+
onMessage: new Observable((subscriber) => {
|
|
38
|
+
const handler = (event) => {
|
|
39
|
+
subscriber.next(event);
|
|
40
|
+
};
|
|
41
|
+
process.on("message", handler);
|
|
42
|
+
return () => process.off("message", handler);
|
|
43
|
+
}).pipe(shareReplay({
|
|
44
|
+
bufferSize: 1,
|
|
45
|
+
refCount: true
|
|
46
|
+
}))
|
|
47
|
+
};
|
|
48
|
+
}
|
|
2
49
|
|
|
3
50
|
export { UniverRPCNodeWorkerPlugin };
|
package/lib/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { c as name, i as PLUGIN_CONFIG_KEY_MAIN_THREAD, l as version, n as __decorateParam, o as defaultPluginMainThreadConfig, r as _defineProperty, t as __decorate } from "./decorate-BPmsIzEY.js";
|
|
2
2
|
import { IConfigService, ILogService, Inject, Injector, Plugin, merge } from "@univerjs/core";
|
|
3
3
|
import { ChannelService, DataSyncPrimaryController, IRPCChannelService, IRemoteSyncService, RemoteSyncPrimaryService } from "@univerjs/rpc";
|
|
4
4
|
import { fork } from "node:child_process";
|
|
@@ -67,4 +67,4 @@ function createNodeMessagePortOnMain(injector, path) {
|
|
|
67
67
|
}, child];
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
export { UniverRPCNodeMainPlugin
|
|
70
|
+
export { UniverRPCNodeMainPlugin };
|
package/lib/types/index.d.ts
CHANGED
|
@@ -14,6 +14,3 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
export { UniverRPCNodeMainPlugin } from './plugin';
|
|
17
|
-
export {
|
|
18
|
-
/** @deprecated Import from '@univerjs/rpc-node/worker' instead. This root export will be removed in the next release. */
|
|
19
|
-
UniverRPCNodeWorkerPlugin, } from './worker';
|
package/lib/umd/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@univerjs/core"),require("@univerjs/rpc"),require("node:child_process"),require("rxjs")
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@univerjs/core"),require("@univerjs/rpc"),require("node:child_process"),require("rxjs")):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`,`@univerjs/rpc`,`node:child_process`,`rxjs`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverRpcNode={},e.UniverCore,e.UniverRpc,e[`Node:child_process`],e.rxjs))})(this,function(e,t,n,r,i){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var a=`@univerjs/rpc-node`,o=`1.5.1`;let s={};function c(e){"@babel/helpers - typeof";return c=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},c(e)}function l(e,t){if(c(e)!=`object`||!e)return e;var n;if(typeof Symbol<`u`&&(n=e[Symbol.toPrimitive])!==void 0){var r=n.call(e,t||`default`);if(c(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function u(e){var t=l(e,`string`);return c(t)==`symbol`?t:t+``}function d(e,t,n){return(t=u(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function f(e,t){return function(n,r){t(n,r,e)}}function p(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 m=class extends t.Plugin{constructor(e=s,n,r){super(),this._config=e,this._injector=n,this._configService=r,d(this,`_child`,null);let{...i}=(0,t.merge)({},s,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,r]=h(this._injector,e);[[n.IRPCChannelService,{useFactory:function(){return new n.ChannelService(t)}}],[n.DataSyncPrimaryController],[n.IRemoteSyncService,{useClass:n.RemoteSyncPrimaryService}]].forEach(e=>this._injector.add(e)),this._injector.get(n.DataSyncPrimaryController),this._child=r}dispose(){if(super.dispose(),this._child){try{this._child.kill()}catch(e){console.error(`Failed to kill child process:`,e)}this._child=null}}};d(m,`pluginName`,`UNIVER_RPC_NODE_MAIN_PLUGIN`),d(m,`packageName`,a),d(m,`version`,o),m=p([f(1,(0,t.Inject)(t.Injector)),f(2,t.IConfigService)],m);function h(e,n){let a=e.get(t.ILogService),o=(0,r.fork)(n);return o.on(`spawn`,()=>a.log(`Child computing process spawned!`)),o.on(`error`,e=>a.error(e)),[{send(e){o.send(e)},onMessage:new i.Observable(e=>{let t=t=>{e.next(t)};return o.on(`message`,t),()=>o.off(`message`,t)}).pipe((0,i.shareReplay)({bufferSize:1,refCount:!0}))},o]}Object.defineProperty(e,"UniverRPCNodeMainPlugin",{enumerable:!0,get:function(){return m}})});
|
package/lib/worker.js
CHANGED
|
@@ -1,3 +1,50 @@
|
|
|
1
|
-
import { t as
|
|
1
|
+
import { a as PLUGIN_CONFIG_KEY_WORKER_THREAD, c as name, l as version, n as __decorateParam, r as _defineProperty, s as defaultPluginWorkerThreadConfig, t as __decorate } from "./decorate-BPmsIzEY.js";
|
|
2
|
+
import { IConfigService, Inject, Injector, Plugin, merge } from "@univerjs/core";
|
|
3
|
+
import { ChannelService, DataSyncReplicaController, IRPCChannelService, IRemoteInstanceService, WebWorkerRemoteInstanceService } from "@univerjs/rpc";
|
|
4
|
+
import { Observable, shareReplay } from "rxjs";
|
|
5
|
+
import process from "node:process";
|
|
6
|
+
|
|
7
|
+
// src/worker.ts
|
|
8
|
+
let UniverRPCNodeWorkerPlugin = class UniverRPCNodeWorkerPlugin extends Plugin {
|
|
9
|
+
constructor(_config = defaultPluginWorkerThreadConfig, _injector, _configService) {
|
|
10
|
+
super();
|
|
11
|
+
this._config = _config;
|
|
12
|
+
this._injector = _injector;
|
|
13
|
+
this._configService = _configService;
|
|
14
|
+
const { ...rest } = merge({}, defaultPluginWorkerThreadConfig, this._config);
|
|
15
|
+
this._configService.setConfig(PLUGIN_CONFIG_KEY_WORKER_THREAD, rest);
|
|
16
|
+
}
|
|
17
|
+
onStarting() {
|
|
18
|
+
[
|
|
19
|
+
[DataSyncReplicaController],
|
|
20
|
+
[IRPCChannelService, { useFactory: function createChannelService() {
|
|
21
|
+
return new ChannelService(createNodeWorkerMessageProtocol());
|
|
22
|
+
} }],
|
|
23
|
+
[IRemoteInstanceService, { useClass: WebWorkerRemoteInstanceService }]
|
|
24
|
+
].forEach((d) => this._injector.add(d));
|
|
25
|
+
this._injector.get(DataSyncReplicaController);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
_defineProperty(UniverRPCNodeWorkerPlugin, "pluginName", "UNIVER_RPC_NODE_WORKER_PLUGIN");
|
|
29
|
+
_defineProperty(UniverRPCNodeWorkerPlugin, "packageName", name);
|
|
30
|
+
_defineProperty(UniverRPCNodeWorkerPlugin, "version", version);
|
|
31
|
+
UniverRPCNodeWorkerPlugin = __decorate([__decorateParam(1, Inject(Injector)), __decorateParam(2, IConfigService)], UniverRPCNodeWorkerPlugin);
|
|
32
|
+
function createNodeWorkerMessageProtocol() {
|
|
33
|
+
return {
|
|
34
|
+
send(message) {
|
|
35
|
+
process.send(message);
|
|
36
|
+
},
|
|
37
|
+
onMessage: new Observable((subscriber) => {
|
|
38
|
+
const handler = (event) => {
|
|
39
|
+
subscriber.next(event);
|
|
40
|
+
};
|
|
41
|
+
process.on("message", handler);
|
|
42
|
+
return () => process.off("message", handler);
|
|
43
|
+
}).pipe(shareReplay({
|
|
44
|
+
bufferSize: 1,
|
|
45
|
+
refCount: true
|
|
46
|
+
}))
|
|
47
|
+
};
|
|
48
|
+
}
|
|
2
49
|
|
|
3
50
|
export { UniverRPCNodeWorkerPlugin };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/rpc-node",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.1",
|
|
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>",
|
|
@@ -57,14 +57,14 @@
|
|
|
57
57
|
"rxjs": ">=7.0.0"
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
|
-
"@univerjs/core": "1.
|
|
61
|
-
"@univerjs/rpc": "1.
|
|
60
|
+
"@univerjs/core": "1.5.1",
|
|
61
|
+
"@univerjs/rpc": "1.5.1"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
|
-
"@univerjs-infra/shared": "1.
|
|
64
|
+
"@univerjs-infra/shared": "1.5.1",
|
|
65
65
|
"rxjs": "7.8.2",
|
|
66
|
-
"tsrs": "0.
|
|
67
|
-
"vitest": "^5.0
|
|
66
|
+
"tsrs": "0.23.0-ts7.1.0-beta",
|
|
67
|
+
"vitest": "^5.1.0"
|
|
68
68
|
},
|
|
69
69
|
"scripts": {
|
|
70
70
|
"test": "vitest run",
|
|
@@ -1,203 +0,0 @@
|
|
|
1
|
-
// \0rolldown/runtime.js
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
-
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
-
key = keys[i];
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
13
|
-
__defProp(to, key, {
|
|
14
|
-
get: ((k) => from[k]).bind(null, key),
|
|
15
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
return to;
|
|
21
|
-
};
|
|
22
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
|
|
23
|
-
value: mod,
|
|
24
|
-
enumerable: true
|
|
25
|
-
}) : target, mod));
|
|
26
|
-
|
|
27
|
-
let _univerjs_core = require("@univerjs/core");
|
|
28
|
-
let _univerjs_rpc = require("@univerjs/rpc");
|
|
29
|
-
let rxjs = require("rxjs");
|
|
30
|
-
let node_process = require("node:process");
|
|
31
|
-
node_process = __toESM(node_process);
|
|
32
|
-
|
|
33
|
-
// package.json
|
|
34
|
-
var name = "@univerjs/rpc-node";
|
|
35
|
-
var version = "1.4.0";
|
|
36
|
-
|
|
37
|
-
// src/config/config.ts
|
|
38
|
-
/**
|
|
39
|
-
* Copyright 2023-present DreamNum Co., Ltd.
|
|
40
|
-
*
|
|
41
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
42
|
-
* you may not use this file except in compliance with the License.
|
|
43
|
-
* You may obtain a copy of the License at
|
|
44
|
-
*
|
|
45
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
46
|
-
*
|
|
47
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
48
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
49
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
50
|
-
* See the License for the specific language governing permissions and
|
|
51
|
-
* limitations under the License.
|
|
52
|
-
*/
|
|
53
|
-
const PLUGIN_CONFIG_KEY_MAIN_THREAD = "rpc-node.main-thread.config";
|
|
54
|
-
const configSymbolMainThread = Symbol(PLUGIN_CONFIG_KEY_MAIN_THREAD);
|
|
55
|
-
const defaultPluginMainThreadConfig = {};
|
|
56
|
-
const PLUGIN_CONFIG_KEY_WORKER_THREAD = "rpc-node.worker-thread.config";
|
|
57
|
-
const configSymbolWorkerThread = Symbol(PLUGIN_CONFIG_KEY_WORKER_THREAD);
|
|
58
|
-
const defaultPluginWorkerThreadConfig = {};
|
|
59
|
-
|
|
60
|
-
// \0@oxc-project+runtime@0.156.0/helpers/esm/typeof.js
|
|
61
|
-
function _typeof(o) {
|
|
62
|
-
"@babel/helpers - typeof";
|
|
63
|
-
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
64
|
-
return typeof o;
|
|
65
|
-
} : function(o) {
|
|
66
|
-
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
67
|
-
}, _typeof(o);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// \0@oxc-project+runtime@0.156.0/helpers/esm/toPrimitive.js
|
|
71
|
-
function toPrimitive(t, r) {
|
|
72
|
-
if ("object" != _typeof(t) || !t) return t;
|
|
73
|
-
var e = t[Symbol.toPrimitive];
|
|
74
|
-
if (void 0 !== e) {
|
|
75
|
-
var i = e.call(t, r || "default");
|
|
76
|
-
if ("object" != _typeof(i)) return i;
|
|
77
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
78
|
-
}
|
|
79
|
-
return ("string" === r ? String : Number)(t);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
// \0@oxc-project+runtime@0.156.0/helpers/esm/toPropertyKey.js
|
|
83
|
-
function toPropertyKey(t) {
|
|
84
|
-
var i = toPrimitive(t, "string");
|
|
85
|
-
return "symbol" == _typeof(i) ? i : i + "";
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
// \0@oxc-project+runtime@0.156.0/helpers/esm/defineProperty.js
|
|
89
|
-
function _defineProperty(e, r, t) {
|
|
90
|
-
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
91
|
-
value: t,
|
|
92
|
-
enumerable: !0,
|
|
93
|
-
configurable: !0,
|
|
94
|
-
writable: !0
|
|
95
|
-
}) : e[r] = t, e;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
// \0@oxc-project+runtime@0.156.0/helpers/esm/decorateParam.js
|
|
99
|
-
function __decorateParam(paramIndex, decorator) {
|
|
100
|
-
return function(target, key) {
|
|
101
|
-
decorator(target, key, paramIndex);
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
// \0@oxc-project+runtime@0.156.0/helpers/esm/decorate.js
|
|
106
|
-
function __decorate(decorators, target, key, desc) {
|
|
107
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
108
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
109
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
110
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
// src/worker.ts
|
|
114
|
-
let UniverRPCNodeWorkerPlugin = class UniverRPCNodeWorkerPlugin extends _univerjs_core.Plugin {
|
|
115
|
-
constructor(_config = defaultPluginWorkerThreadConfig, _injector, _configService) {
|
|
116
|
-
super();
|
|
117
|
-
this._config = _config;
|
|
118
|
-
this._injector = _injector;
|
|
119
|
-
this._configService = _configService;
|
|
120
|
-
const { ...rest } = (0, _univerjs_core.merge)({}, defaultPluginWorkerThreadConfig, this._config);
|
|
121
|
-
this._configService.setConfig(PLUGIN_CONFIG_KEY_WORKER_THREAD, rest);
|
|
122
|
-
}
|
|
123
|
-
onStarting() {
|
|
124
|
-
[
|
|
125
|
-
[_univerjs_rpc.DataSyncReplicaController],
|
|
126
|
-
[_univerjs_rpc.IRPCChannelService, { useFactory: function createChannelService() {
|
|
127
|
-
return new _univerjs_rpc.ChannelService(createNodeWorkerMessageProtocol());
|
|
128
|
-
} }],
|
|
129
|
-
[_univerjs_rpc.IRemoteInstanceService, { useClass: _univerjs_rpc.WebWorkerRemoteInstanceService }]
|
|
130
|
-
].forEach((d) => this._injector.add(d));
|
|
131
|
-
this._injector.get(_univerjs_rpc.DataSyncReplicaController);
|
|
132
|
-
}
|
|
133
|
-
};
|
|
134
|
-
_defineProperty(UniverRPCNodeWorkerPlugin, "pluginName", "UNIVER_RPC_NODE_WORKER_PLUGIN");
|
|
135
|
-
_defineProperty(UniverRPCNodeWorkerPlugin, "packageName", name);
|
|
136
|
-
_defineProperty(UniverRPCNodeWorkerPlugin, "version", version);
|
|
137
|
-
UniverRPCNodeWorkerPlugin = __decorate([__decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_core.Injector)), __decorateParam(2, _univerjs_core.IConfigService)], UniverRPCNodeWorkerPlugin);
|
|
138
|
-
function createNodeWorkerMessageProtocol() {
|
|
139
|
-
return {
|
|
140
|
-
send(message) {
|
|
141
|
-
node_process.default.send(message);
|
|
142
|
-
},
|
|
143
|
-
onMessage: new rxjs.Observable((subscriber) => {
|
|
144
|
-
const handler = (event) => {
|
|
145
|
-
subscriber.next(event);
|
|
146
|
-
};
|
|
147
|
-
node_process.default.on("message", handler);
|
|
148
|
-
return () => node_process.default.off("message", handler);
|
|
149
|
-
}).pipe((0, rxjs.shareReplay)({
|
|
150
|
-
bufferSize: 1,
|
|
151
|
-
refCount: true
|
|
152
|
-
}))
|
|
153
|
-
};
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
Object.defineProperty(exports, "PLUGIN_CONFIG_KEY_MAIN_THREAD", {
|
|
157
|
-
enumerable: true,
|
|
158
|
-
get: function () {
|
|
159
|
-
return PLUGIN_CONFIG_KEY_MAIN_THREAD;
|
|
160
|
-
}
|
|
161
|
-
});
|
|
162
|
-
Object.defineProperty(exports, "UniverRPCNodeWorkerPlugin", {
|
|
163
|
-
enumerable: true,
|
|
164
|
-
get: function () {
|
|
165
|
-
return UniverRPCNodeWorkerPlugin;
|
|
166
|
-
}
|
|
167
|
-
});
|
|
168
|
-
Object.defineProperty(exports, "__decorate", {
|
|
169
|
-
enumerable: true,
|
|
170
|
-
get: function () {
|
|
171
|
-
return __decorate;
|
|
172
|
-
}
|
|
173
|
-
});
|
|
174
|
-
Object.defineProperty(exports, "__decorateParam", {
|
|
175
|
-
enumerable: true,
|
|
176
|
-
get: function () {
|
|
177
|
-
return __decorateParam;
|
|
178
|
-
}
|
|
179
|
-
});
|
|
180
|
-
Object.defineProperty(exports, "_defineProperty", {
|
|
181
|
-
enumerable: true,
|
|
182
|
-
get: function () {
|
|
183
|
-
return _defineProperty;
|
|
184
|
-
}
|
|
185
|
-
});
|
|
186
|
-
Object.defineProperty(exports, "defaultPluginMainThreadConfig", {
|
|
187
|
-
enumerable: true,
|
|
188
|
-
get: function () {
|
|
189
|
-
return defaultPluginMainThreadConfig;
|
|
190
|
-
}
|
|
191
|
-
});
|
|
192
|
-
Object.defineProperty(exports, "name", {
|
|
193
|
-
enumerable: true,
|
|
194
|
-
get: function () {
|
|
195
|
-
return name;
|
|
196
|
-
}
|
|
197
|
-
});
|
|
198
|
-
Object.defineProperty(exports, "version", {
|
|
199
|
-
enumerable: true,
|
|
200
|
-
get: function () {
|
|
201
|
-
return version;
|
|
202
|
-
}
|
|
203
|
-
});
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
import { IConfigService, Inject, Injector, Plugin, merge } from "@univerjs/core";
|
|
2
|
-
import { ChannelService, DataSyncReplicaController, IRPCChannelService, IRemoteInstanceService, WebWorkerRemoteInstanceService } from "@univerjs/rpc";
|
|
3
|
-
import { Observable, shareReplay } from "rxjs";
|
|
4
|
-
import process from "node:process";
|
|
5
|
-
|
|
6
|
-
// package.json
|
|
7
|
-
var name = "@univerjs/rpc-node";
|
|
8
|
-
var version = "1.4.0";
|
|
9
|
-
|
|
10
|
-
// src/config/config.ts
|
|
11
|
-
/**
|
|
12
|
-
* Copyright 2023-present DreamNum Co., Ltd.
|
|
13
|
-
*
|
|
14
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
15
|
-
* you may not use this file except in compliance with the License.
|
|
16
|
-
* You may obtain a copy of the License at
|
|
17
|
-
*
|
|
18
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
19
|
-
*
|
|
20
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
21
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
22
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
23
|
-
* See the License for the specific language governing permissions and
|
|
24
|
-
* limitations under the License.
|
|
25
|
-
*/
|
|
26
|
-
const PLUGIN_CONFIG_KEY_MAIN_THREAD = "rpc-node.main-thread.config";
|
|
27
|
-
const configSymbolMainThread = Symbol(PLUGIN_CONFIG_KEY_MAIN_THREAD);
|
|
28
|
-
const defaultPluginMainThreadConfig = {};
|
|
29
|
-
const PLUGIN_CONFIG_KEY_WORKER_THREAD = "rpc-node.worker-thread.config";
|
|
30
|
-
const configSymbolWorkerThread = Symbol(PLUGIN_CONFIG_KEY_WORKER_THREAD);
|
|
31
|
-
const defaultPluginWorkerThreadConfig = {};
|
|
32
|
-
|
|
33
|
-
// \0@oxc-project+runtime@0.156.0/helpers/esm/typeof.js
|
|
34
|
-
function _typeof(o) {
|
|
35
|
-
"@babel/helpers - typeof";
|
|
36
|
-
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
37
|
-
return typeof o;
|
|
38
|
-
} : function(o) {
|
|
39
|
-
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
40
|
-
}, _typeof(o);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
// \0@oxc-project+runtime@0.156.0/helpers/esm/toPrimitive.js
|
|
44
|
-
function toPrimitive(t, r) {
|
|
45
|
-
if ("object" != _typeof(t) || !t) return t;
|
|
46
|
-
var e = t[Symbol.toPrimitive];
|
|
47
|
-
if (void 0 !== e) {
|
|
48
|
-
var i = e.call(t, r || "default");
|
|
49
|
-
if ("object" != _typeof(i)) return i;
|
|
50
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
51
|
-
}
|
|
52
|
-
return ("string" === r ? String : Number)(t);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// \0@oxc-project+runtime@0.156.0/helpers/esm/toPropertyKey.js
|
|
56
|
-
function toPropertyKey(t) {
|
|
57
|
-
var i = toPrimitive(t, "string");
|
|
58
|
-
return "symbol" == _typeof(i) ? i : i + "";
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// \0@oxc-project+runtime@0.156.0/helpers/esm/defineProperty.js
|
|
62
|
-
function _defineProperty(e, r, t) {
|
|
63
|
-
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
64
|
-
value: t,
|
|
65
|
-
enumerable: !0,
|
|
66
|
-
configurable: !0,
|
|
67
|
-
writable: !0
|
|
68
|
-
}) : e[r] = t, e;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
// \0@oxc-project+runtime@0.156.0/helpers/esm/decorateParam.js
|
|
72
|
-
function __decorateParam(paramIndex, decorator) {
|
|
73
|
-
return function(target, key) {
|
|
74
|
-
decorator(target, key, paramIndex);
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
// \0@oxc-project+runtime@0.156.0/helpers/esm/decorate.js
|
|
79
|
-
function __decorate(decorators, target, key, desc) {
|
|
80
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
81
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
82
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
83
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
// src/worker.ts
|
|
87
|
-
let UniverRPCNodeWorkerPlugin = class UniverRPCNodeWorkerPlugin extends Plugin {
|
|
88
|
-
constructor(_config = defaultPluginWorkerThreadConfig, _injector, _configService) {
|
|
89
|
-
super();
|
|
90
|
-
this._config = _config;
|
|
91
|
-
this._injector = _injector;
|
|
92
|
-
this._configService = _configService;
|
|
93
|
-
const { ...rest } = merge({}, defaultPluginWorkerThreadConfig, this._config);
|
|
94
|
-
this._configService.setConfig(PLUGIN_CONFIG_KEY_WORKER_THREAD, rest);
|
|
95
|
-
}
|
|
96
|
-
onStarting() {
|
|
97
|
-
[
|
|
98
|
-
[DataSyncReplicaController],
|
|
99
|
-
[IRPCChannelService, { useFactory: function createChannelService() {
|
|
100
|
-
return new ChannelService(createNodeWorkerMessageProtocol());
|
|
101
|
-
} }],
|
|
102
|
-
[IRemoteInstanceService, { useClass: WebWorkerRemoteInstanceService }]
|
|
103
|
-
].forEach((d) => this._injector.add(d));
|
|
104
|
-
this._injector.get(DataSyncReplicaController);
|
|
105
|
-
}
|
|
106
|
-
};
|
|
107
|
-
_defineProperty(UniverRPCNodeWorkerPlugin, "pluginName", "UNIVER_RPC_NODE_WORKER_PLUGIN");
|
|
108
|
-
_defineProperty(UniverRPCNodeWorkerPlugin, "packageName", name);
|
|
109
|
-
_defineProperty(UniverRPCNodeWorkerPlugin, "version", version);
|
|
110
|
-
UniverRPCNodeWorkerPlugin = __decorate([__decorateParam(1, Inject(Injector)), __decorateParam(2, IConfigService)], UniverRPCNodeWorkerPlugin);
|
|
111
|
-
function createNodeWorkerMessageProtocol() {
|
|
112
|
-
return {
|
|
113
|
-
send(message) {
|
|
114
|
-
process.send(message);
|
|
115
|
-
},
|
|
116
|
-
onMessage: new Observable((subscriber) => {
|
|
117
|
-
const handler = (event) => {
|
|
118
|
-
subscriber.next(event);
|
|
119
|
-
};
|
|
120
|
-
process.on("message", handler);
|
|
121
|
-
return () => process.off("message", handler);
|
|
122
|
-
}).pipe(shareReplay({
|
|
123
|
-
bufferSize: 1,
|
|
124
|
-
refCount: true
|
|
125
|
-
}))
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
export { PLUGIN_CONFIG_KEY_MAIN_THREAD as a, version as c, _defineProperty as i, __decorate as n, defaultPluginMainThreadConfig as o, __decorateParam as r, name as s, UniverRPCNodeWorkerPlugin as t };
|
package/lib/worker-C3wWR2ZL.js
DELETED
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
import { IConfigService, Inject, Injector, Plugin, merge } from "@univerjs/core";
|
|
2
|
-
import { ChannelService, DataSyncReplicaController, IRPCChannelService, IRemoteInstanceService, WebWorkerRemoteInstanceService } from "@univerjs/rpc";
|
|
3
|
-
import { Observable, shareReplay } from "rxjs";
|
|
4
|
-
import process from "node:process";
|
|
5
|
-
|
|
6
|
-
// package.json
|
|
7
|
-
var name = "@univerjs/rpc-node";
|
|
8
|
-
var version = "1.4.0";
|
|
9
|
-
|
|
10
|
-
// src/config/config.ts
|
|
11
|
-
/**
|
|
12
|
-
* Copyright 2023-present DreamNum Co., Ltd.
|
|
13
|
-
*
|
|
14
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
15
|
-
* you may not use this file except in compliance with the License.
|
|
16
|
-
* You may obtain a copy of the License at
|
|
17
|
-
*
|
|
18
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
19
|
-
*
|
|
20
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
21
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
22
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
23
|
-
* See the License for the specific language governing permissions and
|
|
24
|
-
* limitations under the License.
|
|
25
|
-
*/
|
|
26
|
-
const PLUGIN_CONFIG_KEY_MAIN_THREAD = "rpc-node.main-thread.config";
|
|
27
|
-
const configSymbolMainThread = Symbol(PLUGIN_CONFIG_KEY_MAIN_THREAD);
|
|
28
|
-
const defaultPluginMainThreadConfig = {};
|
|
29
|
-
const PLUGIN_CONFIG_KEY_WORKER_THREAD = "rpc-node.worker-thread.config";
|
|
30
|
-
const configSymbolWorkerThread = Symbol(PLUGIN_CONFIG_KEY_WORKER_THREAD);
|
|
31
|
-
const defaultPluginWorkerThreadConfig = {};
|
|
32
|
-
|
|
33
|
-
// \0@oxc-project+runtime@0.156.0/helpers/esm/typeof.js
|
|
34
|
-
function _typeof(o) {
|
|
35
|
-
"@babel/helpers - typeof";
|
|
36
|
-
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
37
|
-
return typeof o;
|
|
38
|
-
} : function(o) {
|
|
39
|
-
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
40
|
-
}, _typeof(o);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
// \0@oxc-project+runtime@0.156.0/helpers/esm/toPrimitive.js
|
|
44
|
-
function toPrimitive(t, r) {
|
|
45
|
-
if ("object" != _typeof(t) || !t) return t;
|
|
46
|
-
var e = t[Symbol.toPrimitive];
|
|
47
|
-
if (void 0 !== e) {
|
|
48
|
-
var i = e.call(t, r || "default");
|
|
49
|
-
if ("object" != _typeof(i)) return i;
|
|
50
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
51
|
-
}
|
|
52
|
-
return ("string" === r ? String : Number)(t);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// \0@oxc-project+runtime@0.156.0/helpers/esm/toPropertyKey.js
|
|
56
|
-
function toPropertyKey(t) {
|
|
57
|
-
var i = toPrimitive(t, "string");
|
|
58
|
-
return "symbol" == _typeof(i) ? i : i + "";
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// \0@oxc-project+runtime@0.156.0/helpers/esm/defineProperty.js
|
|
62
|
-
function _defineProperty(e, r, t) {
|
|
63
|
-
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
64
|
-
value: t,
|
|
65
|
-
enumerable: !0,
|
|
66
|
-
configurable: !0,
|
|
67
|
-
writable: !0
|
|
68
|
-
}) : e[r] = t, e;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
// \0@oxc-project+runtime@0.156.0/helpers/esm/decorateParam.js
|
|
72
|
-
function __decorateParam(paramIndex, decorator) {
|
|
73
|
-
return function(target, key) {
|
|
74
|
-
decorator(target, key, paramIndex);
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
// \0@oxc-project+runtime@0.156.0/helpers/esm/decorate.js
|
|
79
|
-
function __decorate(decorators, target, key, desc) {
|
|
80
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
81
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
82
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
83
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
// src/worker.ts
|
|
87
|
-
let UniverRPCNodeWorkerPlugin = class UniverRPCNodeWorkerPlugin extends Plugin {
|
|
88
|
-
constructor(_config = defaultPluginWorkerThreadConfig, _injector, _configService) {
|
|
89
|
-
super();
|
|
90
|
-
this._config = _config;
|
|
91
|
-
this._injector = _injector;
|
|
92
|
-
this._configService = _configService;
|
|
93
|
-
const { ...rest } = merge({}, defaultPluginWorkerThreadConfig, this._config);
|
|
94
|
-
this._configService.setConfig(PLUGIN_CONFIG_KEY_WORKER_THREAD, rest);
|
|
95
|
-
}
|
|
96
|
-
onStarting() {
|
|
97
|
-
[
|
|
98
|
-
[DataSyncReplicaController],
|
|
99
|
-
[IRPCChannelService, { useFactory: function createChannelService() {
|
|
100
|
-
return new ChannelService(createNodeWorkerMessageProtocol());
|
|
101
|
-
} }],
|
|
102
|
-
[IRemoteInstanceService, { useClass: WebWorkerRemoteInstanceService }]
|
|
103
|
-
].forEach((d) => this._injector.add(d));
|
|
104
|
-
this._injector.get(DataSyncReplicaController);
|
|
105
|
-
}
|
|
106
|
-
};
|
|
107
|
-
_defineProperty(UniverRPCNodeWorkerPlugin, "pluginName", "UNIVER_RPC_NODE_WORKER_PLUGIN");
|
|
108
|
-
_defineProperty(UniverRPCNodeWorkerPlugin, "packageName", name);
|
|
109
|
-
_defineProperty(UniverRPCNodeWorkerPlugin, "version", version);
|
|
110
|
-
UniverRPCNodeWorkerPlugin = __decorate([__decorateParam(1, Inject(Injector)), __decorateParam(2, IConfigService)], UniverRPCNodeWorkerPlugin);
|
|
111
|
-
function createNodeWorkerMessageProtocol() {
|
|
112
|
-
return {
|
|
113
|
-
send(message) {
|
|
114
|
-
process.send(message);
|
|
115
|
-
},
|
|
116
|
-
onMessage: new Observable((subscriber) => {
|
|
117
|
-
const handler = (event) => {
|
|
118
|
-
subscriber.next(event);
|
|
119
|
-
};
|
|
120
|
-
process.on("message", handler);
|
|
121
|
-
return () => process.off("message", handler);
|
|
122
|
-
}).pipe(shareReplay({
|
|
123
|
-
bufferSize: 1,
|
|
124
|
-
refCount: true
|
|
125
|
-
}))
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
export { PLUGIN_CONFIG_KEY_MAIN_THREAD as a, version as c, _defineProperty as i, __decorate as n, defaultPluginMainThreadConfig as o, __decorateParam as r, name as s, UniverRPCNodeWorkerPlugin as t };
|