@univerjs/rpc 0.6.7 → 0.6.9
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/index.js +525 -0
- package/package.json +3 -3
package/lib/index.js
ADDED
|
@@ -0,0 +1,525 @@
|
|
|
1
|
+
var X = Object.defineProperty;
|
|
2
|
+
var Z = (s, t, e) => t in s ? X(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e;
|
|
3
|
+
var a = (s, t, e) => Z(s, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
+
import { createIdentifier as k, UniverInstanceType as u, ICommandService as C, IUniverInstanceService as L, ILogService as ee, RxDisposable as O, Inject as b, Injector as R, toDisposable as te, CommandType as H, Disposable as ne, IConfigService as A, Plugin as V, merge as F } from "@univerjs/core";
|
|
5
|
+
import { takeUntil as v, filter as se, take as re } from "rxjs/operators";
|
|
6
|
+
import { BehaviorSubject as ie, firstValueFrom as ce, Observable as T, isObservable as oe, of as ae, shareReplay as z } from "rxjs";
|
|
7
|
+
const he = "rpc.main-thread.config", j = {}, le = "rpc.worker-thread.config", D = {};
|
|
8
|
+
var _e = Object.getOwnPropertyDescriptor, G = (s, t, e, n) => {
|
|
9
|
+
for (var r = n > 1 ? void 0 : n ? _e(t, e) : t, i = s.length - 1, c; i >= 0; i--)
|
|
10
|
+
(c = s[i]) && (r = c(r) || r);
|
|
11
|
+
return r;
|
|
12
|
+
}, p = (s, t) => (e, n) => t(e, n, s);
|
|
13
|
+
const W = "rpc.remote-sync.service", m = k(W);
|
|
14
|
+
let M = class {
|
|
15
|
+
constructor(s) {
|
|
16
|
+
this._commandService = s;
|
|
17
|
+
}
|
|
18
|
+
async syncMutation(s) {
|
|
19
|
+
return this._commandService.syncExecuteCommand(s.mutationInfo.id, s.mutationInfo.params, {
|
|
20
|
+
onlyLocal: !0,
|
|
21
|
+
fromSync: !0
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
M = G([
|
|
26
|
+
p(0, C)
|
|
27
|
+
], M);
|
|
28
|
+
const $ = "univer.remote-instance-service", g = k($);
|
|
29
|
+
let q = class {
|
|
30
|
+
constructor(s, t, e) {
|
|
31
|
+
this._univerInstanceService = s, this._commandService = t, this._logService = e;
|
|
32
|
+
}
|
|
33
|
+
whenReady() {
|
|
34
|
+
return Promise.resolve(!0);
|
|
35
|
+
}
|
|
36
|
+
async syncMutation(s) {
|
|
37
|
+
return this._applyMutation(s.mutationInfo);
|
|
38
|
+
}
|
|
39
|
+
async createInstance(s) {
|
|
40
|
+
const { type: t, snapshot: e } = s;
|
|
41
|
+
try {
|
|
42
|
+
switch (t) {
|
|
43
|
+
case u.UNIVER_SHEET:
|
|
44
|
+
return this._univerInstanceService.createUnit(u.UNIVER_SHEET, e), !0;
|
|
45
|
+
default:
|
|
46
|
+
throw new Error(
|
|
47
|
+
`[WebWorkerRemoteInstanceService]: cannot create replica for document type: ${t}.`
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
} catch (n) {
|
|
51
|
+
throw n instanceof Error ? n : new TypeError(`${n}`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
async disposeInstance(s) {
|
|
55
|
+
return this._univerInstanceService.disposeUnit(s.unitID);
|
|
56
|
+
}
|
|
57
|
+
_applyMutation(s) {
|
|
58
|
+
const { id: t, params: e } = s;
|
|
59
|
+
return this._commandService.syncExecuteCommand(t, e, {
|
|
60
|
+
onlyLocal: !0,
|
|
61
|
+
fromSync: !0
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
q = G([
|
|
66
|
+
p(0, L),
|
|
67
|
+
p(1, C),
|
|
68
|
+
p(2, ee)
|
|
69
|
+
], q);
|
|
70
|
+
function Y(s) {
|
|
71
|
+
const t = s;
|
|
72
|
+
return new class {
|
|
73
|
+
call(e, n) {
|
|
74
|
+
const r = t[e];
|
|
75
|
+
if (typeof r == "function") {
|
|
76
|
+
let i = n ? r.apply(t, n) : r.call(t);
|
|
77
|
+
return i instanceof Promise || (i = Promise.resolve(i)), i;
|
|
78
|
+
}
|
|
79
|
+
throw new Error(`[RPC]: method not found for ${e}!`);
|
|
80
|
+
}
|
|
81
|
+
subscribe(e, n) {
|
|
82
|
+
const r = t[e];
|
|
83
|
+
if (typeof r == "function") {
|
|
84
|
+
const i = n ? r.apply(t, n) : r.call(t);
|
|
85
|
+
return oe(i) ? i : ae(i);
|
|
86
|
+
}
|
|
87
|
+
throw new Error(`[RPC]: observable method not found for ${e}!`);
|
|
88
|
+
}
|
|
89
|
+
}();
|
|
90
|
+
}
|
|
91
|
+
function B(s) {
|
|
92
|
+
return new Proxy({}, {
|
|
93
|
+
get(t, e) {
|
|
94
|
+
if (e !== "dispose")
|
|
95
|
+
return function(...n) {
|
|
96
|
+
return ue(e) ? s.subscribe(e, n) : s.call(e, n);
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
function ue(s) {
|
|
102
|
+
return s.endsWith("$");
|
|
103
|
+
}
|
|
104
|
+
class de extends O {
|
|
105
|
+
constructor(e) {
|
|
106
|
+
super();
|
|
107
|
+
a(this, "_initialized", new ie(!1));
|
|
108
|
+
a(this, "_lastRequestCounter", 0);
|
|
109
|
+
a(this, "_pendingRequests", /* @__PURE__ */ new Map());
|
|
110
|
+
this._protocol = e, this._protocol.send({
|
|
111
|
+
type: 50
|
|
112
|
+
/* REQUEST_INITIALIZATION */
|
|
113
|
+
}), this._protocol.onMessage.pipe(v(this.dispose$)).subscribe((n) => this._onMessage(n));
|
|
114
|
+
}
|
|
115
|
+
dispose() {
|
|
116
|
+
this._pendingRequests.clear();
|
|
117
|
+
}
|
|
118
|
+
getChannel(e) {
|
|
119
|
+
const n = this;
|
|
120
|
+
return {
|
|
121
|
+
call(r, i) {
|
|
122
|
+
return n._disposed ? Promise.reject() : n._remoteCall(e, r, i);
|
|
123
|
+
},
|
|
124
|
+
subscribe(r, i) {
|
|
125
|
+
if (n._disposed)
|
|
126
|
+
throw new Error("[ChannelClient]: client is disposed!");
|
|
127
|
+
return n._remoteSubscribe(e, r, i);
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
_whenReady() {
|
|
132
|
+
return ce(
|
|
133
|
+
this._initialized.pipe(
|
|
134
|
+
se((e) => e),
|
|
135
|
+
re(1)
|
|
136
|
+
)
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
async _remoteCall(e, n, r) {
|
|
140
|
+
await this._whenReady();
|
|
141
|
+
const i = ++this._lastRequestCounter, h = { seq: i, type: 100, channelName: e, method: n, args: r }, o = this;
|
|
142
|
+
return new Promise((w, l) => {
|
|
143
|
+
const Q = {
|
|
144
|
+
handle(E) {
|
|
145
|
+
switch (E.type) {
|
|
146
|
+
case 201:
|
|
147
|
+
o._pendingRequests.delete(i), w(E.data);
|
|
148
|
+
break;
|
|
149
|
+
case 202:
|
|
150
|
+
o._pendingRequests.delete(i), l(E.data);
|
|
151
|
+
break;
|
|
152
|
+
default:
|
|
153
|
+
throw new Error("[ChannelClient]: unknown response type!");
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
this._pendingRequests.set(i, Q), this._sendRequest(h);
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
_remoteSubscribe(e, n, r) {
|
|
161
|
+
return new T((i) => {
|
|
162
|
+
let c = -1;
|
|
163
|
+
return this._whenReady().then(() => {
|
|
164
|
+
c = ++this._lastRequestCounter;
|
|
165
|
+
const o = { seq: c, type: 101, channelName: e, method: n, args: r }, w = {
|
|
166
|
+
handle(l) {
|
|
167
|
+
switch (l.type) {
|
|
168
|
+
case 300:
|
|
169
|
+
i.next(l.data);
|
|
170
|
+
break;
|
|
171
|
+
case 301:
|
|
172
|
+
i.error(l.data);
|
|
173
|
+
break;
|
|
174
|
+
case 302:
|
|
175
|
+
i.complete();
|
|
176
|
+
break;
|
|
177
|
+
default:
|
|
178
|
+
throw new Error("[ChannelClient]: unknown response type!");
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
this._pendingRequests.set(c, w), this._sendRequest(o);
|
|
183
|
+
}), () => {
|
|
184
|
+
if (c === -1)
|
|
185
|
+
return;
|
|
186
|
+
const h = {
|
|
187
|
+
type: 102,
|
|
188
|
+
seq: c,
|
|
189
|
+
channelName: e,
|
|
190
|
+
method: n
|
|
191
|
+
};
|
|
192
|
+
this._sendRequest(h);
|
|
193
|
+
};
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
_sendRequest(e) {
|
|
197
|
+
this._protocol.send(e);
|
|
198
|
+
}
|
|
199
|
+
_onMessage(e) {
|
|
200
|
+
var n;
|
|
201
|
+
switch (e.type) {
|
|
202
|
+
case 0:
|
|
203
|
+
this._initialized.next(!0);
|
|
204
|
+
break;
|
|
205
|
+
case 201:
|
|
206
|
+
case 202:
|
|
207
|
+
case 300:
|
|
208
|
+
case 302:
|
|
209
|
+
case 301:
|
|
210
|
+
(n = this._pendingRequests.get(e.seq)) == null || n.handle(e);
|
|
211
|
+
break;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
class pe extends O {
|
|
216
|
+
constructor(e) {
|
|
217
|
+
super();
|
|
218
|
+
a(this, "_channels", /* @__PURE__ */ new Map());
|
|
219
|
+
a(this, "_subscriptions", /* @__PURE__ */ new Map());
|
|
220
|
+
this._protocol = e, this._protocol.onMessage.pipe(v(this.dispose$)).subscribe((n) => this._onRequest(n)), this._sendInitialize();
|
|
221
|
+
}
|
|
222
|
+
dispose() {
|
|
223
|
+
super.dispose(), this._subscriptions.clear(), this._channels.clear();
|
|
224
|
+
}
|
|
225
|
+
registerChannel(e, n) {
|
|
226
|
+
this._channels.set(e, n);
|
|
227
|
+
}
|
|
228
|
+
_onRequest(e) {
|
|
229
|
+
switch (e.type) {
|
|
230
|
+
case 50:
|
|
231
|
+
this._sendInitialize();
|
|
232
|
+
break;
|
|
233
|
+
case 100:
|
|
234
|
+
this._onMethodCall(e);
|
|
235
|
+
break;
|
|
236
|
+
case 101:
|
|
237
|
+
this._onSubscribe(e);
|
|
238
|
+
break;
|
|
239
|
+
case 102:
|
|
240
|
+
this._onUnsubscribe(e);
|
|
241
|
+
break;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
_sendInitialize() {
|
|
245
|
+
this._sendResponse({
|
|
246
|
+
seq: -1,
|
|
247
|
+
type: 0
|
|
248
|
+
/* INITIALIZE */
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
_onMethodCall(e) {
|
|
252
|
+
const { channelName: n, method: r, args: i } = e, c = this._channels.get(n);
|
|
253
|
+
let h;
|
|
254
|
+
try {
|
|
255
|
+
if (!c)
|
|
256
|
+
throw new Error(`[ChannelServer]: Channel ${n} not found!`);
|
|
257
|
+
h = i ? c.call(r, i) : c.call(r);
|
|
258
|
+
} catch (o) {
|
|
259
|
+
h = Promise.reject(o);
|
|
260
|
+
}
|
|
261
|
+
h.then((o) => {
|
|
262
|
+
this._sendResponse({ seq: e.seq, type: 201, data: o });
|
|
263
|
+
}).catch((o) => {
|
|
264
|
+
o instanceof Error ? this._sendResponse({ seq: e.seq, type: 202, data: o.message }) : this._sendResponse({ seq: e.seq, type: 202, data: String(o) });
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
_onSubscribe(e) {
|
|
268
|
+
const { channelName: n, seq: r } = e, i = this._channels.get(n);
|
|
269
|
+
try {
|
|
270
|
+
if (!i)
|
|
271
|
+
throw new Error(`[ChannelServer]: Channel ${n} not found!`);
|
|
272
|
+
const h = i.subscribe(e.method, e.args).subscribe({
|
|
273
|
+
next: (o) => {
|
|
274
|
+
this._sendResponse({ seq: r, type: 300, data: o });
|
|
275
|
+
},
|
|
276
|
+
error: (o) => {
|
|
277
|
+
this._sendResponse({ seq: r, type: 301, data: o.message }), this._sendResponse({
|
|
278
|
+
seq: r,
|
|
279
|
+
type: 302
|
|
280
|
+
/* SUBSCRIBE_COMPLETE */
|
|
281
|
+
});
|
|
282
|
+
},
|
|
283
|
+
complete: () => {
|
|
284
|
+
this._sendResponse({
|
|
285
|
+
seq: r,
|
|
286
|
+
type: 302
|
|
287
|
+
/* SUBSCRIBE_COMPLETE */
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
});
|
|
291
|
+
this._subscriptions.set(e.seq, h);
|
|
292
|
+
} catch (c) {
|
|
293
|
+
c instanceof Error ? this._sendResponse({ seq: e.seq, type: 301, data: c.message }) : this._sendResponse({ seq: e.seq, type: 301, data: String(c) });
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
_onUnsubscribe(e) {
|
|
297
|
+
const n = this._subscriptions.get(e.seq);
|
|
298
|
+
n && (n.unsubscribe(), this._subscriptions.delete(e.seq));
|
|
299
|
+
}
|
|
300
|
+
_sendResponse(e) {
|
|
301
|
+
this._protocol.send(e);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
const I = k("IRPCChannelService");
|
|
305
|
+
class K {
|
|
306
|
+
constructor(t) {
|
|
307
|
+
a(this, "_client");
|
|
308
|
+
a(this, "_server");
|
|
309
|
+
this._client = new de(t), this._server = new pe(t);
|
|
310
|
+
}
|
|
311
|
+
dispose() {
|
|
312
|
+
this._client.dispose(), this._server.dispose();
|
|
313
|
+
}
|
|
314
|
+
requestChannel(t) {
|
|
315
|
+
return this._client.getChannel(t);
|
|
316
|
+
}
|
|
317
|
+
registerChannel(t, e) {
|
|
318
|
+
this._server.registerChannel(t, e);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
var ve = Object.getOwnPropertyDescriptor, me = (s, t, e, n) => {
|
|
322
|
+
for (var r = n > 1 ? void 0 : n ? ve(t, e) : t, i = s.length - 1, c; i >= 0; i--)
|
|
323
|
+
(c = s[i]) && (r = c(r) || r);
|
|
324
|
+
return r;
|
|
325
|
+
}, _ = (s, t) => (e, n) => t(e, n, s);
|
|
326
|
+
let y = class extends O {
|
|
327
|
+
constructor(t, e, n, r, i) {
|
|
328
|
+
super();
|
|
329
|
+
a(this, "_remoteInstanceService");
|
|
330
|
+
a(this, "_syncingUnits", /* @__PURE__ */ new Set());
|
|
331
|
+
a(this, "_syncingMutations", /* @__PURE__ */ new Set());
|
|
332
|
+
this._injector = t, this._commandService = e, this._univerInstanceService = n, this._rpcChannelService = r, this._remoteSyncService = i, this._initRPCChannels(), this._init();
|
|
333
|
+
}
|
|
334
|
+
registerSyncingMutations(t) {
|
|
335
|
+
this._syncingMutations.add(t.id);
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* Only spreadsheets would be synced to the web worker in normal situations. If you would like to
|
|
339
|
+
* sync other types of documents, you should manually call this method with that document's id.
|
|
340
|
+
*/
|
|
341
|
+
syncUnit(t) {
|
|
342
|
+
return this._syncingUnits.add(t), te(() => this._syncingUnits.delete(t));
|
|
343
|
+
}
|
|
344
|
+
_initRPCChannels() {
|
|
345
|
+
this._rpcChannelService.registerChannel(W, Y(this._remoteSyncService)), this._injector.add([
|
|
346
|
+
g,
|
|
347
|
+
{ useFactory: () => B(this._rpcChannelService.requestChannel($)) }
|
|
348
|
+
]), this._remoteInstanceService = this._injector.get(g);
|
|
349
|
+
}
|
|
350
|
+
_init() {
|
|
351
|
+
this._univerInstanceService.getTypeOfUnitAdded$(u.UNIVER_SHEET).pipe(v(this.dispose$)).subscribe((t) => {
|
|
352
|
+
this._syncingUnits.add(t.getUnitId()), this._remoteInstanceService.createInstance({
|
|
353
|
+
unitID: t.getUnitId(),
|
|
354
|
+
type: u.UNIVER_SHEET,
|
|
355
|
+
snapshot: t.getSnapshot()
|
|
356
|
+
});
|
|
357
|
+
}), this._univerInstanceService.getTypeOfUnitDisposed$(u.UNIVER_SHEET).pipe(v(this.dispose$)).subscribe((t) => {
|
|
358
|
+
this._syncingUnits.delete(t.getUnitId()), this._remoteInstanceService.disposeInstance({
|
|
359
|
+
unitID: t.getUnitId()
|
|
360
|
+
});
|
|
361
|
+
}), this.disposeWithMe(this._commandService.onCommandExecuted((t, e) => {
|
|
362
|
+
const { type: n, params: r, id: i } = t, c = (r == null ? void 0 : r.unitId) || "";
|
|
363
|
+
n === H.MUTATION && // only sync mutations to the worker thread
|
|
364
|
+
(!c || this._syncingUnits.has(c)) && // do not sync mutations from the web worker back to the web worker
|
|
365
|
+
!(e != null && e.fromSync) && // do not sync mutations those are not meant to be synced
|
|
366
|
+
this._syncingMutations.has(i) && this._remoteInstanceService.syncMutation({ mutationInfo: t });
|
|
367
|
+
}));
|
|
368
|
+
}
|
|
369
|
+
};
|
|
370
|
+
y = me([
|
|
371
|
+
_(0, b(R)),
|
|
372
|
+
_(1, C),
|
|
373
|
+
_(2, L),
|
|
374
|
+
_(3, I),
|
|
375
|
+
_(4, m)
|
|
376
|
+
], y);
|
|
377
|
+
var ge = Object.getOwnPropertyDescriptor, ye = (s, t, e, n) => {
|
|
378
|
+
for (var r = n > 1 ? void 0 : n ? ge(t, e) : t, i = s.length - 1, c; i >= 0; i--)
|
|
379
|
+
(c = s[i]) && (r = c(r) || r);
|
|
380
|
+
return r;
|
|
381
|
+
}, d = (s, t) => (e, n) => t(e, n, s);
|
|
382
|
+
let f = class extends ne {
|
|
383
|
+
constructor(t, e, n, r) {
|
|
384
|
+
super();
|
|
385
|
+
a(this, "_remoteSyncService");
|
|
386
|
+
this._injector = t, this._remoteInstanceService = e, this._commandService = n, this._rpcChannelService = r, this._initRPCChannels(), this._init();
|
|
387
|
+
}
|
|
388
|
+
_initRPCChannels() {
|
|
389
|
+
this._rpcChannelService.registerChannel($, Y(this._remoteInstanceService)), this._injector.add([
|
|
390
|
+
m,
|
|
391
|
+
{ useFactory: () => B(this._rpcChannelService.requestChannel(W)) }
|
|
392
|
+
]), this._remoteSyncService = this._injector.get(m);
|
|
393
|
+
}
|
|
394
|
+
_init() {
|
|
395
|
+
this.disposeWithMe(
|
|
396
|
+
// Mutations executed on the main thread should be synced to the worker thread.
|
|
397
|
+
this._commandService.onCommandExecuted((t, e) => {
|
|
398
|
+
t.type === H.MUTATION && !(e != null && e.fromSync) && this._remoteSyncService.syncMutation({
|
|
399
|
+
mutationInfo: t
|
|
400
|
+
});
|
|
401
|
+
})
|
|
402
|
+
);
|
|
403
|
+
}
|
|
404
|
+
};
|
|
405
|
+
f = ye([
|
|
406
|
+
d(0, b(R)),
|
|
407
|
+
d(1, g),
|
|
408
|
+
d(2, C),
|
|
409
|
+
d(3, I)
|
|
410
|
+
], f);
|
|
411
|
+
function fe() {
|
|
412
|
+
return {
|
|
413
|
+
send(s) {
|
|
414
|
+
postMessage(s);
|
|
415
|
+
},
|
|
416
|
+
onMessage: new T((s) => {
|
|
417
|
+
const t = (e) => {
|
|
418
|
+
s.next(e.data);
|
|
419
|
+
};
|
|
420
|
+
return addEventListener("message", t), () => removeEventListener("message", t);
|
|
421
|
+
}).pipe(z(1))
|
|
422
|
+
};
|
|
423
|
+
}
|
|
424
|
+
function Se(s) {
|
|
425
|
+
return {
|
|
426
|
+
send(t) {
|
|
427
|
+
s.postMessage(t);
|
|
428
|
+
},
|
|
429
|
+
onMessage: new T((t) => {
|
|
430
|
+
const e = (n) => {
|
|
431
|
+
t.next(n.data);
|
|
432
|
+
};
|
|
433
|
+
return s.addEventListener("message", e), () => s.removeEventListener("message", e);
|
|
434
|
+
}).pipe(z(1))
|
|
435
|
+
};
|
|
436
|
+
}
|
|
437
|
+
var Ce = Object.getOwnPropertyDescriptor, J = (s, t, e, n) => {
|
|
438
|
+
for (var r = n > 1 ? void 0 : n ? Ce(t, e) : t, i = s.length - 1, c; i >= 0; i--)
|
|
439
|
+
(c = s[i]) && (r = c(r) || r);
|
|
440
|
+
return r;
|
|
441
|
+
}, S = (s, t) => (e, n) => t(e, n, s), P;
|
|
442
|
+
let N = (P = class extends V {
|
|
443
|
+
constructor(t = j, e, n) {
|
|
444
|
+
super();
|
|
445
|
+
a(this, "_internalWorker", null);
|
|
446
|
+
this._config = t, this._injector = e, this._configService = n;
|
|
447
|
+
const { ...r } = F(
|
|
448
|
+
{},
|
|
449
|
+
j,
|
|
450
|
+
this._config
|
|
451
|
+
);
|
|
452
|
+
this._configService.setConfig(he, r);
|
|
453
|
+
}
|
|
454
|
+
dispose() {
|
|
455
|
+
super.dispose(), this._internalWorker && (this._internalWorker.terminate(), this._internalWorker = null);
|
|
456
|
+
}
|
|
457
|
+
onStarting() {
|
|
458
|
+
const { workerURL: t } = this._config;
|
|
459
|
+
if (!t)
|
|
460
|
+
throw new Error("[UniverRPCMainThreadPlugin]: The workerURL is required for the RPC main thread plugin.");
|
|
461
|
+
const e = t instanceof Worker ? t : new Worker(t);
|
|
462
|
+
this._internalWorker = t instanceof Worker ? null : e;
|
|
463
|
+
const n = Se(e);
|
|
464
|
+
[
|
|
465
|
+
[
|
|
466
|
+
I,
|
|
467
|
+
{
|
|
468
|
+
useFactory: () => new K(n)
|
|
469
|
+
}
|
|
470
|
+
],
|
|
471
|
+
[y],
|
|
472
|
+
[m, { useClass: M }]
|
|
473
|
+
].forEach((i) => this._injector.add(i)), this._injector.get(y);
|
|
474
|
+
}
|
|
475
|
+
}, a(P, "pluginName", "UNIVER_RPC_MAIN_THREAD_PLUGIN"), P);
|
|
476
|
+
N = J([
|
|
477
|
+
S(1, b(R)),
|
|
478
|
+
S(2, A)
|
|
479
|
+
], N);
|
|
480
|
+
var U;
|
|
481
|
+
let x = (U = class extends V {
|
|
482
|
+
constructor(s = D, t, e) {
|
|
483
|
+
super(), this._config = s, this._injector = t, this._configService = e;
|
|
484
|
+
const { ...n } = F(
|
|
485
|
+
{},
|
|
486
|
+
D,
|
|
487
|
+
this._config
|
|
488
|
+
);
|
|
489
|
+
this._configService.setConfig(le, n);
|
|
490
|
+
}
|
|
491
|
+
onStarting() {
|
|
492
|
+
[
|
|
493
|
+
[f],
|
|
494
|
+
[
|
|
495
|
+
I,
|
|
496
|
+
{
|
|
497
|
+
useFactory: () => new K(fe())
|
|
498
|
+
}
|
|
499
|
+
],
|
|
500
|
+
[g, { useClass: q }]
|
|
501
|
+
].forEach((s) => this._injector.add(s)), this._injector.get(f);
|
|
502
|
+
}
|
|
503
|
+
}, a(U, "pluginName", "UNIVER_RPC_WORKER_THREAD_PLUGIN"), U);
|
|
504
|
+
x = J([
|
|
505
|
+
S(1, b(R)),
|
|
506
|
+
S(2, A)
|
|
507
|
+
], x);
|
|
508
|
+
export {
|
|
509
|
+
de as ChannelClient,
|
|
510
|
+
pe as ChannelServer,
|
|
511
|
+
K as ChannelService,
|
|
512
|
+
y as DataSyncPrimaryController,
|
|
513
|
+
f as DataSyncReplicaController,
|
|
514
|
+
I as IRPCChannelService,
|
|
515
|
+
g as IRemoteInstanceService,
|
|
516
|
+
m as IRemoteSyncService,
|
|
517
|
+
$ as RemoteInstanceServiceName,
|
|
518
|
+
M as RemoteSyncPrimaryService,
|
|
519
|
+
W as RemoteSyncServiceName,
|
|
520
|
+
N as UniverRPCMainThreadPlugin,
|
|
521
|
+
x as UniverRPCWorkerThreadPlugin,
|
|
522
|
+
q as WebWorkerRemoteInstanceService,
|
|
523
|
+
Y as fromModule,
|
|
524
|
+
B as toModule
|
|
525
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/rpc",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.9",
|
|
4
4
|
"private": false,
|
|
5
5
|
"author": "DreamNum <developer@univer.ai>",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -47,14 +47,14 @@
|
|
|
47
47
|
"rxjs": ">=7.0.0"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@univerjs/core": "0.6.
|
|
50
|
+
"@univerjs/core": "0.6.9"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"rxjs": "^7.8.1",
|
|
54
54
|
"typescript": "^5.8.2",
|
|
55
55
|
"vite": "^6.2.3",
|
|
56
56
|
"vitest": "^3.0.9",
|
|
57
|
-
"@univerjs-infra/shared": "0.6.
|
|
57
|
+
"@univerjs-infra/shared": "0.6.9"
|
|
58
58
|
},
|
|
59
59
|
"scripts": {
|
|
60
60
|
"test": "vitest run",
|