@univerjs/rpc 1.0.0-rc.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/cjs/index.js CHANGED
@@ -27,7 +27,7 @@ const configSymbolWorkerThread = Symbol(PLUGIN_CONFIG_KEY_WORKER_THREAD);
27
27
  const defaultPluginWorkerThreadConfig = {};
28
28
 
29
29
  //#endregion
30
- //#region \0@oxc-project+runtime@0.140.0/helpers/esm/decorateParam.js
30
+ //#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorateParam.js
31
31
  function __decorateParam(paramIndex, decorator) {
32
32
  return function(target, key) {
33
33
  decorator(target, key, paramIndex);
@@ -35,7 +35,7 @@ function __decorateParam(paramIndex, decorator) {
35
35
  }
36
36
 
37
37
  //#endregion
38
- //#region \0@oxc-project+runtime@0.140.0/helpers/esm/decorate.js
38
+ //#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorate.js
39
39
  function __decorate(decorators, target, key, desc) {
40
40
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
41
41
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -128,7 +128,7 @@ WebWorkerRemoteInstanceService = __decorate([
128
128
  ], WebWorkerRemoteInstanceService);
129
129
 
130
130
  //#endregion
131
- //#region \0@oxc-project+runtime@0.140.0/helpers/esm/typeof.js
131
+ //#region \0@oxc-project+runtime@0.149.0/helpers/esm/typeof.js
132
132
  function _typeof(o) {
133
133
  "@babel/helpers - typeof";
134
134
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -139,7 +139,7 @@ function _typeof(o) {
139
139
  }
140
140
 
141
141
  //#endregion
142
- //#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPrimitive.js
142
+ //#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPrimitive.js
143
143
  function toPrimitive(t, r) {
144
144
  if ("object" != _typeof(t) || !t) return t;
145
145
  var e = t[Symbol.toPrimitive];
@@ -152,14 +152,14 @@ function toPrimitive(t, r) {
152
152
  }
153
153
 
154
154
  //#endregion
155
- //#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPropertyKey.js
155
+ //#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPropertyKey.js
156
156
  function toPropertyKey(t) {
157
157
  var i = toPrimitive(t, "string");
158
158
  return "symbol" == _typeof(i) ? i : i + "";
159
159
  }
160
160
 
161
161
  //#endregion
162
- //#region \0@oxc-project+runtime@0.140.0/helpers/esm/defineProperty.js
162
+ //#region \0@oxc-project+runtime@0.149.0/helpers/esm/defineProperty.js
163
163
  function _defineProperty(e, r, t) {
164
164
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
165
165
  value: t,
@@ -222,6 +222,13 @@ function toModule(channel) {
222
222
  function propertyIsEventSource(name) {
223
223
  return name.endsWith("$");
224
224
  }
225
+ const CHANNEL_CLIENT_DISPOSED_ERROR_MESSAGE = "[ChannelClient]: client is disposed!";
226
+ var ChannelClientDisposedError = class extends Error {
227
+ constructor() {
228
+ super(CHANNEL_CLIENT_DISPOSED_ERROR_MESSAGE);
229
+ this.name = "ChannelClientDisposedError";
230
+ }
231
+ };
225
232
  /**
226
233
  * This method provides implementation for `IChannel` and is responsible for
227
234
  * transforming a local calling to a RPC calling.
@@ -238,7 +245,7 @@ var ChannelClient = class extends _univerjs_core.RxDisposable {
238
245
  }
239
246
  dispose() {
240
247
  if (this._disposed) return;
241
- const error = /* @__PURE__ */ new Error("[ChannelClient]: client is disposed!");
248
+ const error = new ChannelClientDisposedError();
242
249
  this._initialized.error(error);
243
250
  for (const responseHandler of this._pendingRequests.values()) responseHandler.dispose(error);
244
251
  this._pendingRequests.clear();
@@ -247,11 +254,11 @@ var ChannelClient = class extends _univerjs_core.RxDisposable {
247
254
  getChannel(channelName) {
248
255
  return {
249
256
  call: (method, args) => {
250
- if (this._disposed) return Promise.reject(/* @__PURE__ */ new Error("[ChannelClient]: client is disposed!"));
257
+ if (this._disposed) return Promise.reject(new ChannelClientDisposedError());
251
258
  return this._remoteCall(channelName, method, args);
252
259
  },
253
260
  subscribe: (eventMethod, args) => {
254
- if (this._disposed) throw new Error("[ChannelClient]: client is disposed!");
261
+ if (this._disposed) throw new ChannelClientDisposedError();
255
262
  return this._remoteSubscribe(channelName, eventMethod, args);
256
263
  }
257
264
  };
@@ -394,10 +401,7 @@ var ChannelServer = class extends _univerjs_core.RxDisposable {
394
401
  case 101:
395
402
  this._onSubscribe(request);
396
403
  break;
397
- case 102:
398
- this._onUnsubscribe(request);
399
- break;
400
- default: break;
404
+ case 102: this._onUnsubscribe(request);
401
405
  }
402
406
  }
403
407
  _sendInitialize() {
@@ -520,13 +524,14 @@ var ChannelService = class {
520
524
  //#endregion
521
525
  //#region src/controllers/data-sync/data-sync-primary.controller.ts
522
526
  let DataSyncPrimaryController = class DataSyncPrimaryController extends _univerjs_core.RxDisposable {
523
- constructor(_injector, _commandService, _univerInstanceService, _rpcChannelService, _remoteSyncService) {
527
+ constructor(_injector, _commandService, _univerInstanceService, _rpcChannelService, _remoteSyncService, _logService) {
524
528
  super();
525
529
  this._injector = _injector;
526
530
  this._commandService = _commandService;
527
531
  this._univerInstanceService = _univerInstanceService;
528
532
  this._rpcChannelService = _rpcChannelService;
529
533
  this._remoteSyncService = _remoteSyncService;
534
+ this._logService = _logService;
530
535
  _defineProperty(this, "_remoteInstanceService", void 0);
531
536
  _defineProperty(this, "_syncingUnits", /* @__PURE__ */ new Set());
532
537
  _defineProperty(this, "_syncingMutations", /* @__PURE__ */ new Set());
@@ -546,14 +551,14 @@ let DataSyncPrimaryController = class DataSyncPrimaryController extends _univerj
546
551
  const alreadySyncing = this._syncingUnits.has(unitId);
547
552
  this._syncingUnits.add(unitId);
548
553
  const unit = this._univerInstanceService.getUnit(unitId, _univerjs_core.UniverInstanceType.UNIVER_SHEET) ?? this._univerInstanceService.getUnit(unitId, _univerjs_core.UniverInstanceType.UNIVER_BASE);
549
- if (!alreadySyncing && unit) this._remoteInstanceService.createInstance({
554
+ if (!alreadySyncing && unit) this._handleRemoteRequest(this._remoteInstanceService.createInstance({
550
555
  unitID: unit.getUnitId(),
551
556
  type: unit.type,
552
557
  snapshot: unit.getSnapshot()
553
- });
558
+ }), "create the remote unit");
554
559
  return (0, _univerjs_core.toDisposable)(() => {
555
560
  if (!alreadySyncing) this._syncingUnits.delete(unitId);
556
- if (!alreadySyncing && unit) this._remoteInstanceService.disposeInstance({ unitID: unit.getUnitId() });
561
+ if (!alreadySyncing && unit) this._handleRemoteRequest(this._remoteInstanceService.disposeInstance({ unitID: unit.getUnitId() }), "dispose the remote unit");
557
562
  });
558
563
  }
559
564
  /** Sync registered mutations for a unit without creating a replica unit. */
@@ -578,34 +583,42 @@ let DataSyncPrimaryController = class DataSyncPrimaryController extends _univerj
578
583
  this._injector.add([IRemoteInstanceService, { useFactory: () => toModule(this._rpcChannelService.requestChannel(RemoteInstanceServiceName)) }]);
579
584
  this._remoteInstanceService = this._injector.get(IRemoteInstanceService);
580
585
  this._remoteReady = this._remoteInstanceService.whenReady();
586
+ this._handleRemoteRequest(this._remoteReady, "initialize the remote instance service");
581
587
  }
582
588
  _init() {
583
589
  this._univerInstanceService.getTypeOfUnitAdded$(_univerjs_core.UniverInstanceType.UNIVER_SHEET).pipe((0, rxjs_operators.takeUntil)(this.dispose$)).subscribe((event) => {
584
590
  const { unit: sheet } = event;
585
591
  this._syncingUnits.add(sheet.getUnitId());
586
- this._remoteInstanceService.createInstance({
592
+ this._handleRemoteRequest(this._remoteInstanceService.createInstance({
587
593
  unitID: sheet.getUnitId(),
588
594
  type: _univerjs_core.UniverInstanceType.UNIVER_SHEET,
589
595
  snapshot: sheet.getSnapshot()
590
- });
596
+ }), "create the remote workbook");
591
597
  });
592
598
  this._univerInstanceService.getTypeOfUnitDisposed$(_univerjs_core.UniverInstanceType.UNIVER_SHEET).pipe((0, rxjs_operators.takeUntil)(this.dispose$)).subscribe((workbook) => {
593
599
  this._syncingUnits.delete(workbook.getUnitId());
594
- this._remoteInstanceService.disposeInstance({ unitID: workbook.getUnitId() });
600
+ this._handleRemoteRequest(this._remoteInstanceService.disposeInstance({ unitID: workbook.getUnitId() }), "dispose the remote workbook");
595
601
  });
596
602
  this.disposeWithMe(this._commandService.onCommandExecuted((commandInfo, options) => {
597
603
  const { type, params, id } = commandInfo;
598
604
  const unitId = (params === null || params === void 0 ? void 0 : params.unitId) || "";
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);
605
+ 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._handleRemoteRequest(this.syncMutation(commandInfo, options), `sync mutation ${id}`);
600
606
  }));
601
607
  }
608
+ _handleRemoteRequest(request, operation) {
609
+ request.catch((error) => {
610
+ if (error instanceof ChannelClientDisposedError) return;
611
+ this._logService.error(`[DataSyncPrimaryController]: Failed to ${operation}.`, error);
612
+ });
613
+ }
602
614
  };
603
615
  DataSyncPrimaryController = __decorate([
604
616
  __decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_core.Injector)),
605
617
  __decorateParam(1, _univerjs_core.ICommandService),
606
618
  __decorateParam(2, _univerjs_core.IUniverInstanceService),
607
619
  __decorateParam(3, IRPCChannelService),
608
- __decorateParam(4, IRemoteSyncService)
620
+ __decorateParam(4, IRemoteSyncService),
621
+ __decorateParam(5, _univerjs_core.ILogService)
609
622
  ], DataSyncPrimaryController);
610
623
 
611
624
  //#endregion
@@ -642,7 +655,7 @@ DataSyncReplicaController = __decorate([
642
655
  //#endregion
643
656
  //#region package.json
644
657
  var name = "@univerjs/rpc";
645
- var version = "1.0.0-rc.0";
658
+ var version = "1.0.0";
646
659
 
647
660
  //#endregion
648
661
  //#region src/services/rpc/implementations/web-worker-rpc.service.ts
package/lib/es/index.js CHANGED
@@ -26,7 +26,7 @@ const configSymbolWorkerThread = Symbol(PLUGIN_CONFIG_KEY_WORKER_THREAD);
26
26
  const defaultPluginWorkerThreadConfig = {};
27
27
 
28
28
  //#endregion
29
- //#region \0@oxc-project+runtime@0.140.0/helpers/esm/decorateParam.js
29
+ //#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorateParam.js
30
30
  function __decorateParam(paramIndex, decorator) {
31
31
  return function(target, key) {
32
32
  decorator(target, key, paramIndex);
@@ -34,7 +34,7 @@ function __decorateParam(paramIndex, decorator) {
34
34
  }
35
35
 
36
36
  //#endregion
37
- //#region \0@oxc-project+runtime@0.140.0/helpers/esm/decorate.js
37
+ //#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorate.js
38
38
  function __decorate(decorators, target, key, desc) {
39
39
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
40
40
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -127,7 +127,7 @@ WebWorkerRemoteInstanceService = __decorate([
127
127
  ], WebWorkerRemoteInstanceService);
128
128
 
129
129
  //#endregion
130
- //#region \0@oxc-project+runtime@0.140.0/helpers/esm/typeof.js
130
+ //#region \0@oxc-project+runtime@0.149.0/helpers/esm/typeof.js
131
131
  function _typeof(o) {
132
132
  "@babel/helpers - typeof";
133
133
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -138,7 +138,7 @@ function _typeof(o) {
138
138
  }
139
139
 
140
140
  //#endregion
141
- //#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPrimitive.js
141
+ //#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPrimitive.js
142
142
  function toPrimitive(t, r) {
143
143
  if ("object" != _typeof(t) || !t) return t;
144
144
  var e = t[Symbol.toPrimitive];
@@ -151,14 +151,14 @@ function toPrimitive(t, r) {
151
151
  }
152
152
 
153
153
  //#endregion
154
- //#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPropertyKey.js
154
+ //#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPropertyKey.js
155
155
  function toPropertyKey(t) {
156
156
  var i = toPrimitive(t, "string");
157
157
  return "symbol" == _typeof(i) ? i : i + "";
158
158
  }
159
159
 
160
160
  //#endregion
161
- //#region \0@oxc-project+runtime@0.140.0/helpers/esm/defineProperty.js
161
+ //#region \0@oxc-project+runtime@0.149.0/helpers/esm/defineProperty.js
162
162
  function _defineProperty(e, r, t) {
163
163
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
164
164
  value: t,
@@ -221,6 +221,13 @@ function toModule(channel) {
221
221
  function propertyIsEventSource(name) {
222
222
  return name.endsWith("$");
223
223
  }
224
+ const CHANNEL_CLIENT_DISPOSED_ERROR_MESSAGE = "[ChannelClient]: client is disposed!";
225
+ var ChannelClientDisposedError = class extends Error {
226
+ constructor() {
227
+ super(CHANNEL_CLIENT_DISPOSED_ERROR_MESSAGE);
228
+ this.name = "ChannelClientDisposedError";
229
+ }
230
+ };
224
231
  /**
225
232
  * This method provides implementation for `IChannel` and is responsible for
226
233
  * transforming a local calling to a RPC calling.
@@ -237,7 +244,7 @@ var ChannelClient = class extends RxDisposable {
237
244
  }
238
245
  dispose() {
239
246
  if (this._disposed) return;
240
- const error = /* @__PURE__ */ new Error("[ChannelClient]: client is disposed!");
247
+ const error = new ChannelClientDisposedError();
241
248
  this._initialized.error(error);
242
249
  for (const responseHandler of this._pendingRequests.values()) responseHandler.dispose(error);
243
250
  this._pendingRequests.clear();
@@ -246,11 +253,11 @@ var ChannelClient = class extends RxDisposable {
246
253
  getChannel(channelName) {
247
254
  return {
248
255
  call: (method, args) => {
249
- if (this._disposed) return Promise.reject(/* @__PURE__ */ new Error("[ChannelClient]: client is disposed!"));
256
+ if (this._disposed) return Promise.reject(new ChannelClientDisposedError());
250
257
  return this._remoteCall(channelName, method, args);
251
258
  },
252
259
  subscribe: (eventMethod, args) => {
253
- if (this._disposed) throw new Error("[ChannelClient]: client is disposed!");
260
+ if (this._disposed) throw new ChannelClientDisposedError();
254
261
  return this._remoteSubscribe(channelName, eventMethod, args);
255
262
  }
256
263
  };
@@ -393,10 +400,7 @@ var ChannelServer = class extends RxDisposable {
393
400
  case 101:
394
401
  this._onSubscribe(request);
395
402
  break;
396
- case 102:
397
- this._onUnsubscribe(request);
398
- break;
399
- default: break;
403
+ case 102: this._onUnsubscribe(request);
400
404
  }
401
405
  }
402
406
  _sendInitialize() {
@@ -519,13 +523,14 @@ var ChannelService = class {
519
523
  //#endregion
520
524
  //#region src/controllers/data-sync/data-sync-primary.controller.ts
521
525
  let DataSyncPrimaryController = class DataSyncPrimaryController extends RxDisposable {
522
- constructor(_injector, _commandService, _univerInstanceService, _rpcChannelService, _remoteSyncService) {
526
+ constructor(_injector, _commandService, _univerInstanceService, _rpcChannelService, _remoteSyncService, _logService) {
523
527
  super();
524
528
  this._injector = _injector;
525
529
  this._commandService = _commandService;
526
530
  this._univerInstanceService = _univerInstanceService;
527
531
  this._rpcChannelService = _rpcChannelService;
528
532
  this._remoteSyncService = _remoteSyncService;
533
+ this._logService = _logService;
529
534
  _defineProperty(this, "_remoteInstanceService", void 0);
530
535
  _defineProperty(this, "_syncingUnits", /* @__PURE__ */ new Set());
531
536
  _defineProperty(this, "_syncingMutations", /* @__PURE__ */ new Set());
@@ -545,14 +550,14 @@ let DataSyncPrimaryController = class DataSyncPrimaryController extends RxDispos
545
550
  const alreadySyncing = this._syncingUnits.has(unitId);
546
551
  this._syncingUnits.add(unitId);
547
552
  const unit = this._univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_SHEET) ?? this._univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_BASE);
548
- if (!alreadySyncing && unit) this._remoteInstanceService.createInstance({
553
+ if (!alreadySyncing && unit) this._handleRemoteRequest(this._remoteInstanceService.createInstance({
549
554
  unitID: unit.getUnitId(),
550
555
  type: unit.type,
551
556
  snapshot: unit.getSnapshot()
552
- });
557
+ }), "create the remote unit");
553
558
  return toDisposable(() => {
554
559
  if (!alreadySyncing) this._syncingUnits.delete(unitId);
555
- if (!alreadySyncing && unit) this._remoteInstanceService.disposeInstance({ unitID: unit.getUnitId() });
560
+ if (!alreadySyncing && unit) this._handleRemoteRequest(this._remoteInstanceService.disposeInstance({ unitID: unit.getUnitId() }), "dispose the remote unit");
556
561
  });
557
562
  }
558
563
  /** Sync registered mutations for a unit without creating a replica unit. */
@@ -577,34 +582,42 @@ let DataSyncPrimaryController = class DataSyncPrimaryController extends RxDispos
577
582
  this._injector.add([IRemoteInstanceService, { useFactory: () => toModule(this._rpcChannelService.requestChannel(RemoteInstanceServiceName)) }]);
578
583
  this._remoteInstanceService = this._injector.get(IRemoteInstanceService);
579
584
  this._remoteReady = this._remoteInstanceService.whenReady();
585
+ this._handleRemoteRequest(this._remoteReady, "initialize the remote instance service");
580
586
  }
581
587
  _init() {
582
588
  this._univerInstanceService.getTypeOfUnitAdded$(UniverInstanceType.UNIVER_SHEET).pipe(takeUntil(this.dispose$)).subscribe((event) => {
583
589
  const { unit: sheet } = event;
584
590
  this._syncingUnits.add(sheet.getUnitId());
585
- this._remoteInstanceService.createInstance({
591
+ this._handleRemoteRequest(this._remoteInstanceService.createInstance({
586
592
  unitID: sheet.getUnitId(),
587
593
  type: UniverInstanceType.UNIVER_SHEET,
588
594
  snapshot: sheet.getSnapshot()
589
- });
595
+ }), "create the remote workbook");
590
596
  });
591
597
  this._univerInstanceService.getTypeOfUnitDisposed$(UniverInstanceType.UNIVER_SHEET).pipe(takeUntil(this.dispose$)).subscribe((workbook) => {
592
598
  this._syncingUnits.delete(workbook.getUnitId());
593
- this._remoteInstanceService.disposeInstance({ unitID: workbook.getUnitId() });
599
+ this._handleRemoteRequest(this._remoteInstanceService.disposeInstance({ unitID: workbook.getUnitId() }), "dispose the remote workbook");
594
600
  });
595
601
  this.disposeWithMe(this._commandService.onCommandExecuted((commandInfo, options) => {
596
602
  const { type, params, id } = commandInfo;
597
603
  const unitId = (params === null || params === void 0 ? void 0 : params.unitId) || "";
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);
604
+ if (type === CommandType.MUTATION && (!unitId || this._syncingUnits.has(unitId)) && !(options === null || options === void 0 ? void 0 : options.fromSync) && this._syncingMutations.has(id)) this._handleRemoteRequest(this.syncMutation(commandInfo, options), `sync mutation ${id}`);
599
605
  }));
600
606
  }
607
+ _handleRemoteRequest(request, operation) {
608
+ request.catch((error) => {
609
+ if (error instanceof ChannelClientDisposedError) return;
610
+ this._logService.error(`[DataSyncPrimaryController]: Failed to ${operation}.`, error);
611
+ });
612
+ }
601
613
  };
602
614
  DataSyncPrimaryController = __decorate([
603
615
  __decorateParam(0, Inject(Injector)),
604
616
  __decorateParam(1, ICommandService),
605
617
  __decorateParam(2, IUniverInstanceService),
606
618
  __decorateParam(3, IRPCChannelService),
607
- __decorateParam(4, IRemoteSyncService)
619
+ __decorateParam(4, IRemoteSyncService),
620
+ __decorateParam(5, ILogService)
608
621
  ], DataSyncPrimaryController);
609
622
 
610
623
  //#endregion
@@ -641,7 +654,7 @@ DataSyncReplicaController = __decorate([
641
654
  //#endregion
642
655
  //#region package.json
643
656
  var name = "@univerjs/rpc";
644
- var version = "1.0.0-rc.0";
657
+ var version = "1.0.0";
645
658
 
646
659
  //#endregion
647
660
  //#region src/services/rpc/implementations/web-worker-rpc.service.ts
package/lib/index.js CHANGED
@@ -26,7 +26,7 @@ const configSymbolWorkerThread = Symbol(PLUGIN_CONFIG_KEY_WORKER_THREAD);
26
26
  const defaultPluginWorkerThreadConfig = {};
27
27
 
28
28
  //#endregion
29
- //#region \0@oxc-project+runtime@0.140.0/helpers/esm/decorateParam.js
29
+ //#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorateParam.js
30
30
  function __decorateParam(paramIndex, decorator) {
31
31
  return function(target, key) {
32
32
  decorator(target, key, paramIndex);
@@ -34,7 +34,7 @@ function __decorateParam(paramIndex, decorator) {
34
34
  }
35
35
 
36
36
  //#endregion
37
- //#region \0@oxc-project+runtime@0.140.0/helpers/esm/decorate.js
37
+ //#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorate.js
38
38
  function __decorate(decorators, target, key, desc) {
39
39
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
40
40
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -127,7 +127,7 @@ WebWorkerRemoteInstanceService = __decorate([
127
127
  ], WebWorkerRemoteInstanceService);
128
128
 
129
129
  //#endregion
130
- //#region \0@oxc-project+runtime@0.140.0/helpers/esm/typeof.js
130
+ //#region \0@oxc-project+runtime@0.149.0/helpers/esm/typeof.js
131
131
  function _typeof(o) {
132
132
  "@babel/helpers - typeof";
133
133
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -138,7 +138,7 @@ function _typeof(o) {
138
138
  }
139
139
 
140
140
  //#endregion
141
- //#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPrimitive.js
141
+ //#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPrimitive.js
142
142
  function toPrimitive(t, r) {
143
143
  if ("object" != _typeof(t) || !t) return t;
144
144
  var e = t[Symbol.toPrimitive];
@@ -151,14 +151,14 @@ function toPrimitive(t, r) {
151
151
  }
152
152
 
153
153
  //#endregion
154
- //#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPropertyKey.js
154
+ //#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPropertyKey.js
155
155
  function toPropertyKey(t) {
156
156
  var i = toPrimitive(t, "string");
157
157
  return "symbol" == _typeof(i) ? i : i + "";
158
158
  }
159
159
 
160
160
  //#endregion
161
- //#region \0@oxc-project+runtime@0.140.0/helpers/esm/defineProperty.js
161
+ //#region \0@oxc-project+runtime@0.149.0/helpers/esm/defineProperty.js
162
162
  function _defineProperty(e, r, t) {
163
163
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
164
164
  value: t,
@@ -221,6 +221,13 @@ function toModule(channel) {
221
221
  function propertyIsEventSource(name) {
222
222
  return name.endsWith("$");
223
223
  }
224
+ const CHANNEL_CLIENT_DISPOSED_ERROR_MESSAGE = "[ChannelClient]: client is disposed!";
225
+ var ChannelClientDisposedError = class extends Error {
226
+ constructor() {
227
+ super(CHANNEL_CLIENT_DISPOSED_ERROR_MESSAGE);
228
+ this.name = "ChannelClientDisposedError";
229
+ }
230
+ };
224
231
  /**
225
232
  * This method provides implementation for `IChannel` and is responsible for
226
233
  * transforming a local calling to a RPC calling.
@@ -237,7 +244,7 @@ var ChannelClient = class extends RxDisposable {
237
244
  }
238
245
  dispose() {
239
246
  if (this._disposed) return;
240
- const error = /* @__PURE__ */ new Error("[ChannelClient]: client is disposed!");
247
+ const error = new ChannelClientDisposedError();
241
248
  this._initialized.error(error);
242
249
  for (const responseHandler of this._pendingRequests.values()) responseHandler.dispose(error);
243
250
  this._pendingRequests.clear();
@@ -246,11 +253,11 @@ var ChannelClient = class extends RxDisposable {
246
253
  getChannel(channelName) {
247
254
  return {
248
255
  call: (method, args) => {
249
- if (this._disposed) return Promise.reject(/* @__PURE__ */ new Error("[ChannelClient]: client is disposed!"));
256
+ if (this._disposed) return Promise.reject(new ChannelClientDisposedError());
250
257
  return this._remoteCall(channelName, method, args);
251
258
  },
252
259
  subscribe: (eventMethod, args) => {
253
- if (this._disposed) throw new Error("[ChannelClient]: client is disposed!");
260
+ if (this._disposed) throw new ChannelClientDisposedError();
254
261
  return this._remoteSubscribe(channelName, eventMethod, args);
255
262
  }
256
263
  };
@@ -393,10 +400,7 @@ var ChannelServer = class extends RxDisposable {
393
400
  case 101:
394
401
  this._onSubscribe(request);
395
402
  break;
396
- case 102:
397
- this._onUnsubscribe(request);
398
- break;
399
- default: break;
403
+ case 102: this._onUnsubscribe(request);
400
404
  }
401
405
  }
402
406
  _sendInitialize() {
@@ -519,13 +523,14 @@ var ChannelService = class {
519
523
  //#endregion
520
524
  //#region src/controllers/data-sync/data-sync-primary.controller.ts
521
525
  let DataSyncPrimaryController = class DataSyncPrimaryController extends RxDisposable {
522
- constructor(_injector, _commandService, _univerInstanceService, _rpcChannelService, _remoteSyncService) {
526
+ constructor(_injector, _commandService, _univerInstanceService, _rpcChannelService, _remoteSyncService, _logService) {
523
527
  super();
524
528
  this._injector = _injector;
525
529
  this._commandService = _commandService;
526
530
  this._univerInstanceService = _univerInstanceService;
527
531
  this._rpcChannelService = _rpcChannelService;
528
532
  this._remoteSyncService = _remoteSyncService;
533
+ this._logService = _logService;
529
534
  _defineProperty(this, "_remoteInstanceService", void 0);
530
535
  _defineProperty(this, "_syncingUnits", /* @__PURE__ */ new Set());
531
536
  _defineProperty(this, "_syncingMutations", /* @__PURE__ */ new Set());
@@ -545,14 +550,14 @@ let DataSyncPrimaryController = class DataSyncPrimaryController extends RxDispos
545
550
  const alreadySyncing = this._syncingUnits.has(unitId);
546
551
  this._syncingUnits.add(unitId);
547
552
  const unit = this._univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_SHEET) ?? this._univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_BASE);
548
- if (!alreadySyncing && unit) this._remoteInstanceService.createInstance({
553
+ if (!alreadySyncing && unit) this._handleRemoteRequest(this._remoteInstanceService.createInstance({
549
554
  unitID: unit.getUnitId(),
550
555
  type: unit.type,
551
556
  snapshot: unit.getSnapshot()
552
- });
557
+ }), "create the remote unit");
553
558
  return toDisposable(() => {
554
559
  if (!alreadySyncing) this._syncingUnits.delete(unitId);
555
- if (!alreadySyncing && unit) this._remoteInstanceService.disposeInstance({ unitID: unit.getUnitId() });
560
+ if (!alreadySyncing && unit) this._handleRemoteRequest(this._remoteInstanceService.disposeInstance({ unitID: unit.getUnitId() }), "dispose the remote unit");
556
561
  });
557
562
  }
558
563
  /** Sync registered mutations for a unit without creating a replica unit. */
@@ -577,34 +582,42 @@ let DataSyncPrimaryController = class DataSyncPrimaryController extends RxDispos
577
582
  this._injector.add([IRemoteInstanceService, { useFactory: () => toModule(this._rpcChannelService.requestChannel(RemoteInstanceServiceName)) }]);
578
583
  this._remoteInstanceService = this._injector.get(IRemoteInstanceService);
579
584
  this._remoteReady = this._remoteInstanceService.whenReady();
585
+ this._handleRemoteRequest(this._remoteReady, "initialize the remote instance service");
580
586
  }
581
587
  _init() {
582
588
  this._univerInstanceService.getTypeOfUnitAdded$(UniverInstanceType.UNIVER_SHEET).pipe(takeUntil(this.dispose$)).subscribe((event) => {
583
589
  const { unit: sheet } = event;
584
590
  this._syncingUnits.add(sheet.getUnitId());
585
- this._remoteInstanceService.createInstance({
591
+ this._handleRemoteRequest(this._remoteInstanceService.createInstance({
586
592
  unitID: sheet.getUnitId(),
587
593
  type: UniverInstanceType.UNIVER_SHEET,
588
594
  snapshot: sheet.getSnapshot()
589
- });
595
+ }), "create the remote workbook");
590
596
  });
591
597
  this._univerInstanceService.getTypeOfUnitDisposed$(UniverInstanceType.UNIVER_SHEET).pipe(takeUntil(this.dispose$)).subscribe((workbook) => {
592
598
  this._syncingUnits.delete(workbook.getUnitId());
593
- this._remoteInstanceService.disposeInstance({ unitID: workbook.getUnitId() });
599
+ this._handleRemoteRequest(this._remoteInstanceService.disposeInstance({ unitID: workbook.getUnitId() }), "dispose the remote workbook");
594
600
  });
595
601
  this.disposeWithMe(this._commandService.onCommandExecuted((commandInfo, options) => {
596
602
  const { type, params, id } = commandInfo;
597
603
  const unitId = (params === null || params === void 0 ? void 0 : params.unitId) || "";
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);
604
+ if (type === CommandType.MUTATION && (!unitId || this._syncingUnits.has(unitId)) && !(options === null || options === void 0 ? void 0 : options.fromSync) && this._syncingMutations.has(id)) this._handleRemoteRequest(this.syncMutation(commandInfo, options), `sync mutation ${id}`);
599
605
  }));
600
606
  }
607
+ _handleRemoteRequest(request, operation) {
608
+ request.catch((error) => {
609
+ if (error instanceof ChannelClientDisposedError) return;
610
+ this._logService.error(`[DataSyncPrimaryController]: Failed to ${operation}.`, error);
611
+ });
612
+ }
601
613
  };
602
614
  DataSyncPrimaryController = __decorate([
603
615
  __decorateParam(0, Inject(Injector)),
604
616
  __decorateParam(1, ICommandService),
605
617
  __decorateParam(2, IUniverInstanceService),
606
618
  __decorateParam(3, IRPCChannelService),
607
- __decorateParam(4, IRemoteSyncService)
619
+ __decorateParam(4, IRemoteSyncService),
620
+ __decorateParam(5, ILogService)
608
621
  ], DataSyncPrimaryController);
609
622
 
610
623
  //#endregion
@@ -641,7 +654,7 @@ DataSyncReplicaController = __decorate([
641
654
  //#endregion
642
655
  //#region package.json
643
656
  var name = "@univerjs/rpc";
644
- var version = "1.0.0-rc.0";
657
+ var version = "1.0.0";
645
658
 
646
659
  //#endregion
647
660
  //#region src/services/rpc/implementations/web-worker-rpc.service.ts
@@ -15,7 +15,7 @@
15
15
  */
16
16
  import type { IDisposable, IMutation, IMutationInfo } from '@univerjs/core';
17
17
  import type { IRemoteSyncMutationOptions } from '../../services/remote-instance/remote-instance.service';
18
- import { ICommandService, Injector, IUniverInstanceService, RxDisposable } from '@univerjs/core';
18
+ import { ICommandService, ILogService, Injector, IUniverInstanceService, RxDisposable } from '@univerjs/core';
19
19
  import { IRemoteSyncService } from '../../services/remote-instance/remote-instance.service';
20
20
  import { IRPCChannelService } from '../../services/rpc/channel.service';
21
21
  /**
@@ -30,12 +30,13 @@ export declare class DataSyncPrimaryController extends RxDisposable {
30
30
  private readonly _univerInstanceService;
31
31
  private readonly _rpcChannelService;
32
32
  private readonly _remoteSyncService;
33
+ private readonly _logService;
33
34
  private _remoteInstanceService;
34
35
  private readonly _syncingUnits;
35
36
  private readonly _syncingMutations;
36
37
  private _syncMutationQueue;
37
38
  private _remoteReady;
38
- constructor(_injector: Injector, _commandService: ICommandService, _univerInstanceService: IUniverInstanceService, _rpcChannelService: IRPCChannelService, _remoteSyncService: IRemoteSyncService);
39
+ constructor(_injector: Injector, _commandService: ICommandService, _univerInstanceService: IUniverInstanceService, _rpcChannelService: IRPCChannelService, _remoteSyncService: IRemoteSyncService, _logService: ILogService);
39
40
  registerSyncingMutations(mutation: IMutation<object>): void;
40
41
  /**
41
42
  * Only spreadsheets would be synced to the web worker in normal situations. If you would like to
@@ -48,4 +49,5 @@ export declare class DataSyncPrimaryController extends RxDisposable {
48
49
  waitForPendingMutations(): Promise<void>;
49
50
  private _initRPCChannels;
50
51
  private _init;
52
+ private _handleRemoteRequest;
51
53
  }
@@ -52,6 +52,9 @@ export interface IChannelClient {
52
52
  export interface IChannelServer {
53
53
  registerChannel<T extends IChannel>(channelName: string, channel: T): void;
54
54
  }
55
+ export declare class ChannelClientDisposedError extends Error {
56
+ constructor();
57
+ }
55
58
  /**
56
59
  * This method provides implementation for `IChannel` and is responsible for
57
60
  * transforming a local calling to a RPC calling.
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,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});
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 Error{constructor(){super(`[ChannelClient]: client is disposed!`),this.name=`ChannelClientDisposedError`}},w=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=new C;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(new C):this._remoteCall(e,t,n),subscribe:(t,n)=>{if(this._disposed)throw new C;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}}}},T=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)}}_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 E=(0,t.createIdentifier)(`IRPCChannelService`);var D=class{constructor(e){y(this,`_client`,void 0),y(this,`_server`,void 0),this._client=new w(e),this._server=new T(e)}dispose(){this._client.dispose(),this._server.dispose()}requestChannel(e){return this._client.getChannel(e)}registerChannel(e,t){this._server.registerChannel(e,t)}};let O=class extends t.RxDisposable{constructor(e,t,n,r,i,a){super(),this._injector=e,this._commandService=t,this._univerInstanceService=n,this._rpcChannelService=r,this._remoteSyncService=i,this._logService=a,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._handleRemoteRequest(this._remoteInstanceService.createInstance({unitID:r.getUnitId(),type:r.type,snapshot:r.getSnapshot()}),`create the remote unit`),(0,t.toDisposable)(()=>{n||this._syncingUnits.delete(e),!n&&r&&this._handleRemoteRequest(this._remoteInstanceService.disposeInstance({unitID:r.getUnitId()}),`dispose the remote unit`)})}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(),this._handleRemoteRequest(this._remoteReady,`initialize the remote instance service`)}_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._handleRemoteRequest(this._remoteInstanceService.createInstance({unitID:n.getUnitId(),type:t.UniverInstanceType.UNIVER_SHEET,snapshot:n.getSnapshot()}),`create the remote workbook`)}),this._univerInstanceService.getTypeOfUnitDisposed$(t.UniverInstanceType.UNIVER_SHEET).pipe((0,n.takeUntil)(this.dispose$)).subscribe(e=>{this._syncingUnits.delete(e.getUnitId()),this._handleRemoteRequest(this._remoteInstanceService.disposeInstance({unitID:e.getUnitId()}),`dispose the remote workbook`)}),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._handleRemoteRequest(this.syncMutation(e,n),`sync mutation ${a}`)}))}_handleRemoteRequest(e,t){e.catch(e=>{e instanceof C||this._logService.error(`[DataSyncPrimaryController]: Failed to ${t}.`,e)})}};O=l([c(0,(0,t.Inject)(t.Injector)),c(1,t.ICommandService),c(2,t.IUniverInstanceService),c(3,E),c(4,d),c(5,t.ILogService)],O);let k=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)}))}};k=l([c(0,(0,t.Inject)(t.Injector)),c(1,m),c(2,t.ICommandService),c(3,E)],k);var A=`@univerjs/rpc`,j=`1.0.0`;function M(){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 N(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 P=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=N(t);[[E,{useFactory:()=>new D(n)}],[O],[d,{useClass:f}]].forEach(e=>this._injector.add(e)),this._injector.get(O)}};y(P,`pluginName`,`UNIVER_RPC_MAIN_THREAD_PLUGIN`),y(P,`packageName`,A),y(P,`version`,j),P=l([c(1,(0,t.Inject)(t.Injector)),c(2,t.IConfigService)],P);let F=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(){[[k],[E,{useFactory:()=>new D(M())}],[m,{useClass:h}]].forEach(e=>this._injector.add(e)),this._injector.get(k)}};y(F,`pluginName`,`UNIVER_RPC_WORKER_THREAD_PLUGIN`),y(F,`packageName`,A),y(F,`version`,j),F=l([c(1,(0,t.Inject)(t.Injector)),c(2,t.IConfigService)],F),e.ChannelClient=w,e.ChannelServer=T,e.ChannelService=D,Object.defineProperty(e,"DataSyncPrimaryController",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"DataSyncReplicaController",{enumerable:!0,get:function(){return k}}),e.IRPCChannelService=E,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 P}}),Object.defineProperty(e,"UniverRPCWorkerThreadPlugin",{enumerable:!0,get:function(){return F}}),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-rc.0",
3
+ "version": "1.0.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-rc.0"
55
+ "@univerjs/core": "1.0.0"
56
56
  },
57
57
  "devDependencies": {
58
+ "@univerjs-infra/shared": "1.0.0",
58
59
  "rxjs": "^7.8.2",
59
60
  "typescript": "^6.0.3",
60
- "vitest": "^5.0.0",
61
- "@univerjs-infra/shared": "1.0.0-rc.0"
61
+ "vitest": "^5.0.0"
62
62
  },
63
63
  "scripts": {
64
64
  "test": "vitest run",