@univerjs/rpc 0.1.3 → 0.1.5
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 +1 -1
- package/lib/types/controllers/data-sync/data-sync-primary.controller.d.ts +4 -18
- package/lib/types/controllers/data-sync/data-sync-replica.controller.d.ts +4 -18
- package/lib/types/plugin.d.ts +2 -16
- package/lib/types/services/remote-instance/remote-instance.service.d.ts +4 -19
- package/lib/types/services/rpc/channel.service.d.ts +3 -17
- package/lib/types/services/rpc/implementations/web-worker-rpc.service.d.ts +2 -16
- package/lib/types/services/rpc/rpc.service.d.ts +2 -16
- package/package.json +10 -8
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
When handling some time-intensive tasks, such as formula computation, Univer can offload them to a location outside of the main thread, such as a Web Worker thread. The `@univerjs/rpc` library provides an RPC mechanism that simplifies communication between the main thread and other threads.
|
|
9
9
|
|
|
10
|
-
For more information, see the [Architecture of Web Worker](https://univer.ai/
|
|
10
|
+
For more information, see the [Architecture of Web Worker](https://univer.ai/guides/concepts-and-architecture/web-worker/).
|
|
11
11
|
|
|
12
12
|
## Usage
|
|
13
13
|
|
|
@@ -1,22 +1,8 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright 2023-present DreamNum Inc.
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
import { ICommandService, IUniverInstanceService, RxDisposable } from '@univerjs/core';
|
|
17
|
-
import { Injector } from '@wendellhu/redi';
|
|
18
|
-
import { IRemoteSyncService } from '../../services/remote-instance/remote-instance.service';
|
|
19
1
|
import { IRPChannelService } from '../../services/rpc/channel.service';
|
|
2
|
+
import { IRemoteSyncService } from '../../services/remote-instance/remote-instance.service';
|
|
3
|
+
import { Injector } from '@wendellhu/redi';
|
|
4
|
+
import { ICommandService, IUniverInstanceService, RxDisposable } from '@univerjs/core';
|
|
5
|
+
|
|
20
6
|
/**
|
|
21
7
|
* This controller is responsible for syncing data from the primary thread to
|
|
22
8
|
* the worker thread.
|
|
@@ -1,22 +1,8 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright 2023-present DreamNum Inc.
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
import { Disposable, ICommandService } from '@univerjs/core';
|
|
17
|
-
import { Injector } from '@wendellhu/redi';
|
|
18
|
-
import { IRemoteInstanceService } from '../../services/remote-instance/remote-instance.service';
|
|
19
1
|
import { IRPChannelService } from '../../services/rpc/channel.service';
|
|
2
|
+
import { IRemoteInstanceService } from '../../services/remote-instance/remote-instance.service';
|
|
3
|
+
import { Injector } from '@wendellhu/redi';
|
|
4
|
+
import { Disposable, ICommandService } from '@univerjs/core';
|
|
5
|
+
|
|
20
6
|
/**
|
|
21
7
|
* This controller is responsible for syncing data from the worker thread to
|
|
22
8
|
* the primary thread.
|
package/lib/types/plugin.d.ts
CHANGED
|
@@ -1,20 +1,6 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright 2023-present DreamNum Inc.
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
import { Plugin, PluginType } from '@univerjs/core';
|
|
17
1
|
import { Injector } from '@wendellhu/redi';
|
|
2
|
+
import { Plugin, PluginType } from '@univerjs/core';
|
|
3
|
+
|
|
18
4
|
export interface IUniverRPCMainThreadConfig {
|
|
19
5
|
workerURL: string | URL | Worker;
|
|
20
6
|
}
|
|
@@ -1,20 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
import type { IExecutionOptions, IMutationInfo, IWorkbookData } from '@univerjs/core';
|
|
17
|
-
import { ICommandService, IUniverInstanceService, UniverInstanceType } from '@univerjs/core';
|
|
1
|
+
import { IExecutionOptions, IMutationInfo, IWorkbookData, ICommandService, IUniverInstanceService, UniverInstanceType } from '@univerjs/core';
|
|
2
|
+
|
|
18
3
|
export interface IRemoteSyncMutationOptions extends IExecutionOptions {
|
|
19
4
|
/** If this mutation is executed after it was sent from the peer univer instance (e.g. in a web worker). */
|
|
20
5
|
fromSync?: boolean;
|
|
@@ -25,7 +10,7 @@ export declare const RemoteSyncServiceName = "univer.remote-sync-service";
|
|
|
25
10
|
*
|
|
26
11
|
* Replica Univer could call this service to update mutations back to the primary Univer.
|
|
27
12
|
*/
|
|
28
|
-
export declare const IRemoteSyncService: import(
|
|
13
|
+
export declare const IRemoteSyncService: import('@wendellhu/redi').IdentifierDecorator<IRemoteSyncService>;
|
|
29
14
|
export interface IRemoteSyncService {
|
|
30
15
|
syncMutation(params: {
|
|
31
16
|
mutationInfo: IMutationInfo;
|
|
@@ -45,7 +30,7 @@ export declare const RemoteInstanceServiceName = "univer.remote-instance-service
|
|
|
45
30
|
* Primary univer could call this service to init and dispose univer business instances
|
|
46
31
|
* and sync mutations to replica univer.
|
|
47
32
|
*/
|
|
48
|
-
export declare const IRemoteInstanceService: import(
|
|
33
|
+
export declare const IRemoteInstanceService: import('@wendellhu/redi').IdentifierDecorator<IRemoteInstanceService>;
|
|
49
34
|
export interface IRemoteInstanceService {
|
|
50
35
|
/** Tell other modules if the `IRemoteInstanceService` is ready to load files. */
|
|
51
36
|
whenReady(): Promise<true>;
|
|
@@ -1,24 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
import type { IChannel, IMessageProtocol } from './rpc.service';
|
|
1
|
+
import { IChannel, IMessageProtocol } from './rpc.service';
|
|
2
|
+
|
|
17
3
|
export interface IRPChannelService {
|
|
18
4
|
requestChannel(name: string): IChannel;
|
|
19
5
|
registerChannel(name: string, channel: IChannel): void;
|
|
20
6
|
}
|
|
21
|
-
export declare const IRPChannelService: import(
|
|
7
|
+
export declare const IRPChannelService: import('@wendellhu/redi').IdentifierDecorator<IRPChannelService>;
|
|
22
8
|
/**
|
|
23
9
|
* This service is responsible for managing the RPC channels.
|
|
24
10
|
*/
|
|
@@ -1,19 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
import type { IMessageProtocol } from '../rpc.service';
|
|
1
|
+
import { IMessageProtocol } from '../rpc.service';
|
|
2
|
+
|
|
17
3
|
/**
|
|
18
4
|
* Generate an `IMessageProtocol` on the web worker.
|
|
19
5
|
*/
|
|
@@ -1,20 +1,6 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright 2023-present DreamNum Inc.
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
import { RxDisposable } from '@univerjs/core';
|
|
17
1
|
import { Observable } from 'rxjs';
|
|
2
|
+
import { RxDisposable } from '@univerjs/core';
|
|
3
|
+
|
|
18
4
|
/** This protocol is for transferring data from the two peer univer instance running in different locations. */
|
|
19
5
|
export interface IMessageProtocol {
|
|
20
6
|
send(message: any): void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/rpc",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"private": false,
|
|
5
5
|
"author": "DreamNum <developer@univer.ai>",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -16,7 +16,9 @@
|
|
|
16
16
|
"bugs": {
|
|
17
17
|
"url": "https://github.com/dream-num/univer/issues"
|
|
18
18
|
},
|
|
19
|
-
"keywords": [
|
|
19
|
+
"keywords": [
|
|
20
|
+
"univer"
|
|
21
|
+
],
|
|
20
22
|
"exports": {
|
|
21
23
|
".": {
|
|
22
24
|
"import": "./lib/es/index.js",
|
|
@@ -49,17 +51,17 @@
|
|
|
49
51
|
"peerDependencies": {
|
|
50
52
|
"@wendellhu/redi": "0.13.0",
|
|
51
53
|
"rxjs": ">=7.0.0",
|
|
52
|
-
"@univerjs/core": "0.1.
|
|
54
|
+
"@univerjs/core": "0.1.5"
|
|
53
55
|
},
|
|
54
56
|
"dependencies": {},
|
|
55
57
|
"devDependencies": {
|
|
56
58
|
"@wendellhu/redi": "^0.13.0",
|
|
57
59
|
"rxjs": "^7.8.1",
|
|
58
|
-
"typescript": "^5.4.
|
|
59
|
-
"vite": "^5.
|
|
60
|
-
"vitest": "^1.
|
|
61
|
-
"@univerjs/
|
|
62
|
-
"@univerjs/
|
|
60
|
+
"typescript": "^5.4.3",
|
|
61
|
+
"vite": "^5.2.6",
|
|
62
|
+
"vitest": "^1.4.0",
|
|
63
|
+
"@univerjs/core": "0.1.5",
|
|
64
|
+
"@univerjs/shared": "0.1.5"
|
|
63
65
|
},
|
|
64
66
|
"scripts": {
|
|
65
67
|
"lint:types": "tsc --noEmit",
|