@univerjs/rpc 1.0.0-insiders.20260809-70eefdd → 1.0.0-rc.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/LICENSE ADDED
@@ -0,0 +1,176 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
package/README.md CHANGED
@@ -27,9 +27,13 @@ Keep all `@univerjs/*` packages on the same version.
27
27
  ```ts
28
28
  import { UniverRPCMainThreadPlugin } from '@univerjs/rpc';
29
29
 
30
- univer.registerPlugin(UniverRPCMainThreadPlugin);
30
+ const worker = new Worker(new URL('./worker.js', import.meta.url), { type: 'module' });
31
+ univer.registerPlugin(UniverRPCMainThreadPlugin, { workerURL: worker });
32
+ univer.onDispose(() => worker.terminate());
31
33
  ```
32
34
 
35
+ The referenced worker module must create its own Univer instance and register `UniverRPCWorkerThreadPlugin`; see the [browser worker example](../../examples/src/sheets-mobile/worker.ts).
36
+
33
37
  Exported plugin classes:
34
38
 
35
39
  - `UniverRPCMainThreadPlugin`
@@ -40,4 +44,3 @@ Exported plugin classes:
40
44
  - [Documentation](https://docs.univer.ai)
41
45
  - [NPM package](https://npmjs.com/package/@univerjs/rpc)
42
46
  - [GitHub repository](https://github.com/dream-num/univer)
43
-
package/lib/cjs/index.js CHANGED
@@ -75,13 +75,15 @@ const RemoteInstanceServiceName = "univer.remote-instance-service";
75
75
  */
76
76
  const IRemoteInstanceService = (0, _univerjs_core.createIdentifier)(RemoteInstanceServiceName);
77
77
  let WebWorkerRemoteInstanceService = class WebWorkerRemoteInstanceService {
78
- constructor(_univerInstanceService, _commandService, _logService) {
78
+ constructor(_univerInstanceService, _commandService, _logService, _lifecycleService) {
79
79
  this._univerInstanceService = _univerInstanceService;
80
80
  this._commandService = _commandService;
81
81
  this._logService = _logService;
82
+ this._lifecycleService = _lifecycleService;
82
83
  }
83
84
  whenReady() {
84
- return Promise.resolve(true);
85
+ if (this._lifecycleService.stage >= _univerjs_core.LifecycleStages.Ready) return Promise.resolve(true);
86
+ return this._lifecycleService.onStage(_univerjs_core.LifecycleStages.Ready).then(() => true);
85
87
  }
86
88
  async syncMutation(params, options) {
87
89
  return this._applyMutation(params.mutationInfo, options);
@@ -121,7 +123,8 @@ let WebWorkerRemoteInstanceService = class WebWorkerRemoteInstanceService {
121
123
  WebWorkerRemoteInstanceService = __decorate([
122
124
  __decorateParam(0, _univerjs_core.IUniverInstanceService),
123
125
  __decorateParam(1, _univerjs_core.ICommandService),
124
- __decorateParam(2, _univerjs_core.ILogService)
126
+ __decorateParam(2, _univerjs_core.ILogService),
127
+ __decorateParam(3, (0, _univerjs_core.Inject)(_univerjs_core.LifecycleService))
125
128
  ], WebWorkerRemoteInstanceService);
126
129
 
127
130
  //#endregion
@@ -234,7 +237,12 @@ var ChannelClient = class extends _univerjs_core.RxDisposable {
234
237
  this._protocol.onMessage.pipe((0, rxjs_operators.takeUntil)(this.dispose$)).subscribe((message) => this._onMessage(message));
235
238
  }
236
239
  dispose() {
240
+ if (this._disposed) return;
241
+ const error = /* @__PURE__ */ new Error("[ChannelClient]: client is disposed!");
242
+ this._initialized.error(error);
243
+ for (const responseHandler of this._pendingRequests.values()) responseHandler.dispose(error);
237
244
  this._pendingRequests.clear();
245
+ super.dispose();
238
246
  }
239
247
  getChannel(channelName) {
240
248
  return {
@@ -266,19 +274,24 @@ var ChannelClient = class extends _univerjs_core.RxDisposable {
266
274
  };
267
275
  const pendingRequests = this._pendingRequests;
268
276
  return new Promise((resolve, reject) => {
269
- this._pendingRequests.set(sequence, { handle(response) {
270
- switch (response.type) {
271
- case 201:
272
- pendingRequests.delete(sequence);
273
- resolve(response.data);
274
- break;
275
- case 202:
276
- pendingRequests.delete(sequence);
277
- reject(response.data);
278
- break;
279
- default: throw new Error("[ChannelClient]: unknown response type!");
277
+ this._pendingRequests.set(sequence, {
278
+ handle(response) {
279
+ switch (response.type) {
280
+ case 201:
281
+ pendingRequests.delete(sequence);
282
+ resolve(response.data);
283
+ break;
284
+ case 202:
285
+ pendingRequests.delete(sequence);
286
+ reject(response.data);
287
+ break;
288
+ default: throw new Error("[ChannelClient]: unknown response type!");
289
+ }
290
+ },
291
+ dispose(error) {
292
+ reject(error);
280
293
  }
281
- } });
294
+ });
282
295
  this._sendRequest(request);
283
296
  });
284
297
  }
@@ -294,20 +307,25 @@ var ChannelClient = class extends _univerjs_core.RxDisposable {
294
307
  method,
295
308
  args
296
309
  };
297
- this._pendingRequests.set(sequence, { handle(response) {
298
- switch (response.type) {
299
- case 300:
300
- subscriber.next(response.data);
301
- break;
302
- case 301:
303
- subscriber.error(response.data);
304
- break;
305
- case 302:
306
- subscriber.complete();
307
- break;
308
- default: throw new Error("[ChannelClient]: unknown response type!");
310
+ this._pendingRequests.set(sequence, {
311
+ handle(response) {
312
+ switch (response.type) {
313
+ case 300:
314
+ subscriber.next(response.data);
315
+ break;
316
+ case 301:
317
+ subscriber.error(response.data);
318
+ break;
319
+ case 302:
320
+ subscriber.complete();
321
+ break;
322
+ default: throw new Error("[ChannelClient]: unknown response type!");
323
+ }
324
+ },
325
+ dispose(error) {
326
+ subscriber.error(error);
309
327
  }
310
- } });
328
+ });
311
329
  this._sendRequest(request);
312
330
  };
313
331
  if (this._initialized.getValue()) doSubscribe();
@@ -358,6 +376,7 @@ var ChannelServer = class extends _univerjs_core.RxDisposable {
358
376
  }
359
377
  dispose() {
360
378
  super.dispose();
379
+ for (const subscription of this._subscriptions.values()) subscription.unsubscribe();
361
380
  this._subscriptions.clear();
362
381
  this._channels.clear();
363
382
  }
@@ -512,6 +531,7 @@ let DataSyncPrimaryController = class DataSyncPrimaryController extends _univerj
512
531
  _defineProperty(this, "_syncingUnits", /* @__PURE__ */ new Set());
513
532
  _defineProperty(this, "_syncingMutations", /* @__PURE__ */ new Set());
514
533
  _defineProperty(this, "_syncMutationQueue", Promise.resolve());
534
+ _defineProperty(this, "_remoteReady", Promise.resolve(true));
515
535
  this._initRPCChannels();
516
536
  this._init();
517
537
  }
@@ -544,10 +564,20 @@ let DataSyncPrimaryController = class DataSyncPrimaryController extends _univerj
544
564
  if (!alreadySyncing) this._syncingUnits.delete(unitId);
545
565
  });
546
566
  }
567
+ async syncMutation(commandInfo, options) {
568
+ const sync = () => this._remoteReady.then(() => this._remoteInstanceService.syncMutation({ mutationInfo: commandInfo }, options));
569
+ const result = this._syncMutationQueue.then(sync, sync);
570
+ this._syncMutationQueue = result.catch(() => false);
571
+ return result;
572
+ }
573
+ async waitForPendingMutations() {
574
+ await this._syncMutationQueue.catch(() => false);
575
+ }
547
576
  _initRPCChannels() {
548
577
  this._rpcChannelService.registerChannel(RemoteSyncServiceName, fromModule(this._remoteSyncService));
549
578
  this._injector.add([IRemoteInstanceService, { useFactory: () => toModule(this._rpcChannelService.requestChannel(RemoteInstanceServiceName)) }]);
550
579
  this._remoteInstanceService = this._injector.get(IRemoteInstanceService);
580
+ this._remoteReady = this._remoteInstanceService.whenReady();
551
581
  }
552
582
  _init() {
553
583
  this._univerInstanceService.getTypeOfUnitAdded$(_univerjs_core.UniverInstanceType.UNIVER_SHEET).pipe((0, rxjs_operators.takeUntil)(this.dispose$)).subscribe((event) => {
@@ -566,10 +596,7 @@ let DataSyncPrimaryController = class DataSyncPrimaryController extends _univerj
566
596
  this.disposeWithMe(this._commandService.onCommandExecuted((commandInfo, options) => {
567
597
  const { type, params, id } = commandInfo;
568
598
  const unitId = (params === null || params === void 0 ? void 0 : params.unitId) || "";
569
- if (type === _univerjs_core.CommandType.MUTATION && (!unitId || this._syncingUnits.has(unitId)) && !(options === null || options === void 0 ? void 0 : options.fromSync) && this._syncingMutations.has(id)) {
570
- const sync = () => this._remoteInstanceService.syncMutation({ mutationInfo: commandInfo }, options);
571
- this._syncMutationQueue = this._syncMutationQueue.then(sync, sync).catch(() => false);
572
- }
599
+ if (type === _univerjs_core.CommandType.MUTATION && (!unitId || this._syncingUnits.has(unitId)) && !(options === null || options === void 0 ? void 0 : options.fromSync) && this._syncingMutations.has(id)) this.syncMutation(commandInfo, options);
573
600
  }));
574
601
  }
575
602
  };
@@ -615,7 +642,7 @@ DataSyncReplicaController = __decorate([
615
642
  //#endregion
616
643
  //#region package.json
617
644
  var name = "@univerjs/rpc";
618
- var version = "1.0.0-insiders.20260809-70eefdd";
645
+ var version = "1.0.0-rc.0";
619
646
 
620
647
  //#endregion
621
648
  //#region src/services/rpc/implementations/web-worker-rpc.service.ts
package/lib/es/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { CommandType, Disposable, ICommandService, IConfigService, ILogService, IUniverInstanceService, Inject, Injector, Plugin, RxDisposable, UniverInstanceType, createIdentifier, merge, toDisposable } from "@univerjs/core";
1
+ import { CommandType, Disposable, ICommandService, IConfigService, ILogService, IUniverInstanceService, Inject, Injector, LifecycleService, LifecycleStages, Plugin, RxDisposable, UniverInstanceType, createIdentifier, merge, toDisposable } from "@univerjs/core";
2
2
  import { filter, take, takeUntil } from "rxjs/operators";
3
3
  import { BehaviorSubject, Observable, firstValueFrom, isObservable, of, shareReplay } from "rxjs";
4
4
 
@@ -74,13 +74,15 @@ const RemoteInstanceServiceName = "univer.remote-instance-service";
74
74
  */
75
75
  const IRemoteInstanceService = createIdentifier(RemoteInstanceServiceName);
76
76
  let WebWorkerRemoteInstanceService = class WebWorkerRemoteInstanceService {
77
- constructor(_univerInstanceService, _commandService, _logService) {
77
+ constructor(_univerInstanceService, _commandService, _logService, _lifecycleService) {
78
78
  this._univerInstanceService = _univerInstanceService;
79
79
  this._commandService = _commandService;
80
80
  this._logService = _logService;
81
+ this._lifecycleService = _lifecycleService;
81
82
  }
82
83
  whenReady() {
83
- return Promise.resolve(true);
84
+ if (this._lifecycleService.stage >= LifecycleStages.Ready) return Promise.resolve(true);
85
+ return this._lifecycleService.onStage(LifecycleStages.Ready).then(() => true);
84
86
  }
85
87
  async syncMutation(params, options) {
86
88
  return this._applyMutation(params.mutationInfo, options);
@@ -120,7 +122,8 @@ let WebWorkerRemoteInstanceService = class WebWorkerRemoteInstanceService {
120
122
  WebWorkerRemoteInstanceService = __decorate([
121
123
  __decorateParam(0, IUniverInstanceService),
122
124
  __decorateParam(1, ICommandService),
123
- __decorateParam(2, ILogService)
125
+ __decorateParam(2, ILogService),
126
+ __decorateParam(3, Inject(LifecycleService))
124
127
  ], WebWorkerRemoteInstanceService);
125
128
 
126
129
  //#endregion
@@ -233,7 +236,12 @@ var ChannelClient = class extends RxDisposable {
233
236
  this._protocol.onMessage.pipe(takeUntil(this.dispose$)).subscribe((message) => this._onMessage(message));
234
237
  }
235
238
  dispose() {
239
+ if (this._disposed) return;
240
+ const error = /* @__PURE__ */ new Error("[ChannelClient]: client is disposed!");
241
+ this._initialized.error(error);
242
+ for (const responseHandler of this._pendingRequests.values()) responseHandler.dispose(error);
236
243
  this._pendingRequests.clear();
244
+ super.dispose();
237
245
  }
238
246
  getChannel(channelName) {
239
247
  return {
@@ -265,19 +273,24 @@ var ChannelClient = class extends RxDisposable {
265
273
  };
266
274
  const pendingRequests = this._pendingRequests;
267
275
  return new Promise((resolve, reject) => {
268
- this._pendingRequests.set(sequence, { handle(response) {
269
- switch (response.type) {
270
- case 201:
271
- pendingRequests.delete(sequence);
272
- resolve(response.data);
273
- break;
274
- case 202:
275
- pendingRequests.delete(sequence);
276
- reject(response.data);
277
- break;
278
- default: throw new Error("[ChannelClient]: unknown response type!");
276
+ this._pendingRequests.set(sequence, {
277
+ handle(response) {
278
+ switch (response.type) {
279
+ case 201:
280
+ pendingRequests.delete(sequence);
281
+ resolve(response.data);
282
+ break;
283
+ case 202:
284
+ pendingRequests.delete(sequence);
285
+ reject(response.data);
286
+ break;
287
+ default: throw new Error("[ChannelClient]: unknown response type!");
288
+ }
289
+ },
290
+ dispose(error) {
291
+ reject(error);
279
292
  }
280
- } });
293
+ });
281
294
  this._sendRequest(request);
282
295
  });
283
296
  }
@@ -293,20 +306,25 @@ var ChannelClient = class extends RxDisposable {
293
306
  method,
294
307
  args
295
308
  };
296
- this._pendingRequests.set(sequence, { handle(response) {
297
- switch (response.type) {
298
- case 300:
299
- subscriber.next(response.data);
300
- break;
301
- case 301:
302
- subscriber.error(response.data);
303
- break;
304
- case 302:
305
- subscriber.complete();
306
- break;
307
- default: throw new Error("[ChannelClient]: unknown response type!");
309
+ this._pendingRequests.set(sequence, {
310
+ handle(response) {
311
+ switch (response.type) {
312
+ case 300:
313
+ subscriber.next(response.data);
314
+ break;
315
+ case 301:
316
+ subscriber.error(response.data);
317
+ break;
318
+ case 302:
319
+ subscriber.complete();
320
+ break;
321
+ default: throw new Error("[ChannelClient]: unknown response type!");
322
+ }
323
+ },
324
+ dispose(error) {
325
+ subscriber.error(error);
308
326
  }
309
- } });
327
+ });
310
328
  this._sendRequest(request);
311
329
  };
312
330
  if (this._initialized.getValue()) doSubscribe();
@@ -357,6 +375,7 @@ var ChannelServer = class extends RxDisposable {
357
375
  }
358
376
  dispose() {
359
377
  super.dispose();
378
+ for (const subscription of this._subscriptions.values()) subscription.unsubscribe();
360
379
  this._subscriptions.clear();
361
380
  this._channels.clear();
362
381
  }
@@ -511,6 +530,7 @@ let DataSyncPrimaryController = class DataSyncPrimaryController extends RxDispos
511
530
  _defineProperty(this, "_syncingUnits", /* @__PURE__ */ new Set());
512
531
  _defineProperty(this, "_syncingMutations", /* @__PURE__ */ new Set());
513
532
  _defineProperty(this, "_syncMutationQueue", Promise.resolve());
533
+ _defineProperty(this, "_remoteReady", Promise.resolve(true));
514
534
  this._initRPCChannels();
515
535
  this._init();
516
536
  }
@@ -543,10 +563,20 @@ let DataSyncPrimaryController = class DataSyncPrimaryController extends RxDispos
543
563
  if (!alreadySyncing) this._syncingUnits.delete(unitId);
544
564
  });
545
565
  }
566
+ async syncMutation(commandInfo, options) {
567
+ const sync = () => this._remoteReady.then(() => this._remoteInstanceService.syncMutation({ mutationInfo: commandInfo }, options));
568
+ const result = this._syncMutationQueue.then(sync, sync);
569
+ this._syncMutationQueue = result.catch(() => false);
570
+ return result;
571
+ }
572
+ async waitForPendingMutations() {
573
+ await this._syncMutationQueue.catch(() => false);
574
+ }
546
575
  _initRPCChannels() {
547
576
  this._rpcChannelService.registerChannel(RemoteSyncServiceName, fromModule(this._remoteSyncService));
548
577
  this._injector.add([IRemoteInstanceService, { useFactory: () => toModule(this._rpcChannelService.requestChannel(RemoteInstanceServiceName)) }]);
549
578
  this._remoteInstanceService = this._injector.get(IRemoteInstanceService);
579
+ this._remoteReady = this._remoteInstanceService.whenReady();
550
580
  }
551
581
  _init() {
552
582
  this._univerInstanceService.getTypeOfUnitAdded$(UniverInstanceType.UNIVER_SHEET).pipe(takeUntil(this.dispose$)).subscribe((event) => {
@@ -565,10 +595,7 @@ let DataSyncPrimaryController = class DataSyncPrimaryController extends RxDispos
565
595
  this.disposeWithMe(this._commandService.onCommandExecuted((commandInfo, options) => {
566
596
  const { type, params, id } = commandInfo;
567
597
  const unitId = (params === null || params === void 0 ? void 0 : params.unitId) || "";
568
- if (type === CommandType.MUTATION && (!unitId || this._syncingUnits.has(unitId)) && !(options === null || options === void 0 ? void 0 : options.fromSync) && this._syncingMutations.has(id)) {
569
- const sync = () => this._remoteInstanceService.syncMutation({ mutationInfo: commandInfo }, options);
570
- this._syncMutationQueue = this._syncMutationQueue.then(sync, sync).catch(() => false);
571
- }
598
+ if (type === CommandType.MUTATION && (!unitId || this._syncingUnits.has(unitId)) && !(options === null || options === void 0 ? void 0 : options.fromSync) && this._syncingMutations.has(id)) this.syncMutation(commandInfo, options);
572
599
  }));
573
600
  }
574
601
  };
@@ -614,7 +641,7 @@ DataSyncReplicaController = __decorate([
614
641
  //#endregion
615
642
  //#region package.json
616
643
  var name = "@univerjs/rpc";
617
- var version = "1.0.0-insiders.20260809-70eefdd";
644
+ var version = "1.0.0-rc.0";
618
645
 
619
646
  //#endregion
620
647
  //#region src/services/rpc/implementations/web-worker-rpc.service.ts
package/lib/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { CommandType, Disposable, ICommandService, IConfigService, ILogService, IUniverInstanceService, Inject, Injector, Plugin, RxDisposable, UniverInstanceType, createIdentifier, merge, toDisposable } from "@univerjs/core";
1
+ import { CommandType, Disposable, ICommandService, IConfigService, ILogService, IUniverInstanceService, Inject, Injector, LifecycleService, LifecycleStages, Plugin, RxDisposable, UniverInstanceType, createIdentifier, merge, toDisposable } from "@univerjs/core";
2
2
  import { filter, take, takeUntil } from "rxjs/operators";
3
3
  import { BehaviorSubject, Observable, firstValueFrom, isObservable, of, shareReplay } from "rxjs";
4
4
 
@@ -74,13 +74,15 @@ const RemoteInstanceServiceName = "univer.remote-instance-service";
74
74
  */
75
75
  const IRemoteInstanceService = createIdentifier(RemoteInstanceServiceName);
76
76
  let WebWorkerRemoteInstanceService = class WebWorkerRemoteInstanceService {
77
- constructor(_univerInstanceService, _commandService, _logService) {
77
+ constructor(_univerInstanceService, _commandService, _logService, _lifecycleService) {
78
78
  this._univerInstanceService = _univerInstanceService;
79
79
  this._commandService = _commandService;
80
80
  this._logService = _logService;
81
+ this._lifecycleService = _lifecycleService;
81
82
  }
82
83
  whenReady() {
83
- return Promise.resolve(true);
84
+ if (this._lifecycleService.stage >= LifecycleStages.Ready) return Promise.resolve(true);
85
+ return this._lifecycleService.onStage(LifecycleStages.Ready).then(() => true);
84
86
  }
85
87
  async syncMutation(params, options) {
86
88
  return this._applyMutation(params.mutationInfo, options);
@@ -120,7 +122,8 @@ let WebWorkerRemoteInstanceService = class WebWorkerRemoteInstanceService {
120
122
  WebWorkerRemoteInstanceService = __decorate([
121
123
  __decorateParam(0, IUniverInstanceService),
122
124
  __decorateParam(1, ICommandService),
123
- __decorateParam(2, ILogService)
125
+ __decorateParam(2, ILogService),
126
+ __decorateParam(3, Inject(LifecycleService))
124
127
  ], WebWorkerRemoteInstanceService);
125
128
 
126
129
  //#endregion
@@ -233,7 +236,12 @@ var ChannelClient = class extends RxDisposable {
233
236
  this._protocol.onMessage.pipe(takeUntil(this.dispose$)).subscribe((message) => this._onMessage(message));
234
237
  }
235
238
  dispose() {
239
+ if (this._disposed) return;
240
+ const error = /* @__PURE__ */ new Error("[ChannelClient]: client is disposed!");
241
+ this._initialized.error(error);
242
+ for (const responseHandler of this._pendingRequests.values()) responseHandler.dispose(error);
236
243
  this._pendingRequests.clear();
244
+ super.dispose();
237
245
  }
238
246
  getChannel(channelName) {
239
247
  return {
@@ -265,19 +273,24 @@ var ChannelClient = class extends RxDisposable {
265
273
  };
266
274
  const pendingRequests = this._pendingRequests;
267
275
  return new Promise((resolve, reject) => {
268
- this._pendingRequests.set(sequence, { handle(response) {
269
- switch (response.type) {
270
- case 201:
271
- pendingRequests.delete(sequence);
272
- resolve(response.data);
273
- break;
274
- case 202:
275
- pendingRequests.delete(sequence);
276
- reject(response.data);
277
- break;
278
- default: throw new Error("[ChannelClient]: unknown response type!");
276
+ this._pendingRequests.set(sequence, {
277
+ handle(response) {
278
+ switch (response.type) {
279
+ case 201:
280
+ pendingRequests.delete(sequence);
281
+ resolve(response.data);
282
+ break;
283
+ case 202:
284
+ pendingRequests.delete(sequence);
285
+ reject(response.data);
286
+ break;
287
+ default: throw new Error("[ChannelClient]: unknown response type!");
288
+ }
289
+ },
290
+ dispose(error) {
291
+ reject(error);
279
292
  }
280
- } });
293
+ });
281
294
  this._sendRequest(request);
282
295
  });
283
296
  }
@@ -293,20 +306,25 @@ var ChannelClient = class extends RxDisposable {
293
306
  method,
294
307
  args
295
308
  };
296
- this._pendingRequests.set(sequence, { handle(response) {
297
- switch (response.type) {
298
- case 300:
299
- subscriber.next(response.data);
300
- break;
301
- case 301:
302
- subscriber.error(response.data);
303
- break;
304
- case 302:
305
- subscriber.complete();
306
- break;
307
- default: throw new Error("[ChannelClient]: unknown response type!");
309
+ this._pendingRequests.set(sequence, {
310
+ handle(response) {
311
+ switch (response.type) {
312
+ case 300:
313
+ subscriber.next(response.data);
314
+ break;
315
+ case 301:
316
+ subscriber.error(response.data);
317
+ break;
318
+ case 302:
319
+ subscriber.complete();
320
+ break;
321
+ default: throw new Error("[ChannelClient]: unknown response type!");
322
+ }
323
+ },
324
+ dispose(error) {
325
+ subscriber.error(error);
308
326
  }
309
- } });
327
+ });
310
328
  this._sendRequest(request);
311
329
  };
312
330
  if (this._initialized.getValue()) doSubscribe();
@@ -357,6 +375,7 @@ var ChannelServer = class extends RxDisposable {
357
375
  }
358
376
  dispose() {
359
377
  super.dispose();
378
+ for (const subscription of this._subscriptions.values()) subscription.unsubscribe();
360
379
  this._subscriptions.clear();
361
380
  this._channels.clear();
362
381
  }
@@ -511,6 +530,7 @@ let DataSyncPrimaryController = class DataSyncPrimaryController extends RxDispos
511
530
  _defineProperty(this, "_syncingUnits", /* @__PURE__ */ new Set());
512
531
  _defineProperty(this, "_syncingMutations", /* @__PURE__ */ new Set());
513
532
  _defineProperty(this, "_syncMutationQueue", Promise.resolve());
533
+ _defineProperty(this, "_remoteReady", Promise.resolve(true));
514
534
  this._initRPCChannels();
515
535
  this._init();
516
536
  }
@@ -543,10 +563,20 @@ let DataSyncPrimaryController = class DataSyncPrimaryController extends RxDispos
543
563
  if (!alreadySyncing) this._syncingUnits.delete(unitId);
544
564
  });
545
565
  }
566
+ async syncMutation(commandInfo, options) {
567
+ const sync = () => this._remoteReady.then(() => this._remoteInstanceService.syncMutation({ mutationInfo: commandInfo }, options));
568
+ const result = this._syncMutationQueue.then(sync, sync);
569
+ this._syncMutationQueue = result.catch(() => false);
570
+ return result;
571
+ }
572
+ async waitForPendingMutations() {
573
+ await this._syncMutationQueue.catch(() => false);
574
+ }
546
575
  _initRPCChannels() {
547
576
  this._rpcChannelService.registerChannel(RemoteSyncServiceName, fromModule(this._remoteSyncService));
548
577
  this._injector.add([IRemoteInstanceService, { useFactory: () => toModule(this._rpcChannelService.requestChannel(RemoteInstanceServiceName)) }]);
549
578
  this._remoteInstanceService = this._injector.get(IRemoteInstanceService);
579
+ this._remoteReady = this._remoteInstanceService.whenReady();
550
580
  }
551
581
  _init() {
552
582
  this._univerInstanceService.getTypeOfUnitAdded$(UniverInstanceType.UNIVER_SHEET).pipe(takeUntil(this.dispose$)).subscribe((event) => {
@@ -565,10 +595,7 @@ let DataSyncPrimaryController = class DataSyncPrimaryController extends RxDispos
565
595
  this.disposeWithMe(this._commandService.onCommandExecuted((commandInfo, options) => {
566
596
  const { type, params, id } = commandInfo;
567
597
  const unitId = (params === null || params === void 0 ? void 0 : params.unitId) || "";
568
- if (type === CommandType.MUTATION && (!unitId || this._syncingUnits.has(unitId)) && !(options === null || options === void 0 ? void 0 : options.fromSync) && this._syncingMutations.has(id)) {
569
- const sync = () => this._remoteInstanceService.syncMutation({ mutationInfo: commandInfo }, options);
570
- this._syncMutationQueue = this._syncMutationQueue.then(sync, sync).catch(() => false);
571
- }
598
+ if (type === CommandType.MUTATION && (!unitId || this._syncingUnits.has(unitId)) && !(options === null || options === void 0 ? void 0 : options.fromSync) && this._syncingMutations.has(id)) this.syncMutation(commandInfo, options);
572
599
  }));
573
600
  }
574
601
  };
@@ -614,7 +641,7 @@ DataSyncReplicaController = __decorate([
614
641
  //#endregion
615
642
  //#region package.json
616
643
  var name = "@univerjs/rpc";
617
- var version = "1.0.0-insiders.20260809-70eefdd";
644
+ var version = "1.0.0-rc.0";
618
645
 
619
646
  //#endregion
620
647
  //#region src/services/rpc/implementations/web-worker-rpc.service.ts
@@ -13,7 +13,8 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import type { IDisposable, IMutation } from '@univerjs/core';
16
+ import type { IDisposable, IMutation, IMutationInfo } from '@univerjs/core';
17
+ import type { IRemoteSyncMutationOptions } from '../../services/remote-instance/remote-instance.service';
17
18
  import { ICommandService, Injector, IUniverInstanceService, RxDisposable } from '@univerjs/core';
18
19
  import { IRemoteSyncService } from '../../services/remote-instance/remote-instance.service';
19
20
  import { IRPCChannelService } from '../../services/rpc/channel.service';
@@ -33,6 +34,7 @@ export declare class DataSyncPrimaryController extends RxDisposable {
33
34
  private readonly _syncingUnits;
34
35
  private readonly _syncingMutations;
35
36
  private _syncMutationQueue;
37
+ private _remoteReady;
36
38
  constructor(_injector: Injector, _commandService: ICommandService, _univerInstanceService: IUniverInstanceService, _rpcChannelService: IRPCChannelService, _remoteSyncService: IRemoteSyncService);
37
39
  registerSyncingMutations(mutation: IMutation<object>): void;
38
40
  /**
@@ -42,6 +44,8 @@ export declare class DataSyncPrimaryController extends RxDisposable {
42
44
  syncUnit(unitId: string): IDisposable;
43
45
  /** Sync registered mutations for a unit without creating a replica unit. */
44
46
  syncUnitMutations(unitId: string): IDisposable;
47
+ syncMutation(commandInfo: IMutationInfo, options?: IRemoteSyncMutationOptions): Promise<boolean>;
48
+ waitForPendingMutations(): Promise<void>;
45
49
  private _initRPCChannels;
46
50
  private _init;
47
51
  }
@@ -14,7 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import type { IBaseSnapshot, IExecutionOptions, IMutationInfo, IWorkbookData } from '@univerjs/core';
17
- import { ICommandService, ILogService, IUniverInstanceService, UniverInstanceType } from '@univerjs/core';
17
+ import { ICommandService, ILogService, IUniverInstanceService, LifecycleService, UniverInstanceType } from '@univerjs/core';
18
18
  export interface IRemoteSyncMutationOptions extends IExecutionOptions {
19
19
  /** If this mutation is executed after it was sent from the peer univer instance (e.g. in a web worker). */
20
20
  fromSync?: boolean;
@@ -65,7 +65,8 @@ export declare class WebWorkerRemoteInstanceService implements IRemoteInstanceSe
65
65
  protected readonly _univerInstanceService: IUniverInstanceService;
66
66
  protected readonly _commandService: ICommandService;
67
67
  protected readonly _logService: ILogService;
68
- constructor(_univerInstanceService: IUniverInstanceService, _commandService: ICommandService, _logService: ILogService);
68
+ protected readonly _lifecycleService: LifecycleService;
69
+ constructor(_univerInstanceService: IUniverInstanceService, _commandService: ICommandService, _logService: ILogService, _lifecycleService: LifecycleService);
69
70
  whenReady(): Promise<true>;
70
71
  syncMutation(params: {
71
72
  mutationInfo: IMutationInfo;
package/lib/umd/index.js CHANGED
@@ -1 +1 @@
1
- (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@univerjs/core"),require("rxjs/operators"),require("rxjs")):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`,`rxjs/operators`,`rxjs`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverRpc={},e.UniverCore,e.rxjs.operators,e.rxjs))})(this,function(e,t,n,r){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});let i=`rpc.main-thread.config`,a={},o=`rpc.worker-thread.config`,s={};function c(e,t){return function(n,r){t(n,r,e)}}function l(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 u=`rpc.remote-sync.service`,d=(0,t.createIdentifier)(u),f=class{constructor(e){this._commandService=e}async syncMutation(e,t){let{fromCollab:n,...r}=t||{};return this._commandService.syncExecuteCommand(e.mutationInfo.id,e.mutationInfo.params,{...r,onlyLocal:!0,fromSync:!0})}};f=l([c(0,t.ICommandService)],f);let p=`univer.remote-instance-service`,m=(0,t.createIdentifier)(p),h=class{constructor(e,t,n){this._univerInstanceService=e,this._commandService=t,this._logService=n}whenReady(){return Promise.resolve(!0)}async syncMutation(e,t){return this._applyMutation(e.mutationInfo,t)}async createInstance(e){this._logService.debug(`[WebWorkerRemoteInstanceService]: Creating instance with id ${e.unitID}`);let{type:n,snapshot:r}=e;try{switch(n){case t.UniverInstanceType.UNIVER_SHEET:return this._univerInstanceService.createUnit(t.UniverInstanceType.UNIVER_SHEET,r),!0;case t.UniverInstanceType.UNIVER_BASE:return this._univerInstanceService.createUnit(t.UniverInstanceType.UNIVER_BASE,r),!0;default:throw Error(`[WebWorkerRemoteInstanceService]: cannot create replica for document type: ${n}.`)}}catch(e){throw e instanceof Error?e:TypeError(`${e}`)}}async disposeInstance(e){return this._logService.debug(`[WebWorkerRemoteInstanceService]: Disposing instance with id ${e.unitID}`),this._univerInstanceService.disposeUnit(e.unitID)}_applyMutation(e,t){let{id:n,params:r}=e,{fromCollab:i,...a}=t||{};return this._commandService.syncExecuteCommand(n,r,{...a,onlyLocal:!0,fromSync:!0})}};h=l([c(0,t.IUniverInstanceService),c(1,t.ICommandService),c(2,t.ILogService)],h);function g(e){"@babel/helpers - typeof";return g=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},g(e)}function _(e,t){if(g(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(g(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function v(e){var t=_(e,`string`);return g(t)==`symbol`?t:t+``}function y(e,t,n){return(t=v(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function b(e){let t=e;return new class{call(e,n){let r=t[e];if(typeof r==`function`){let e=n?r.apply(t,n):r.call(t);return e instanceof Promise||(e=Promise.resolve(e)),e}throw Error(`[RPC]: method not found for ${e}!`)}subscribe(e,n){let i=t[e];if(typeof i==`function`){let e=n?i.apply(t,n):i.call(t);return(0,r.isObservable)(e)?e:(0,r.of)(e)}throw Error(`[RPC]: observable method not found for ${e}!`)}}}function x(e){return new Proxy({},{get(t,n){if(n!==`dispose`)return function(...t){return S(n)?e.subscribe(n,t):e.call(n,t)}}})}function S(e){return e.endsWith(`$`)}var C=class extends t.RxDisposable{constructor(e){super(),this._protocol=e,y(this,`_initialized`,new r.BehaviorSubject(!1)),y(this,`_lastRequestCounter`,0),y(this,`_pendingRequests`,new Map),this._protocol.send({type:50}),this._protocol.onMessage.pipe((0,n.takeUntil)(this.dispose$)).subscribe(e=>this._onMessage(e))}dispose(){this._pendingRequests.clear()}getChannel(e){return{call:(t,n)=>this._disposed?Promise.reject(Error(`[ChannelClient]: client is disposed!`)):this._remoteCall(e,t,n),subscribe:(t,n)=>{if(this._disposed)throw Error(`[ChannelClient]: client is disposed!`);return this._remoteSubscribe(e,t,n)}}}_whenReady(){return(0,r.firstValueFrom)(this._initialized.pipe((0,n.filter)(e=>e),(0,n.take)(1)))}_remoteCall(e,t,n){return this._initialized.getValue()?this._doRemoteCall(e,t,n):this._whenReady().then(()=>this._doRemoteCall(e,t,n))}_doRemoteCall(e,t,n){let r=++this._lastRequestCounter,i={seq:r,type:100,channelName:e,method:t,args:n},a=this._pendingRequests;return new Promise((e,t)=>{this._pendingRequests.set(r,{handle(n){switch(n.type){case 201:a.delete(r),e(n.data);break;case 202:a.delete(r),t(n.data);break;default:throw Error(`[ChannelClient]: unknown response type!`)}}}),this._sendRequest(i)})}_remoteSubscribe(e,t,n){return new r.Observable(r=>{let i=-1,a=()=>{i=++this._lastRequestCounter;let a={seq:i,type:101,channelName:e,method:t,args:n};this._pendingRequests.set(i,{handle(e){switch(e.type){case 300:r.next(e.data);break;case 301:r.error(e.data);break;case 302:r.complete();break;default:throw Error(`[ChannelClient]: unknown response type!`)}}}),this._sendRequest(a)};return this._initialized.getValue()?a():this._whenReady().then(a),()=>{if(i===-1)return;let n={type:102,seq:i,channelName:e,method:t};this._sendRequest(n)}})}_sendRequest(e){this._protocol.send(e)}_onMessage(e){let{type:t,seq:n}=e;switch(t){case 0:this._initialized.next(!0);break;case 201:case 202:case 300:case 302:case 301:{var r;let{_pendingRequests:i}=this;(r=i.get(n))==null||r.handle(e),t!==300&&i.delete(n);break}}}},w=class extends t.RxDisposable{constructor(e){super(),this._protocol=e,y(this,`_channels`,new Map),y(this,`_subscriptions`,new Map),this._protocol.onMessage.pipe((0,n.takeUntil)(this.dispose$)).subscribe(e=>this._onRequest(e)),this._sendInitialize()}dispose(){super.dispose(),this._subscriptions.clear(),this._channels.clear()}registerChannel(e,t){this._channels.set(e,t)}_onRequest(e){switch(e.type){case 50:this._sendInitialize();break;case 100:this._onMethodCall(e);break;case 101:this._onSubscribe(e);break;case 102:this._onUnsubscribe(e);break;default:break}}_sendInitialize(){this._sendResponse({seq:-1,type:0})}_onMethodCall(e){let{channelName:t,method:n,args:r}=e,i=this._channels.get(t),a;try{if(!i)throw Error(`[ChannelServer]: Channel ${t} not found!`);a=r?i.call(n,r):i.call(n)}catch(e){a=Promise.reject(e instanceof Error?e:Error(String(e)))}a.then(t=>{this._sendResponse({seq:e.seq,type:201,data:t})}).catch(t=>{t instanceof Error?this._sendResponse({seq:e.seq,type:202,data:t.message}):this._sendResponse({seq:e.seq,type:202,data:String(t)})})}_onSubscribe(e){let{channelName:t,seq:n}=e,r=this._channels.get(t);try{if(!r)throw Error(`[ChannelServer]: Channel ${t} not found!`);let i=r.subscribe(e.method,e.args).subscribe({next:e=>{this._sendResponse({seq:n,type:300,data:e})},error:e=>{this._sendResponse({seq:n,type:301,data:e.message}),this._sendResponse({seq:n,type:302})},complete:()=>{this._sendResponse({seq:n,type:302})}});this._subscriptions.set(e.seq,i)}catch(t){t instanceof Error?this._sendResponse({seq:e.seq,type:301,data:t.message}):this._sendResponse({seq:e.seq,type:301,data:String(t)})}}_onUnsubscribe(e){let t=this._subscriptions.get(e.seq);t&&(t.unsubscribe(),this._subscriptions.delete(e.seq))}_sendResponse(e){this._protocol.send(e)}};let T=(0,t.createIdentifier)(`IRPCChannelService`);var E=class{constructor(e){y(this,`_client`,void 0),y(this,`_server`,void 0),this._client=new C(e),this._server=new w(e)}dispose(){this._client.dispose(),this._server.dispose()}requestChannel(e){return this._client.getChannel(e)}registerChannel(e,t){this._server.registerChannel(e,t)}};let D=class extends t.RxDisposable{constructor(e,t,n,r,i){super(),this._injector=e,this._commandService=t,this._univerInstanceService=n,this._rpcChannelService=r,this._remoteSyncService=i,y(this,`_remoteInstanceService`,void 0),y(this,`_syncingUnits`,new Set),y(this,`_syncingMutations`,new Set),y(this,`_syncMutationQueue`,Promise.resolve()),this._initRPCChannels(),this._init()}registerSyncingMutations(e){this._syncingMutations.add(e.id)}syncUnit(e){let n=this._syncingUnits.has(e);this._syncingUnits.add(e);let r=this._univerInstanceService.getUnit(e,t.UniverInstanceType.UNIVER_SHEET)??this._univerInstanceService.getUnit(e,t.UniverInstanceType.UNIVER_BASE);return!n&&r&&this._remoteInstanceService.createInstance({unitID:r.getUnitId(),type:r.type,snapshot:r.getSnapshot()}),(0,t.toDisposable)(()=>{n||this._syncingUnits.delete(e),!n&&r&&this._remoteInstanceService.disposeInstance({unitID:r.getUnitId()})})}syncUnitMutations(e){let n=this._syncingUnits.has(e);return this._syncingUnits.add(e),(0,t.toDisposable)(()=>{n||this._syncingUnits.delete(e)})}_initRPCChannels(){this._rpcChannelService.registerChannel(u,b(this._remoteSyncService)),this._injector.add([m,{useFactory:()=>x(this._rpcChannelService.requestChannel(p))}]),this._remoteInstanceService=this._injector.get(m)}_init(){this._univerInstanceService.getTypeOfUnitAdded$(t.UniverInstanceType.UNIVER_SHEET).pipe((0,n.takeUntil)(this.dispose$)).subscribe(e=>{let{unit:n}=e;this._syncingUnits.add(n.getUnitId()),this._remoteInstanceService.createInstance({unitID:n.getUnitId(),type:t.UniverInstanceType.UNIVER_SHEET,snapshot:n.getSnapshot()})}),this._univerInstanceService.getTypeOfUnitDisposed$(t.UniverInstanceType.UNIVER_SHEET).pipe((0,n.takeUntil)(this.dispose$)).subscribe(e=>{this._syncingUnits.delete(e.getUnitId()),this._remoteInstanceService.disposeInstance({unitID:e.getUnitId()})}),this.disposeWithMe(this._commandService.onCommandExecuted((e,n)=>{let{type:r,params:i,id:a}=e,o=(i==null?void 0:i.unitId)||``;if(r===t.CommandType.MUTATION&&(!o||this._syncingUnits.has(o))&&!(n!=null&&n.fromSync)&&this._syncingMutations.has(a)){let t=()=>this._remoteInstanceService.syncMutation({mutationInfo:e},n);this._syncMutationQueue=this._syncMutationQueue.then(t,t).catch(()=>!1)}}))}};D=l([c(0,(0,t.Inject)(t.Injector)),c(1,t.ICommandService),c(2,t.IUniverInstanceService),c(3,T),c(4,d)],D);let O=class extends t.Disposable{constructor(e,t,n,r){super(),this._injector=e,this._remoteInstanceService=t,this._commandService=n,this._rpcChannelService=r,y(this,`_remoteSyncService`,void 0),this._initRPCChannels(),this._init()}_initRPCChannels(){this._rpcChannelService.registerChannel(p,b(this._remoteInstanceService)),this._injector.add([d,{useFactory:()=>x(this._rpcChannelService.requestChannel(u))}]),this._remoteSyncService=this._injector.get(d)}_init(){this.disposeWithMe(this._commandService.onCommandExecuted((e,n)=>{e.type===t.CommandType.MUTATION&&!(n!=null&&n.fromSync)&&this._remoteSyncService.syncMutation({mutationInfo:e},n)}))}};O=l([c(0,(0,t.Inject)(t.Injector)),c(1,m),c(2,t.ICommandService),c(3,T)],O);var k=`@univerjs/rpc`,A=`1.0.0-insiders.20260809-70eefdd`;function j(){return{send(e){postMessage(e)},onMessage:new r.Observable(e=>{let t=t=>{e.next(t.data)};return addEventListener(`message`,t),()=>removeEventListener(`message`,t)}).pipe((0,r.shareReplay)({bufferSize:1,refCount:!0}))}}function M(e){return{send(t){e.postMessage(t)},onMessage:new r.Observable(t=>{let n=e=>{t.next(e.data)};return e.addEventListener(`message`,n),()=>e.removeEventListener(`message`,n)}).pipe((0,r.shareReplay)({bufferSize:1,refCount:!0}))}}let N=class extends t.Plugin{constructor(e=a,n,r){super(),this._config=e,this._injector=n,this._configService=r,y(this,`_internalWorker`,null);let{...o}=(0,t.merge)({},a,this._config);this._configService.setConfig(i,o)}dispose(){super.dispose(),this._internalWorker&&=(this._internalWorker.terminate(),null)}onStarting(){let{workerURL:e}=this._config;if(!e)throw Error(`[UniverRPCMainThreadPlugin]: The workerURL is required for the RPC main thread plugin.`);let t=e instanceof Worker?e:new Worker(e);this._internalWorker=e instanceof Worker?null:t;let n=M(t);[[T,{useFactory:()=>new E(n)}],[D],[d,{useClass:f}]].forEach(e=>this._injector.add(e)),this._injector.get(D)}};y(N,`pluginName`,`UNIVER_RPC_MAIN_THREAD_PLUGIN`),y(N,`packageName`,k),y(N,`version`,A),N=l([c(1,(0,t.Inject)(t.Injector)),c(2,t.IConfigService)],N);let P=class extends t.Plugin{constructor(e=s,n,r){super(),this._config=e,this._injector=n,this._configService=r;let{...i}=(0,t.merge)({},s,this._config);this._configService.setConfig(o,i)}onStarting(){[[O],[T,{useFactory:()=>new E(j())}],[m,{useClass:h}]].forEach(e=>this._injector.add(e)),this._injector.get(O)}};y(P,`pluginName`,`UNIVER_RPC_WORKER_THREAD_PLUGIN`),y(P,`packageName`,k),y(P,`version`,A),P=l([c(1,(0,t.Inject)(t.Injector)),c(2,t.IConfigService)],P),e.ChannelClient=C,e.ChannelServer=w,e.ChannelService=E,Object.defineProperty(e,"DataSyncPrimaryController",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"DataSyncReplicaController",{enumerable:!0,get:function(){return O}}),e.IRPCChannelService=T,e.IRemoteInstanceService=m,e.IRemoteSyncService=d,e.PLUGIN_CONFIG_KEY_MAIN_THREAD=i,e.PLUGIN_CONFIG_KEY_WORKER_THREAD=o,e.RemoteInstanceServiceName=p,Object.defineProperty(e,"RemoteSyncPrimaryService",{enumerable:!0,get:function(){return f}}),e.RemoteSyncServiceName=u,Object.defineProperty(e,"UniverRPCMainThreadPlugin",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"UniverRPCWorkerThreadPlugin",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"WebWorkerRemoteInstanceService",{enumerable:!0,get:function(){return h}}),e.fromModule=b,e.toModule=x});
1
+ (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@univerjs/core"),require("rxjs/operators"),require("rxjs")):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`,`rxjs/operators`,`rxjs`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverRpc={},e.UniverCore,e.rxjs.operators,e.rxjs))})(this,function(e,t,n,r){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});let i=`rpc.main-thread.config`,a={},o=`rpc.worker-thread.config`,s={};function c(e,t){return function(n,r){t(n,r,e)}}function l(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 u=`rpc.remote-sync.service`,d=(0,t.createIdentifier)(u),f=class{constructor(e){this._commandService=e}async syncMutation(e,t){let{fromCollab:n,...r}=t||{};return this._commandService.syncExecuteCommand(e.mutationInfo.id,e.mutationInfo.params,{...r,onlyLocal:!0,fromSync:!0})}};f=l([c(0,t.ICommandService)],f);let p=`univer.remote-instance-service`,m=(0,t.createIdentifier)(p),h=class{constructor(e,t,n,r){this._univerInstanceService=e,this._commandService=t,this._logService=n,this._lifecycleService=r}whenReady(){return this._lifecycleService.stage>=t.LifecycleStages.Ready?Promise.resolve(!0):this._lifecycleService.onStage(t.LifecycleStages.Ready).then(()=>!0)}async syncMutation(e,t){return this._applyMutation(e.mutationInfo,t)}async createInstance(e){this._logService.debug(`[WebWorkerRemoteInstanceService]: Creating instance with id ${e.unitID}`);let{type:n,snapshot:r}=e;try{switch(n){case t.UniverInstanceType.UNIVER_SHEET:return this._univerInstanceService.createUnit(t.UniverInstanceType.UNIVER_SHEET,r),!0;case t.UniverInstanceType.UNIVER_BASE:return this._univerInstanceService.createUnit(t.UniverInstanceType.UNIVER_BASE,r),!0;default:throw Error(`[WebWorkerRemoteInstanceService]: cannot create replica for document type: ${n}.`)}}catch(e){throw e instanceof Error?e:TypeError(`${e}`)}}async disposeInstance(e){return this._logService.debug(`[WebWorkerRemoteInstanceService]: Disposing instance with id ${e.unitID}`),this._univerInstanceService.disposeUnit(e.unitID)}_applyMutation(e,t){let{id:n,params:r}=e,{fromCollab:i,...a}=t||{};return this._commandService.syncExecuteCommand(n,r,{...a,onlyLocal:!0,fromSync:!0})}};h=l([c(0,t.IUniverInstanceService),c(1,t.ICommandService),c(2,t.ILogService),c(3,(0,t.Inject)(t.LifecycleService))],h);function g(e){"@babel/helpers - typeof";return g=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},g(e)}function _(e,t){if(g(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(g(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function v(e){var t=_(e,`string`);return g(t)==`symbol`?t:t+``}function y(e,t,n){return(t=v(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function b(e){let t=e;return new class{call(e,n){let r=t[e];if(typeof r==`function`){let e=n?r.apply(t,n):r.call(t);return e instanceof Promise||(e=Promise.resolve(e)),e}throw Error(`[RPC]: method not found for ${e}!`)}subscribe(e,n){let i=t[e];if(typeof i==`function`){let e=n?i.apply(t,n):i.call(t);return(0,r.isObservable)(e)?e:(0,r.of)(e)}throw Error(`[RPC]: observable method not found for ${e}!`)}}}function x(e){return new Proxy({},{get(t,n){if(n!==`dispose`)return function(...t){return S(n)?e.subscribe(n,t):e.call(n,t)}}})}function S(e){return e.endsWith(`$`)}var C=class extends t.RxDisposable{constructor(e){super(),this._protocol=e,y(this,`_initialized`,new r.BehaviorSubject(!1)),y(this,`_lastRequestCounter`,0),y(this,`_pendingRequests`,new Map),this._protocol.send({type:50}),this._protocol.onMessage.pipe((0,n.takeUntil)(this.dispose$)).subscribe(e=>this._onMessage(e))}dispose(){if(this._disposed)return;let e=Error(`[ChannelClient]: client is disposed!`);this._initialized.error(e);for(let t of this._pendingRequests.values())t.dispose(e);this._pendingRequests.clear(),super.dispose()}getChannel(e){return{call:(t,n)=>this._disposed?Promise.reject(Error(`[ChannelClient]: client is disposed!`)):this._remoteCall(e,t,n),subscribe:(t,n)=>{if(this._disposed)throw Error(`[ChannelClient]: client is disposed!`);return this._remoteSubscribe(e,t,n)}}}_whenReady(){return(0,r.firstValueFrom)(this._initialized.pipe((0,n.filter)(e=>e),(0,n.take)(1)))}_remoteCall(e,t,n){return this._initialized.getValue()?this._doRemoteCall(e,t,n):this._whenReady().then(()=>this._doRemoteCall(e,t,n))}_doRemoteCall(e,t,n){let r=++this._lastRequestCounter,i={seq:r,type:100,channelName:e,method:t,args:n},a=this._pendingRequests;return new Promise((e,t)=>{this._pendingRequests.set(r,{handle(n){switch(n.type){case 201:a.delete(r),e(n.data);break;case 202:a.delete(r),t(n.data);break;default:throw Error(`[ChannelClient]: unknown response type!`)}},dispose(e){t(e)}}),this._sendRequest(i)})}_remoteSubscribe(e,t,n){return new r.Observable(r=>{let i=-1,a=()=>{i=++this._lastRequestCounter;let a={seq:i,type:101,channelName:e,method:t,args:n};this._pendingRequests.set(i,{handle(e){switch(e.type){case 300:r.next(e.data);break;case 301:r.error(e.data);break;case 302:r.complete();break;default:throw Error(`[ChannelClient]: unknown response type!`)}},dispose(e){r.error(e)}}),this._sendRequest(a)};return this._initialized.getValue()?a():this._whenReady().then(a),()=>{if(i===-1)return;let n={type:102,seq:i,channelName:e,method:t};this._sendRequest(n)}})}_sendRequest(e){this._protocol.send(e)}_onMessage(e){let{type:t,seq:n}=e;switch(t){case 0:this._initialized.next(!0);break;case 201:case 202:case 300:case 302:case 301:{var r;let{_pendingRequests:i}=this;(r=i.get(n))==null||r.handle(e),t!==300&&i.delete(n);break}}}},w=class extends t.RxDisposable{constructor(e){super(),this._protocol=e,y(this,`_channels`,new Map),y(this,`_subscriptions`,new Map),this._protocol.onMessage.pipe((0,n.takeUntil)(this.dispose$)).subscribe(e=>this._onRequest(e)),this._sendInitialize()}dispose(){super.dispose();for(let e of this._subscriptions.values())e.unsubscribe();this._subscriptions.clear(),this._channels.clear()}registerChannel(e,t){this._channels.set(e,t)}_onRequest(e){switch(e.type){case 50:this._sendInitialize();break;case 100:this._onMethodCall(e);break;case 101:this._onSubscribe(e);break;case 102:this._onUnsubscribe(e);break;default:break}}_sendInitialize(){this._sendResponse({seq:-1,type:0})}_onMethodCall(e){let{channelName:t,method:n,args:r}=e,i=this._channels.get(t),a;try{if(!i)throw Error(`[ChannelServer]: Channel ${t} not found!`);a=r?i.call(n,r):i.call(n)}catch(e){a=Promise.reject(e instanceof Error?e:Error(String(e)))}a.then(t=>{this._sendResponse({seq:e.seq,type:201,data:t})}).catch(t=>{t instanceof Error?this._sendResponse({seq:e.seq,type:202,data:t.message}):this._sendResponse({seq:e.seq,type:202,data:String(t)})})}_onSubscribe(e){let{channelName:t,seq:n}=e,r=this._channels.get(t);try{if(!r)throw Error(`[ChannelServer]: Channel ${t} not found!`);let i=r.subscribe(e.method,e.args).subscribe({next:e=>{this._sendResponse({seq:n,type:300,data:e})},error:e=>{this._sendResponse({seq:n,type:301,data:e.message}),this._sendResponse({seq:n,type:302})},complete:()=>{this._sendResponse({seq:n,type:302})}});this._subscriptions.set(e.seq,i)}catch(t){t instanceof Error?this._sendResponse({seq:e.seq,type:301,data:t.message}):this._sendResponse({seq:e.seq,type:301,data:String(t)})}}_onUnsubscribe(e){let t=this._subscriptions.get(e.seq);t&&(t.unsubscribe(),this._subscriptions.delete(e.seq))}_sendResponse(e){this._protocol.send(e)}};let T=(0,t.createIdentifier)(`IRPCChannelService`);var E=class{constructor(e){y(this,`_client`,void 0),y(this,`_server`,void 0),this._client=new C(e),this._server=new w(e)}dispose(){this._client.dispose(),this._server.dispose()}requestChannel(e){return this._client.getChannel(e)}registerChannel(e,t){this._server.registerChannel(e,t)}};let D=class extends t.RxDisposable{constructor(e,t,n,r,i){super(),this._injector=e,this._commandService=t,this._univerInstanceService=n,this._rpcChannelService=r,this._remoteSyncService=i,y(this,`_remoteInstanceService`,void 0),y(this,`_syncingUnits`,new Set),y(this,`_syncingMutations`,new Set),y(this,`_syncMutationQueue`,Promise.resolve()),y(this,`_remoteReady`,Promise.resolve(!0)),this._initRPCChannels(),this._init()}registerSyncingMutations(e){this._syncingMutations.add(e.id)}syncUnit(e){let n=this._syncingUnits.has(e);this._syncingUnits.add(e);let r=this._univerInstanceService.getUnit(e,t.UniverInstanceType.UNIVER_SHEET)??this._univerInstanceService.getUnit(e,t.UniverInstanceType.UNIVER_BASE);return!n&&r&&this._remoteInstanceService.createInstance({unitID:r.getUnitId(),type:r.type,snapshot:r.getSnapshot()}),(0,t.toDisposable)(()=>{n||this._syncingUnits.delete(e),!n&&r&&this._remoteInstanceService.disposeInstance({unitID:r.getUnitId()})})}syncUnitMutations(e){let n=this._syncingUnits.has(e);return this._syncingUnits.add(e),(0,t.toDisposable)(()=>{n||this._syncingUnits.delete(e)})}async syncMutation(e,t){let n=()=>this._remoteReady.then(()=>this._remoteInstanceService.syncMutation({mutationInfo:e},t)),r=this._syncMutationQueue.then(n,n);return this._syncMutationQueue=r.catch(()=>!1),r}async waitForPendingMutations(){await this._syncMutationQueue.catch(()=>!1)}_initRPCChannels(){this._rpcChannelService.registerChannel(u,b(this._remoteSyncService)),this._injector.add([m,{useFactory:()=>x(this._rpcChannelService.requestChannel(p))}]),this._remoteInstanceService=this._injector.get(m),this._remoteReady=this._remoteInstanceService.whenReady()}_init(){this._univerInstanceService.getTypeOfUnitAdded$(t.UniverInstanceType.UNIVER_SHEET).pipe((0,n.takeUntil)(this.dispose$)).subscribe(e=>{let{unit:n}=e;this._syncingUnits.add(n.getUnitId()),this._remoteInstanceService.createInstance({unitID:n.getUnitId(),type:t.UniverInstanceType.UNIVER_SHEET,snapshot:n.getSnapshot()})}),this._univerInstanceService.getTypeOfUnitDisposed$(t.UniverInstanceType.UNIVER_SHEET).pipe((0,n.takeUntil)(this.dispose$)).subscribe(e=>{this._syncingUnits.delete(e.getUnitId()),this._remoteInstanceService.disposeInstance({unitID:e.getUnitId()})}),this.disposeWithMe(this._commandService.onCommandExecuted((e,n)=>{let{type:r,params:i,id:a}=e,o=(i==null?void 0:i.unitId)||``;r===t.CommandType.MUTATION&&(!o||this._syncingUnits.has(o))&&!(n!=null&&n.fromSync)&&this._syncingMutations.has(a)&&this.syncMutation(e,n)}))}};D=l([c(0,(0,t.Inject)(t.Injector)),c(1,t.ICommandService),c(2,t.IUniverInstanceService),c(3,T),c(4,d)],D);let O=class extends t.Disposable{constructor(e,t,n,r){super(),this._injector=e,this._remoteInstanceService=t,this._commandService=n,this._rpcChannelService=r,y(this,`_remoteSyncService`,void 0),this._initRPCChannels(),this._init()}_initRPCChannels(){this._rpcChannelService.registerChannel(p,b(this._remoteInstanceService)),this._injector.add([d,{useFactory:()=>x(this._rpcChannelService.requestChannel(u))}]),this._remoteSyncService=this._injector.get(d)}_init(){this.disposeWithMe(this._commandService.onCommandExecuted((e,n)=>{e.type===t.CommandType.MUTATION&&!(n!=null&&n.fromSync)&&this._remoteSyncService.syncMutation({mutationInfo:e},n)}))}};O=l([c(0,(0,t.Inject)(t.Injector)),c(1,m),c(2,t.ICommandService),c(3,T)],O);var k=`@univerjs/rpc`,A=`1.0.0-rc.0`;function j(){return{send(e){postMessage(e)},onMessage:new r.Observable(e=>{let t=t=>{e.next(t.data)};return addEventListener(`message`,t),()=>removeEventListener(`message`,t)}).pipe((0,r.shareReplay)({bufferSize:1,refCount:!0}))}}function M(e){return{send(t){e.postMessage(t)},onMessage:new r.Observable(t=>{let n=e=>{t.next(e.data)};return e.addEventListener(`message`,n),()=>e.removeEventListener(`message`,n)}).pipe((0,r.shareReplay)({bufferSize:1,refCount:!0}))}}let N=class extends t.Plugin{constructor(e=a,n,r){super(),this._config=e,this._injector=n,this._configService=r,y(this,`_internalWorker`,null);let{...o}=(0,t.merge)({},a,this._config);this._configService.setConfig(i,o)}dispose(){super.dispose(),this._internalWorker&&=(this._internalWorker.terminate(),null)}onStarting(){let{workerURL:e}=this._config;if(!e)throw Error(`[UniverRPCMainThreadPlugin]: The workerURL is required for the RPC main thread plugin.`);let t=e instanceof Worker?e:new Worker(e);this._internalWorker=e instanceof Worker?null:t;let n=M(t);[[T,{useFactory:()=>new E(n)}],[D],[d,{useClass:f}]].forEach(e=>this._injector.add(e)),this._injector.get(D)}};y(N,`pluginName`,`UNIVER_RPC_MAIN_THREAD_PLUGIN`),y(N,`packageName`,k),y(N,`version`,A),N=l([c(1,(0,t.Inject)(t.Injector)),c(2,t.IConfigService)],N);let P=class extends t.Plugin{constructor(e=s,n,r){super(),this._config=e,this._injector=n,this._configService=r;let{...i}=(0,t.merge)({},s,this._config);this._configService.setConfig(o,i)}onStarting(){[[O],[T,{useFactory:()=>new E(j())}],[m,{useClass:h}]].forEach(e=>this._injector.add(e)),this._injector.get(O)}};y(P,`pluginName`,`UNIVER_RPC_WORKER_THREAD_PLUGIN`),y(P,`packageName`,k),y(P,`version`,A),P=l([c(1,(0,t.Inject)(t.Injector)),c(2,t.IConfigService)],P),e.ChannelClient=C,e.ChannelServer=w,e.ChannelService=E,Object.defineProperty(e,"DataSyncPrimaryController",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"DataSyncReplicaController",{enumerable:!0,get:function(){return O}}),e.IRPCChannelService=T,e.IRemoteInstanceService=m,e.IRemoteSyncService=d,e.PLUGIN_CONFIG_KEY_MAIN_THREAD=i,e.PLUGIN_CONFIG_KEY_WORKER_THREAD=o,e.RemoteInstanceServiceName=p,Object.defineProperty(e,"RemoteSyncPrimaryService",{enumerable:!0,get:function(){return f}}),e.RemoteSyncServiceName=u,Object.defineProperty(e,"UniverRPCMainThreadPlugin",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"UniverRPCWorkerThreadPlugin",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"WebWorkerRemoteInstanceService",{enumerable:!0,get:function(){return h}}),e.fromModule=b,e.toModule=x});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/rpc",
3
- "version": "1.0.0-insiders.20260809-70eefdd",
3
+ "version": "1.0.0-rc.0",
4
4
  "private": false,
5
5
  "description": "Browser RPC layer for Univer main-thread and worker communication.",
6
6
  "author": "DreamNum Co., Ltd. <developer@univer.ai>",
@@ -52,13 +52,13 @@
52
52
  "rxjs": ">=7.0.0"
53
53
  },
54
54
  "dependencies": {
55
- "@univerjs/core": "1.0.0-insiders.20260809-70eefdd"
55
+ "@univerjs/core": "1.0.0-rc.0"
56
56
  },
57
57
  "devDependencies": {
58
58
  "rxjs": "^7.8.2",
59
59
  "typescript": "^6.0.3",
60
- "vitest": "^4.1.10",
61
- "@univerjs-infra/shared": "1.0.0-beta.0"
60
+ "vitest": "^5.0.0",
61
+ "@univerjs-infra/shared": "1.0.0-rc.0"
62
62
  },
63
63
  "scripts": {
64
64
  "test": "vitest run",