@univerjs/rpc 0.1.0-alpha.2 → 0.1.0-beta.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/README.md +1 -1
- package/lib/cjs/index.js +1 -3
- package/lib/es/index.js +254 -1047
- package/lib/types/controllers/data-sync/data-sync-primary.controller.d.ts +2 -2
- package/lib/types/index.d.ts +1 -0
- package/lib/types/plugin.d.ts +0 -1
- package/lib/types/services/remote-instance/remote-instance.service.d.ts +7 -4
- package/lib/types/services/rpc/rpc.service.d.ts +1 -1
- package/lib/umd/index.js +1 -3
- package/package.json +6 -6
package/lib/es/index.js
CHANGED
|
@@ -1,954 +1,166 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import {
|
|
5
|
-
import { createIdentifier as
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
return
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
throw new TypeError("Unable to lift unknown Observable type");
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
var F = function(t, r) {
|
|
27
|
-
return F = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(e, n) {
|
|
28
|
-
e.__proto__ = n;
|
|
29
|
-
} || function(e, n) {
|
|
30
|
-
for (var s in n)
|
|
31
|
-
Object.prototype.hasOwnProperty.call(n, s) && (e[s] = n[s]);
|
|
32
|
-
}, F(t, r);
|
|
33
|
-
};
|
|
34
|
-
function X(t, r) {
|
|
35
|
-
if (typeof r != "function" && r !== null)
|
|
36
|
-
throw new TypeError("Class extends value " + String(r) + " is not a constructor or null");
|
|
37
|
-
F(t, r);
|
|
38
|
-
function e() {
|
|
39
|
-
this.constructor = t;
|
|
40
|
-
}
|
|
41
|
-
t.prototype = r === null ? Object.create(r) : (e.prototype = r.prototype, new e());
|
|
42
|
-
}
|
|
43
|
-
function je(t, r, e, n) {
|
|
44
|
-
function s(i) {
|
|
45
|
-
return i instanceof e ? i : new e(function(o) {
|
|
46
|
-
o(i);
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
return new (e || (e = Promise))(function(i, o) {
|
|
50
|
-
function a(l) {
|
|
51
|
-
try {
|
|
52
|
-
c(n.next(l));
|
|
53
|
-
} catch (v) {
|
|
54
|
-
o(v);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
function u(l) {
|
|
58
|
-
try {
|
|
59
|
-
c(n.throw(l));
|
|
60
|
-
} catch (v) {
|
|
61
|
-
o(v);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
function c(l) {
|
|
65
|
-
l.done ? i(l.value) : s(l.value).then(a, u);
|
|
66
|
-
}
|
|
67
|
-
c((n = n.apply(t, r || [])).next());
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
function ve(t, r) {
|
|
71
|
-
var e = { label: 0, sent: function() {
|
|
72
|
-
if (i[0] & 1)
|
|
73
|
-
throw i[1];
|
|
74
|
-
return i[1];
|
|
75
|
-
}, trys: [], ops: [] }, n, s, i, o;
|
|
76
|
-
return o = { next: a(0), throw: a(1), return: a(2) }, typeof Symbol == "function" && (o[Symbol.iterator] = function() {
|
|
77
|
-
return this;
|
|
78
|
-
}), o;
|
|
79
|
-
function a(c) {
|
|
80
|
-
return function(l) {
|
|
81
|
-
return u([c, l]);
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
function u(c) {
|
|
85
|
-
if (n)
|
|
86
|
-
throw new TypeError("Generator is already executing.");
|
|
87
|
-
for (; o && (o = 0, c[0] && (e = 0)), e; )
|
|
88
|
-
try {
|
|
89
|
-
if (n = 1, s && (i = c[0] & 2 ? s.return : c[0] ? s.throw || ((i = s.return) && i.call(s), 0) : s.next) && !(i = i.call(s, c[1])).done)
|
|
90
|
-
return i;
|
|
91
|
-
switch (s = 0, i && (c = [c[0] & 2, i.value]), c[0]) {
|
|
92
|
-
case 0:
|
|
93
|
-
case 1:
|
|
94
|
-
i = c;
|
|
95
|
-
break;
|
|
96
|
-
case 4:
|
|
97
|
-
return e.label++, { value: c[1], done: !1 };
|
|
98
|
-
case 5:
|
|
99
|
-
e.label++, s = c[1], c = [0];
|
|
100
|
-
continue;
|
|
101
|
-
case 7:
|
|
102
|
-
c = e.ops.pop(), e.trys.pop();
|
|
103
|
-
continue;
|
|
104
|
-
default:
|
|
105
|
-
if (i = e.trys, !(i = i.length > 0 && i[i.length - 1]) && (c[0] === 6 || c[0] === 2)) {
|
|
106
|
-
e = 0;
|
|
107
|
-
continue;
|
|
108
|
-
}
|
|
109
|
-
if (c[0] === 3 && (!i || c[1] > i[0] && c[1] < i[3])) {
|
|
110
|
-
e.label = c[1];
|
|
111
|
-
break;
|
|
112
|
-
}
|
|
113
|
-
if (c[0] === 6 && e.label < i[1]) {
|
|
114
|
-
e.label = i[1], i = c;
|
|
115
|
-
break;
|
|
116
|
-
}
|
|
117
|
-
if (i && e.label < i[2]) {
|
|
118
|
-
e.label = i[2], e.ops.push(c);
|
|
119
|
-
break;
|
|
120
|
-
}
|
|
121
|
-
i[2] && e.ops.pop(), e.trys.pop();
|
|
122
|
-
continue;
|
|
123
|
-
}
|
|
124
|
-
c = r.call(t, e);
|
|
125
|
-
} catch (l) {
|
|
126
|
-
c = [6, l], s = 0;
|
|
127
|
-
} finally {
|
|
128
|
-
n = i = 0;
|
|
129
|
-
}
|
|
130
|
-
if (c[0] & 5)
|
|
131
|
-
throw c[1];
|
|
132
|
-
return { value: c[0] ? c[1] : void 0, done: !0 };
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
function P(t) {
|
|
136
|
-
var r = typeof Symbol == "function" && Symbol.iterator, e = r && t[r], n = 0;
|
|
137
|
-
if (e)
|
|
138
|
-
return e.call(t);
|
|
139
|
-
if (t && typeof t.length == "number")
|
|
140
|
-
return {
|
|
141
|
-
next: function() {
|
|
142
|
-
return t && n >= t.length && (t = void 0), { value: t && t[n++], done: !t };
|
|
143
|
-
}
|
|
144
|
-
};
|
|
145
|
-
throw new TypeError(r ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
146
|
-
}
|
|
147
|
-
function C(t, r) {
|
|
148
|
-
var e = typeof Symbol == "function" && t[Symbol.iterator];
|
|
149
|
-
if (!e)
|
|
150
|
-
return t;
|
|
151
|
-
var n = e.call(t), s, i = [], o;
|
|
152
|
-
try {
|
|
153
|
-
for (; (r === void 0 || r-- > 0) && !(s = n.next()).done; )
|
|
154
|
-
i.push(s.value);
|
|
155
|
-
} catch (a) {
|
|
156
|
-
o = { error: a };
|
|
157
|
-
} finally {
|
|
158
|
-
try {
|
|
159
|
-
s && !s.done && (e = n.return) && e.call(n);
|
|
160
|
-
} finally {
|
|
161
|
-
if (o)
|
|
162
|
-
throw o.error;
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
return i;
|
|
166
|
-
}
|
|
167
|
-
function E(t, r, e) {
|
|
168
|
-
if (e || arguments.length === 2)
|
|
169
|
-
for (var n = 0, s = r.length, i; n < s; n++)
|
|
170
|
-
(i || !(n in r)) && (i || (i = Array.prototype.slice.call(r, 0, n)), i[n] = r[n]);
|
|
171
|
-
return t.concat(i || Array.prototype.slice.call(r));
|
|
172
|
-
}
|
|
173
|
-
function m(t) {
|
|
174
|
-
return this instanceof m ? (this.v = t, this) : new m(t);
|
|
175
|
-
}
|
|
176
|
-
function $e(t, r, e) {
|
|
177
|
-
if (!Symbol.asyncIterator)
|
|
178
|
-
throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
179
|
-
var n = e.apply(t, r || []), s, i = [];
|
|
180
|
-
return s = {}, o("next"), o("throw"), o("return"), s[Symbol.asyncIterator] = function() {
|
|
181
|
-
return this;
|
|
182
|
-
}, s;
|
|
183
|
-
function o(f) {
|
|
184
|
-
n[f] && (s[f] = function(y) {
|
|
185
|
-
return new Promise(function(_, p) {
|
|
186
|
-
i.push([f, y, _, p]) > 1 || a(f, y);
|
|
187
|
-
});
|
|
188
|
-
});
|
|
189
|
-
}
|
|
190
|
-
function a(f, y) {
|
|
191
|
-
try {
|
|
192
|
-
u(n[f](y));
|
|
193
|
-
} catch (_) {
|
|
194
|
-
v(i[0][3], _);
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
function u(f) {
|
|
198
|
-
f.value instanceof m ? Promise.resolve(f.value.v).then(c, l) : v(i[0][2], f);
|
|
199
|
-
}
|
|
200
|
-
function c(f) {
|
|
201
|
-
a("next", f);
|
|
202
|
-
}
|
|
203
|
-
function l(f) {
|
|
204
|
-
a("throw", f);
|
|
205
|
-
}
|
|
206
|
-
function v(f, y) {
|
|
207
|
-
f(y), i.shift(), i.length && a(i[0][0], i[0][1]);
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
function De(t) {
|
|
211
|
-
if (!Symbol.asyncIterator)
|
|
212
|
-
throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
213
|
-
var r = t[Symbol.asyncIterator], e;
|
|
214
|
-
return r ? r.call(t) : (t = typeof P == "function" ? P(t) : t[Symbol.iterator](), e = {}, n("next"), n("throw"), n("return"), e[Symbol.asyncIterator] = function() {
|
|
215
|
-
return this;
|
|
216
|
-
}, e);
|
|
217
|
-
function n(i) {
|
|
218
|
-
e[i] = t[i] && function(o) {
|
|
219
|
-
return new Promise(function(a, u) {
|
|
220
|
-
o = t[i](o), s(a, u, o.done, o.value);
|
|
221
|
-
});
|
|
222
|
-
};
|
|
223
|
-
}
|
|
224
|
-
function s(i, o, a, u) {
|
|
225
|
-
Promise.resolve(u).then(function(c) {
|
|
226
|
-
i({ value: c, done: a });
|
|
227
|
-
}, o);
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
var Le = function(t) {
|
|
231
|
-
return t && typeof t.length == "number" && typeof t != "function";
|
|
232
|
-
};
|
|
233
|
-
function Fe(t) {
|
|
234
|
-
return h(t == null ? void 0 : t.then);
|
|
235
|
-
}
|
|
236
|
-
function ke(t) {
|
|
237
|
-
var r = function(n) {
|
|
238
|
-
Error.call(n), n.stack = new Error().stack;
|
|
239
|
-
}, e = t(r);
|
|
240
|
-
return e.prototype = Object.create(Error.prototype), e.prototype.constructor = e, e;
|
|
241
|
-
}
|
|
242
|
-
var j = ke(function(t) {
|
|
243
|
-
return function(e) {
|
|
244
|
-
t(this), this.message = e ? e.length + ` errors occurred during unsubscription:
|
|
245
|
-
` + e.map(function(n, s) {
|
|
246
|
-
return s + 1 + ") " + n.toString();
|
|
247
|
-
}).join(`
|
|
248
|
-
`) : "", this.name = "UnsubscriptionError", this.errors = e;
|
|
249
|
-
};
|
|
250
|
-
});
|
|
251
|
-
function ne(t, r) {
|
|
252
|
-
if (t) {
|
|
253
|
-
var e = t.indexOf(r);
|
|
254
|
-
0 <= e && t.splice(e, 1);
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
var Z = function() {
|
|
258
|
-
function t(r) {
|
|
259
|
-
this.initialTeardown = r, this.closed = !1, this._parentage = null, this._finalizers = null;
|
|
260
|
-
}
|
|
261
|
-
return t.prototype.unsubscribe = function() {
|
|
262
|
-
var r, e, n, s, i;
|
|
263
|
-
if (!this.closed) {
|
|
264
|
-
this.closed = !0;
|
|
265
|
-
var o = this._parentage;
|
|
266
|
-
if (o)
|
|
267
|
-
if (this._parentage = null, Array.isArray(o))
|
|
268
|
-
try {
|
|
269
|
-
for (var a = P(o), u = a.next(); !u.done; u = a.next()) {
|
|
270
|
-
var c = u.value;
|
|
271
|
-
c.remove(this);
|
|
272
|
-
}
|
|
273
|
-
} catch (p) {
|
|
274
|
-
r = { error: p };
|
|
275
|
-
} finally {
|
|
276
|
-
try {
|
|
277
|
-
u && !u.done && (e = a.return) && e.call(a);
|
|
278
|
-
} finally {
|
|
279
|
-
if (r)
|
|
280
|
-
throw r.error;
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
else
|
|
284
|
-
o.remove(this);
|
|
285
|
-
var l = this.initialTeardown;
|
|
286
|
-
if (h(l))
|
|
287
|
-
try {
|
|
288
|
-
l();
|
|
289
|
-
} catch (p) {
|
|
290
|
-
i = p instanceof j ? p.errors : [p];
|
|
291
|
-
}
|
|
292
|
-
var v = this._finalizers;
|
|
293
|
-
if (v) {
|
|
294
|
-
this._finalizers = null;
|
|
295
|
-
try {
|
|
296
|
-
for (var f = P(v), y = f.next(); !y.done; y = f.next()) {
|
|
297
|
-
var _ = y.value;
|
|
298
|
-
try {
|
|
299
|
-
ie(_);
|
|
300
|
-
} catch (p) {
|
|
301
|
-
i = i ?? [], p instanceof j ? i = E(E([], C(i)), C(p.errors)) : i.push(p);
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
} catch (p) {
|
|
305
|
-
n = { error: p };
|
|
306
|
-
} finally {
|
|
307
|
-
try {
|
|
308
|
-
y && !y.done && (s = f.return) && s.call(f);
|
|
309
|
-
} finally {
|
|
310
|
-
if (n)
|
|
311
|
-
throw n.error;
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
if (i)
|
|
316
|
-
throw new j(i);
|
|
317
|
-
}
|
|
318
|
-
}, t.prototype.add = function(r) {
|
|
319
|
-
var e;
|
|
320
|
-
if (r && r !== this)
|
|
321
|
-
if (this.closed)
|
|
322
|
-
ie(r);
|
|
323
|
-
else {
|
|
324
|
-
if (r instanceof t) {
|
|
325
|
-
if (r.closed || r._hasParent(this))
|
|
326
|
-
return;
|
|
327
|
-
r._addParent(this);
|
|
328
|
-
}
|
|
329
|
-
(this._finalizers = (e = this._finalizers) !== null && e !== void 0 ? e : []).push(r);
|
|
330
|
-
}
|
|
331
|
-
}, t.prototype._hasParent = function(r) {
|
|
332
|
-
var e = this._parentage;
|
|
333
|
-
return e === r || Array.isArray(e) && e.includes(r);
|
|
334
|
-
}, t.prototype._addParent = function(r) {
|
|
335
|
-
var e = this._parentage;
|
|
336
|
-
this._parentage = Array.isArray(e) ? (e.push(r), e) : e ? [e, r] : r;
|
|
337
|
-
}, t.prototype._removeParent = function(r) {
|
|
338
|
-
var e = this._parentage;
|
|
339
|
-
e === r ? this._parentage = null : Array.isArray(e) && ne(e, r);
|
|
340
|
-
}, t.prototype.remove = function(r) {
|
|
341
|
-
var e = this._finalizers;
|
|
342
|
-
e && ne(e, r), r instanceof t && r._removeParent(this);
|
|
343
|
-
}, t.EMPTY = function() {
|
|
344
|
-
var r = new t();
|
|
345
|
-
return r.closed = !0, r;
|
|
346
|
-
}(), t;
|
|
347
|
-
}();
|
|
348
|
-
Z.EMPTY;
|
|
349
|
-
function be(t) {
|
|
350
|
-
return t instanceof Z || t && "closed" in t && h(t.remove) && h(t.add) && h(t.unsubscribe);
|
|
351
|
-
}
|
|
352
|
-
function ie(t) {
|
|
353
|
-
h(t) ? t() : t.unsubscribe();
|
|
354
|
-
}
|
|
355
|
-
var me = {
|
|
356
|
-
onUnhandledError: null,
|
|
357
|
-
onStoppedNotification: null,
|
|
358
|
-
Promise: void 0,
|
|
359
|
-
useDeprecatedSynchronousErrorHandling: !1,
|
|
360
|
-
useDeprecatedNextContext: !1
|
|
361
|
-
}, k = {
|
|
362
|
-
setTimeout: function(t, r) {
|
|
363
|
-
for (var e = [], n = 2; n < arguments.length; n++)
|
|
364
|
-
e[n - 2] = arguments[n];
|
|
365
|
-
var s = k.delegate;
|
|
366
|
-
return s != null && s.setTimeout ? s.setTimeout.apply(s, E([t, r], C(e))) : setTimeout.apply(void 0, E([t, r], C(e)));
|
|
367
|
-
},
|
|
368
|
-
clearTimeout: function(t) {
|
|
369
|
-
var r = k.delegate;
|
|
370
|
-
return ((r == null ? void 0 : r.clearTimeout) || clearTimeout)(t);
|
|
371
|
-
},
|
|
372
|
-
delegate: void 0
|
|
373
|
-
};
|
|
374
|
-
function _e(t) {
|
|
375
|
-
k.setTimeout(function() {
|
|
376
|
-
throw t;
|
|
377
|
-
});
|
|
378
|
-
}
|
|
379
|
-
function W() {
|
|
380
|
-
}
|
|
381
|
-
function We(t) {
|
|
382
|
-
t();
|
|
383
|
-
}
|
|
384
|
-
var K = function(t) {
|
|
385
|
-
X(r, t);
|
|
386
|
-
function r(e) {
|
|
387
|
-
var n = t.call(this) || this;
|
|
388
|
-
return n.isStopped = !1, e ? (n.destination = e, be(e) && e.add(n)) : n.destination = Ve, n;
|
|
389
|
-
}
|
|
390
|
-
return r.create = function(e, n, s) {
|
|
391
|
-
return new H(e, n, s);
|
|
392
|
-
}, r.prototype.next = function(e) {
|
|
393
|
-
this.isStopped || this._next(e);
|
|
394
|
-
}, r.prototype.error = function(e) {
|
|
395
|
-
this.isStopped || (this.isStopped = !0, this._error(e));
|
|
396
|
-
}, r.prototype.complete = function() {
|
|
397
|
-
this.isStopped || (this.isStopped = !0, this._complete());
|
|
398
|
-
}, r.prototype.unsubscribe = function() {
|
|
399
|
-
this.closed || (this.isStopped = !0, t.prototype.unsubscribe.call(this), this.destination = null);
|
|
400
|
-
}, r.prototype._next = function(e) {
|
|
401
|
-
this.destination.next(e);
|
|
402
|
-
}, r.prototype._error = function(e) {
|
|
403
|
-
try {
|
|
404
|
-
this.destination.error(e);
|
|
405
|
-
} finally {
|
|
406
|
-
this.unsubscribe();
|
|
407
|
-
}
|
|
408
|
-
}, r.prototype._complete = function() {
|
|
409
|
-
try {
|
|
410
|
-
this.destination.complete();
|
|
411
|
-
} finally {
|
|
412
|
-
this.unsubscribe();
|
|
413
|
-
}
|
|
414
|
-
}, r;
|
|
415
|
-
}(Z), He = Function.prototype.bind;
|
|
416
|
-
function $(t, r) {
|
|
417
|
-
return He.call(t, r);
|
|
418
|
-
}
|
|
419
|
-
var Ge = function() {
|
|
420
|
-
function t(r) {
|
|
421
|
-
this.partialObserver = r;
|
|
422
|
-
}
|
|
423
|
-
return t.prototype.next = function(r) {
|
|
424
|
-
var e = this.partialObserver;
|
|
425
|
-
if (e.next)
|
|
426
|
-
try {
|
|
427
|
-
e.next(r);
|
|
428
|
-
} catch (n) {
|
|
429
|
-
R(n);
|
|
430
|
-
}
|
|
431
|
-
}, t.prototype.error = function(r) {
|
|
432
|
-
var e = this.partialObserver;
|
|
433
|
-
if (e.error)
|
|
434
|
-
try {
|
|
435
|
-
e.error(r);
|
|
436
|
-
} catch (n) {
|
|
437
|
-
R(n);
|
|
438
|
-
}
|
|
439
|
-
else
|
|
440
|
-
R(r);
|
|
441
|
-
}, t.prototype.complete = function() {
|
|
442
|
-
var r = this.partialObserver;
|
|
443
|
-
if (r.complete)
|
|
444
|
-
try {
|
|
445
|
-
r.complete();
|
|
446
|
-
} catch (e) {
|
|
447
|
-
R(e);
|
|
448
|
-
}
|
|
449
|
-
}, t;
|
|
450
|
-
}(), H = function(t) {
|
|
451
|
-
X(r, t);
|
|
452
|
-
function r(e, n, s) {
|
|
453
|
-
var i = t.call(this) || this, o;
|
|
454
|
-
if (h(e) || !e)
|
|
455
|
-
o = {
|
|
456
|
-
next: e ?? void 0,
|
|
457
|
-
error: n ?? void 0,
|
|
458
|
-
complete: s ?? void 0
|
|
459
|
-
};
|
|
460
|
-
else {
|
|
461
|
-
var a;
|
|
462
|
-
i && me.useDeprecatedNextContext ? (a = Object.create(e), a.unsubscribe = function() {
|
|
463
|
-
return i.unsubscribe();
|
|
464
|
-
}, o = {
|
|
465
|
-
next: e.next && $(e.next, a),
|
|
466
|
-
error: e.error && $(e.error, a),
|
|
467
|
-
complete: e.complete && $(e.complete, a)
|
|
468
|
-
}) : o = e;
|
|
469
|
-
}
|
|
470
|
-
return i.destination = new Ge(o), i;
|
|
471
|
-
}
|
|
472
|
-
return r;
|
|
473
|
-
}(K);
|
|
474
|
-
function R(t) {
|
|
475
|
-
_e(t);
|
|
476
|
-
}
|
|
477
|
-
function Ye(t) {
|
|
478
|
-
throw t;
|
|
479
|
-
}
|
|
480
|
-
var Ve = {
|
|
481
|
-
closed: !0,
|
|
482
|
-
next: W,
|
|
483
|
-
error: Ye,
|
|
484
|
-
complete: W
|
|
485
|
-
}, N = function() {
|
|
486
|
-
return typeof Symbol == "function" && Symbol.observable || "@@observable";
|
|
487
|
-
}();
|
|
488
|
-
function ze(t) {
|
|
489
|
-
return t;
|
|
490
|
-
}
|
|
491
|
-
function Be(t) {
|
|
492
|
-
return t.length === 0 ? ze : t.length === 1 ? t[0] : function(e) {
|
|
493
|
-
return t.reduce(function(n, s) {
|
|
494
|
-
return s(n);
|
|
495
|
-
}, e);
|
|
496
|
-
};
|
|
497
|
-
}
|
|
498
|
-
var b = function() {
|
|
499
|
-
function t(r) {
|
|
500
|
-
r && (this._subscribe = r);
|
|
501
|
-
}
|
|
502
|
-
return t.prototype.lift = function(r) {
|
|
503
|
-
var e = new t();
|
|
504
|
-
return e.source = this, e.operator = r, e;
|
|
505
|
-
}, t.prototype.subscribe = function(r, e, n) {
|
|
506
|
-
var s = this, i = Qe(r) ? r : new H(r, e, n);
|
|
507
|
-
return We(function() {
|
|
508
|
-
var o = s, a = o.operator, u = o.source;
|
|
509
|
-
i.add(a ? a.call(i, u) : u ? s._subscribe(i) : s._trySubscribe(i));
|
|
510
|
-
}), i;
|
|
511
|
-
}, t.prototype._trySubscribe = function(r) {
|
|
512
|
-
try {
|
|
513
|
-
return this._subscribe(r);
|
|
514
|
-
} catch (e) {
|
|
515
|
-
r.error(e);
|
|
516
|
-
}
|
|
517
|
-
}, t.prototype.forEach = function(r, e) {
|
|
518
|
-
var n = this;
|
|
519
|
-
return e = se(e), new e(function(s, i) {
|
|
520
|
-
var o = new H({
|
|
521
|
-
next: function(a) {
|
|
522
|
-
try {
|
|
523
|
-
r(a);
|
|
524
|
-
} catch (u) {
|
|
525
|
-
i(u), o.unsubscribe();
|
|
526
|
-
}
|
|
527
|
-
},
|
|
528
|
-
error: i,
|
|
529
|
-
complete: s
|
|
530
|
-
});
|
|
531
|
-
n.subscribe(o);
|
|
532
|
-
});
|
|
533
|
-
}, t.prototype._subscribe = function(r) {
|
|
534
|
-
var e;
|
|
535
|
-
return (e = this.source) === null || e === void 0 ? void 0 : e.subscribe(r);
|
|
536
|
-
}, t.prototype[N] = function() {
|
|
537
|
-
return this;
|
|
538
|
-
}, t.prototype.pipe = function() {
|
|
539
|
-
for (var r = [], e = 0; e < arguments.length; e++)
|
|
540
|
-
r[e] = arguments[e];
|
|
541
|
-
return Be(r)(this);
|
|
542
|
-
}, t.prototype.toPromise = function(r) {
|
|
543
|
-
var e = this;
|
|
544
|
-
return r = se(r), new r(function(n, s) {
|
|
545
|
-
var i;
|
|
546
|
-
e.subscribe(function(o) {
|
|
547
|
-
return i = o;
|
|
548
|
-
}, function(o) {
|
|
549
|
-
return s(o);
|
|
550
|
-
}, function() {
|
|
551
|
-
return n(i);
|
|
552
|
-
});
|
|
553
|
-
});
|
|
554
|
-
}, t.create = function(r) {
|
|
555
|
-
return new t(r);
|
|
556
|
-
}, t;
|
|
557
|
-
}();
|
|
558
|
-
function se(t) {
|
|
559
|
-
var r;
|
|
560
|
-
return (r = t ?? me.Promise) !== null && r !== void 0 ? r : Promise;
|
|
561
|
-
}
|
|
562
|
-
function Je(t) {
|
|
563
|
-
return t && h(t.next) && h(t.error) && h(t.complete);
|
|
564
|
-
}
|
|
565
|
-
function Qe(t) {
|
|
566
|
-
return t && t instanceof K || Je(t) && be(t);
|
|
567
|
-
}
|
|
568
|
-
function Xe(t) {
|
|
569
|
-
return h(t[N]);
|
|
570
|
-
}
|
|
571
|
-
function Ze(t) {
|
|
572
|
-
return Symbol.asyncIterator && h(t == null ? void 0 : t[Symbol.asyncIterator]);
|
|
573
|
-
}
|
|
574
|
-
function Ke(t) {
|
|
575
|
-
return new TypeError("You provided " + (t !== null && typeof t == "object" ? "an invalid object" : "'" + t + "'") + " where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.");
|
|
576
|
-
}
|
|
577
|
-
function Ne() {
|
|
578
|
-
return typeof Symbol != "function" || !Symbol.iterator ? "@@iterator" : Symbol.iterator;
|
|
579
|
-
}
|
|
580
|
-
var et = Ne();
|
|
581
|
-
function tt(t) {
|
|
582
|
-
return h(t == null ? void 0 : t[et]);
|
|
583
|
-
}
|
|
584
|
-
function rt(t) {
|
|
585
|
-
return $e(this, arguments, function() {
|
|
586
|
-
var e, n, s, i;
|
|
587
|
-
return ve(this, function(o) {
|
|
588
|
-
switch (o.label) {
|
|
589
|
-
case 0:
|
|
590
|
-
e = t.getReader(), o.label = 1;
|
|
591
|
-
case 1:
|
|
592
|
-
o.trys.push([1, , 9, 10]), o.label = 2;
|
|
593
|
-
case 2:
|
|
594
|
-
return [4, m(e.read())];
|
|
595
|
-
case 3:
|
|
596
|
-
return n = o.sent(), s = n.value, i = n.done, i ? [4, m(void 0)] : [3, 5];
|
|
597
|
-
case 4:
|
|
598
|
-
return [2, o.sent()];
|
|
599
|
-
case 5:
|
|
600
|
-
return [4, m(s)];
|
|
601
|
-
case 6:
|
|
602
|
-
return [4, o.sent()];
|
|
603
|
-
case 7:
|
|
604
|
-
return o.sent(), [3, 2];
|
|
605
|
-
case 8:
|
|
606
|
-
return [3, 10];
|
|
607
|
-
case 9:
|
|
608
|
-
return e.releaseLock(), [7];
|
|
609
|
-
case 10:
|
|
610
|
-
return [2];
|
|
611
|
-
}
|
|
612
|
-
});
|
|
613
|
-
});
|
|
614
|
-
}
|
|
615
|
-
function nt(t) {
|
|
616
|
-
return h(t == null ? void 0 : t.getReader);
|
|
617
|
-
}
|
|
618
|
-
function it(t) {
|
|
619
|
-
if (t instanceof b)
|
|
620
|
-
return t;
|
|
621
|
-
if (t != null) {
|
|
622
|
-
if (Xe(t))
|
|
623
|
-
return st(t);
|
|
624
|
-
if (Le(t))
|
|
625
|
-
return ot(t);
|
|
626
|
-
if (Fe(t))
|
|
627
|
-
return ct(t);
|
|
628
|
-
if (Ze(t))
|
|
629
|
-
return Se(t);
|
|
630
|
-
if (tt(t))
|
|
631
|
-
return at(t);
|
|
632
|
-
if (nt(t))
|
|
633
|
-
return ut(t);
|
|
634
|
-
}
|
|
635
|
-
throw Ke(t);
|
|
636
|
-
}
|
|
637
|
-
function st(t) {
|
|
638
|
-
return new b(function(r) {
|
|
639
|
-
var e = t[N]();
|
|
640
|
-
if (h(e.subscribe))
|
|
641
|
-
return e.subscribe(r);
|
|
642
|
-
throw new TypeError("Provided object does not correctly implement Symbol.observable");
|
|
643
|
-
});
|
|
644
|
-
}
|
|
645
|
-
function ot(t) {
|
|
646
|
-
return new b(function(r) {
|
|
647
|
-
for (var e = 0; e < t.length && !r.closed; e++)
|
|
648
|
-
r.next(t[e]);
|
|
649
|
-
r.complete();
|
|
650
|
-
});
|
|
651
|
-
}
|
|
652
|
-
function ct(t) {
|
|
653
|
-
return new b(function(r) {
|
|
654
|
-
t.then(function(e) {
|
|
655
|
-
r.closed || (r.next(e), r.complete());
|
|
656
|
-
}, function(e) {
|
|
657
|
-
return r.error(e);
|
|
658
|
-
}).then(null, _e);
|
|
659
|
-
});
|
|
660
|
-
}
|
|
661
|
-
function at(t) {
|
|
662
|
-
return new b(function(r) {
|
|
663
|
-
var e, n;
|
|
664
|
-
try {
|
|
665
|
-
for (var s = P(t), i = s.next(); !i.done; i = s.next()) {
|
|
666
|
-
var o = i.value;
|
|
667
|
-
if (r.next(o), r.closed)
|
|
668
|
-
return;
|
|
669
|
-
}
|
|
670
|
-
} catch (a) {
|
|
671
|
-
e = { error: a };
|
|
672
|
-
} finally {
|
|
673
|
-
try {
|
|
674
|
-
i && !i.done && (n = s.return) && n.call(s);
|
|
675
|
-
} finally {
|
|
676
|
-
if (e)
|
|
677
|
-
throw e.error;
|
|
678
|
-
}
|
|
679
|
-
}
|
|
680
|
-
r.complete();
|
|
681
|
-
});
|
|
682
|
-
}
|
|
683
|
-
function Se(t) {
|
|
684
|
-
return new b(function(r) {
|
|
685
|
-
lt(t, r).catch(function(e) {
|
|
686
|
-
return r.error(e);
|
|
687
|
-
});
|
|
688
|
-
});
|
|
689
|
-
}
|
|
690
|
-
function ut(t) {
|
|
691
|
-
return Se(rt(t));
|
|
692
|
-
}
|
|
693
|
-
function lt(t, r) {
|
|
694
|
-
var e, n, s, i;
|
|
695
|
-
return je(this, void 0, void 0, function() {
|
|
696
|
-
var o, a;
|
|
697
|
-
return ve(this, function(u) {
|
|
698
|
-
switch (u.label) {
|
|
699
|
-
case 0:
|
|
700
|
-
u.trys.push([0, 5, 6, 11]), e = De(t), u.label = 1;
|
|
701
|
-
case 1:
|
|
702
|
-
return [4, e.next()];
|
|
703
|
-
case 2:
|
|
704
|
-
if (n = u.sent(), !!n.done)
|
|
705
|
-
return [3, 4];
|
|
706
|
-
if (o = n.value, r.next(o), r.closed)
|
|
707
|
-
return [2];
|
|
708
|
-
u.label = 3;
|
|
709
|
-
case 3:
|
|
710
|
-
return [3, 1];
|
|
711
|
-
case 4:
|
|
712
|
-
return [3, 11];
|
|
713
|
-
case 5:
|
|
714
|
-
return a = u.sent(), s = { error: a }, [3, 11];
|
|
715
|
-
case 6:
|
|
716
|
-
return u.trys.push([6, , 9, 10]), n && !n.done && (i = e.return) ? [4, i.call(e)] : [3, 8];
|
|
717
|
-
case 7:
|
|
718
|
-
u.sent(), u.label = 8;
|
|
719
|
-
case 8:
|
|
720
|
-
return [3, 10];
|
|
721
|
-
case 9:
|
|
722
|
-
if (s)
|
|
723
|
-
throw s.error;
|
|
724
|
-
return [7];
|
|
725
|
-
case 10:
|
|
726
|
-
return [7];
|
|
727
|
-
case 11:
|
|
728
|
-
return r.complete(), [2];
|
|
729
|
-
}
|
|
730
|
-
});
|
|
731
|
-
});
|
|
732
|
-
}
|
|
733
|
-
function ee(t, r, e, n, s) {
|
|
734
|
-
return new ft(t, r, e, n, s);
|
|
735
|
-
}
|
|
736
|
-
var ft = function(t) {
|
|
737
|
-
X(r, t);
|
|
738
|
-
function r(e, n, s, i, o, a) {
|
|
739
|
-
var u = t.call(this, e) || this;
|
|
740
|
-
return u.onFinalize = o, u.shouldUnsubscribe = a, u._next = n ? function(c) {
|
|
741
|
-
try {
|
|
742
|
-
n(c);
|
|
743
|
-
} catch (l) {
|
|
744
|
-
e.error(l);
|
|
745
|
-
}
|
|
746
|
-
} : t.prototype._next, u._error = i ? function(c) {
|
|
747
|
-
try {
|
|
748
|
-
i(c);
|
|
749
|
-
} catch (l) {
|
|
750
|
-
e.error(l);
|
|
751
|
-
} finally {
|
|
752
|
-
this.unsubscribe();
|
|
753
|
-
}
|
|
754
|
-
} : t.prototype._error, u._complete = s ? function() {
|
|
755
|
-
try {
|
|
756
|
-
s();
|
|
757
|
-
} catch (c) {
|
|
758
|
-
e.error(c);
|
|
759
|
-
} finally {
|
|
760
|
-
this.unsubscribe();
|
|
761
|
-
}
|
|
762
|
-
} : t.prototype._complete, u;
|
|
763
|
-
}
|
|
764
|
-
return r.prototype.unsubscribe = function() {
|
|
765
|
-
var e;
|
|
766
|
-
if (!this.shouldUnsubscribe || this.shouldUnsubscribe()) {
|
|
767
|
-
var n = this.closed;
|
|
768
|
-
t.prototype.unsubscribe.call(this), !n && ((e = this.onFinalize) === null || e === void 0 || e.call(this));
|
|
769
|
-
}
|
|
770
|
-
}, r;
|
|
771
|
-
}(K), ht = new b(function(t) {
|
|
772
|
-
return t.complete();
|
|
773
|
-
});
|
|
774
|
-
function pt(t) {
|
|
775
|
-
return t <= 0 ? function() {
|
|
776
|
-
return ht;
|
|
777
|
-
} : Q(function(r, e) {
|
|
778
|
-
var n = 0;
|
|
779
|
-
r.subscribe(ee(e, function(s) {
|
|
780
|
-
++n <= t && (e.next(s), t <= n && e.complete());
|
|
781
|
-
}));
|
|
782
|
-
});
|
|
783
|
-
}
|
|
784
|
-
function dt(t, r) {
|
|
785
|
-
return Q(function(e, n) {
|
|
786
|
-
var s = 0;
|
|
787
|
-
e.subscribe(ee(n, function(i) {
|
|
788
|
-
return t.call(r, i, s++) && n.next(i);
|
|
789
|
-
}));
|
|
790
|
-
});
|
|
791
|
-
}
|
|
792
|
-
function x(t) {
|
|
793
|
-
return Q(function(r, e) {
|
|
794
|
-
it(t).subscribe(ee(e, function() {
|
|
795
|
-
return e.complete();
|
|
796
|
-
}, W)), !e.closed && r.subscribe(e);
|
|
797
|
-
});
|
|
798
|
-
}
|
|
799
|
-
var yt = Object.defineProperty, vt = Object.getOwnPropertyDescriptor, we = (t, r, e, n) => {
|
|
800
|
-
for (var s = n > 1 ? void 0 : n ? vt(r, e) : r, i = t.length - 1, o; i >= 0; i--)
|
|
801
|
-
(o = t[i]) && (s = (n ? o(r, e, s) : o(s)) || s);
|
|
802
|
-
return n && s && yt(r, e, s), s;
|
|
803
|
-
}, G = (t, r) => (e, n) => r(e, n, t);
|
|
804
|
-
const te = "univer.remote-sync-service", O = B(te);
|
|
805
|
-
let Y = class {
|
|
806
|
-
constructor(t) {
|
|
807
|
-
this._commandService = t;
|
|
808
|
-
}
|
|
809
|
-
async syncMutation(t) {
|
|
810
|
-
return this._commandService.syncExecuteCommand(t.mutationInfo.id, t.mutationInfo.params, {
|
|
811
|
-
local: !0,
|
|
1
|
+
var Z = Object.defineProperty;
|
|
2
|
+
var K = (s, t, e) => t in s ? Z(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e;
|
|
3
|
+
var a = (s, t, e) => (K(s, typeof t != "symbol" ? t + "" : t, e), e);
|
|
4
|
+
import { UniverInstanceType as T, ICommandService as y, IUniverInstanceService as L, RxDisposable as M, OnLifecycle as W, LifecycleStages as N, CommandType as A, Disposable as k, Plugin as H, PluginType as F } from "@univerjs/core";
|
|
5
|
+
import { createIdentifier as O, Inject as S, Injector as b } from "@wendellhu/redi";
|
|
6
|
+
import { takeUntil as v, filter as ee, take as te } from "rxjs/operators";
|
|
7
|
+
import { BehaviorSubject as ne, firstValueFrom as se, Observable as $, isObservable as re, of as ie, shareReplay as z } from "rxjs";
|
|
8
|
+
var ce = Object.defineProperty, oe = Object.getOwnPropertyDescriptor, V = (s, t, e, n) => {
|
|
9
|
+
for (var r = n > 1 ? void 0 : n ? oe(t, e) : t, i = s.length - 1, c; i >= 0; i--)
|
|
10
|
+
(c = s[i]) && (r = (n ? c(t, e, r) : c(r)) || r);
|
|
11
|
+
return n && r && ce(t, e, r), r;
|
|
12
|
+
}, P = (s, t) => (e, n) => t(e, n, s);
|
|
13
|
+
const U = "univer.remote-sync-service", m = O(U);
|
|
14
|
+
let E = 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,
|
|
812
21
|
fromSync: !0
|
|
813
22
|
});
|
|
814
23
|
}
|
|
815
24
|
};
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
],
|
|
819
|
-
const
|
|
820
|
-
let
|
|
821
|
-
constructor(
|
|
822
|
-
this._univerInstanceService =
|
|
823
|
-
}
|
|
824
|
-
|
|
825
|
-
return
|
|
826
|
-
|
|
25
|
+
E = V([
|
|
26
|
+
P(0, y)
|
|
27
|
+
], E);
|
|
28
|
+
const D = "univer.remote-instance-service", f = O(D);
|
|
29
|
+
let q = class {
|
|
30
|
+
constructor(s, t) {
|
|
31
|
+
this._univerInstanceService = s, this._commandService = t;
|
|
32
|
+
}
|
|
33
|
+
whenReady() {
|
|
34
|
+
return Promise.resolve(!0);
|
|
35
|
+
}
|
|
36
|
+
async syncMutation(s) {
|
|
37
|
+
return this._commandService.syncExecuteCommand(s.mutationInfo.id, s.mutationInfo.params, {
|
|
38
|
+
onlyLocal: !0,
|
|
827
39
|
fromSync: !0
|
|
828
40
|
});
|
|
829
41
|
}
|
|
830
|
-
async createInstance(
|
|
831
|
-
const { type:
|
|
42
|
+
async createInstance(s) {
|
|
43
|
+
const { type: t, snapshot: e } = s;
|
|
832
44
|
try {
|
|
833
|
-
switch (
|
|
834
|
-
case
|
|
45
|
+
switch (t) {
|
|
46
|
+
case T.SHEET:
|
|
835
47
|
return !!this._univerInstanceService.createSheet(e);
|
|
836
48
|
default:
|
|
837
49
|
throw new Error(
|
|
838
|
-
`[RemoteInstanceReplicaService]: cannot create replica for document type: ${
|
|
50
|
+
`[RemoteInstanceReplicaService]: cannot create replica for document type: ${t}.`
|
|
839
51
|
);
|
|
840
52
|
}
|
|
841
53
|
} catch (n) {
|
|
842
54
|
throw n instanceof Error ? n : new Error(`${n}`);
|
|
843
55
|
}
|
|
844
56
|
}
|
|
845
|
-
async disposeInstance(
|
|
846
|
-
return this._univerInstanceService.disposeDocument(
|
|
57
|
+
async disposeInstance(s) {
|
|
58
|
+
return this._univerInstanceService.disposeDocument(s.unitID);
|
|
847
59
|
}
|
|
848
60
|
};
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
],
|
|
853
|
-
function
|
|
854
|
-
const
|
|
61
|
+
q = V([
|
|
62
|
+
P(0, L),
|
|
63
|
+
P(1, y)
|
|
64
|
+
], q);
|
|
65
|
+
function G(s) {
|
|
66
|
+
const t = s;
|
|
855
67
|
return new class {
|
|
856
68
|
call(e, n) {
|
|
857
|
-
const
|
|
858
|
-
if (typeof
|
|
859
|
-
let i =
|
|
69
|
+
const r = t[e];
|
|
70
|
+
if (typeof r == "function") {
|
|
71
|
+
let i = r.apply(t, [n]);
|
|
860
72
|
return i instanceof Promise || (i = Promise.resolve(i)), i;
|
|
861
73
|
}
|
|
862
74
|
throw new Error(`[RPC]: method not found for ${e}!`);
|
|
863
75
|
}
|
|
864
76
|
subscribe(e, n) {
|
|
865
|
-
const
|
|
866
|
-
if (typeof
|
|
867
|
-
const i =
|
|
868
|
-
return
|
|
77
|
+
const r = t[e];
|
|
78
|
+
if (typeof r == "function") {
|
|
79
|
+
const i = r.apply(t, n);
|
|
80
|
+
return re(i) ? i : ie(i);
|
|
869
81
|
}
|
|
870
82
|
throw new Error(`[RPC]: observable method not found for ${e}!`);
|
|
871
83
|
}
|
|
872
84
|
}();
|
|
873
85
|
}
|
|
874
|
-
function
|
|
86
|
+
function B(s) {
|
|
875
87
|
return new Proxy({}, {
|
|
876
|
-
get(
|
|
88
|
+
get(t, e) {
|
|
877
89
|
return function(...n) {
|
|
878
|
-
return
|
|
90
|
+
return ae(e) ? s.subscribe(e, n[0]) : s.call(e, n[0]);
|
|
879
91
|
};
|
|
880
92
|
}
|
|
881
93
|
});
|
|
882
94
|
}
|
|
883
|
-
function
|
|
884
|
-
return
|
|
95
|
+
function ae(s) {
|
|
96
|
+
return s.endsWith("$");
|
|
885
97
|
}
|
|
886
|
-
class
|
|
98
|
+
class he extends M {
|
|
887
99
|
constructor(e) {
|
|
888
100
|
super();
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
this._protocol = e, this._protocol.onMessage.pipe(
|
|
101
|
+
a(this, "_initialized", new ne(!1));
|
|
102
|
+
a(this, "_lastRequestCounter", 0);
|
|
103
|
+
a(this, "_pendingRequests", /* @__PURE__ */ new Map());
|
|
104
|
+
a(this, "_pendingSubscriptions", /* @__PURE__ */ new Map());
|
|
105
|
+
this._protocol = e, this._protocol.onMessage.pipe(v(this.dispose$)).subscribe((n) => this._onMessage(n));
|
|
894
106
|
}
|
|
895
107
|
getChannel(e) {
|
|
896
108
|
const n = this;
|
|
897
109
|
return {
|
|
898
|
-
call(
|
|
899
|
-
return n._disposed ? Promise.reject() : n._remoteCall(e,
|
|
110
|
+
call(r, i) {
|
|
111
|
+
return n._disposed ? Promise.reject() : n._remoteCall(e, r, i);
|
|
900
112
|
},
|
|
901
|
-
subscribe(
|
|
113
|
+
subscribe(r, i) {
|
|
902
114
|
if (n._disposed)
|
|
903
115
|
throw new Error("[ChannelClient]: client is disposed!");
|
|
904
|
-
return n._remoteSubscribe(e,
|
|
116
|
+
return n._remoteSubscribe(e, r, i);
|
|
905
117
|
}
|
|
906
118
|
};
|
|
907
119
|
}
|
|
908
120
|
_whenReady() {
|
|
909
|
-
return
|
|
121
|
+
return se(
|
|
910
122
|
this._initialized.pipe(
|
|
911
|
-
|
|
912
|
-
|
|
123
|
+
ee((e) => e),
|
|
124
|
+
te(1)
|
|
913
125
|
)
|
|
914
126
|
);
|
|
915
127
|
}
|
|
916
|
-
async _remoteCall(e, n,
|
|
128
|
+
async _remoteCall(e, n, r) {
|
|
917
129
|
await this._whenReady();
|
|
918
|
-
const i = ++this._lastRequestCounter,
|
|
919
|
-
return new Promise((
|
|
920
|
-
const
|
|
921
|
-
handle(
|
|
922
|
-
switch (
|
|
923
|
-
case
|
|
924
|
-
|
|
130
|
+
const i = ++this._lastRequestCounter, h = { seq: i, type: 100, channelName: e, method: n, args: r }, o = this;
|
|
131
|
+
return new Promise((g, l) => {
|
|
132
|
+
const Y = {
|
|
133
|
+
handle(R) {
|
|
134
|
+
switch (R.type) {
|
|
135
|
+
case 201:
|
|
136
|
+
o._pendingRequests.delete(i), g(R.data);
|
|
925
137
|
break;
|
|
926
|
-
case
|
|
927
|
-
|
|
138
|
+
case 202:
|
|
139
|
+
o._pendingRequests.delete(i), l(R.data);
|
|
928
140
|
break;
|
|
929
141
|
default:
|
|
930
142
|
throw new Error("[ChannelClient]: unknown response type!");
|
|
931
143
|
}
|
|
932
144
|
}
|
|
933
145
|
};
|
|
934
|
-
this._pendingRequests.set(i,
|
|
146
|
+
this._pendingRequests.set(i, Y), this._sendRequest(h);
|
|
935
147
|
});
|
|
936
148
|
}
|
|
937
|
-
_remoteSubscribe(e, n,
|
|
938
|
-
return new
|
|
939
|
-
let
|
|
149
|
+
_remoteSubscribe(e, n, r) {
|
|
150
|
+
return new $((i) => {
|
|
151
|
+
let c = -1;
|
|
940
152
|
return this._whenReady().then(() => {
|
|
941
|
-
|
|
942
|
-
const
|
|
153
|
+
c = ++this._lastRequestCounter;
|
|
154
|
+
const o = { seq: c, type: 101, channelName: e, method: n, args: r }, g = {
|
|
943
155
|
handle(l) {
|
|
944
156
|
switch (l.type) {
|
|
945
|
-
case
|
|
157
|
+
case 300:
|
|
946
158
|
i.next(l.data);
|
|
947
159
|
break;
|
|
948
|
-
case
|
|
160
|
+
case 301:
|
|
949
161
|
i.error(l.data);
|
|
950
162
|
break;
|
|
951
|
-
case
|
|
163
|
+
case 302:
|
|
952
164
|
i.complete();
|
|
953
165
|
break;
|
|
954
166
|
default:
|
|
@@ -956,45 +168,45 @@ class mt extends z {
|
|
|
956
168
|
}
|
|
957
169
|
}
|
|
958
170
|
};
|
|
959
|
-
this._pendingRequests.set(
|
|
171
|
+
this._pendingRequests.set(c, g), this._sendRequest(o);
|
|
960
172
|
}), () => {
|
|
961
|
-
if (
|
|
173
|
+
if (c === -1)
|
|
962
174
|
return;
|
|
963
|
-
const
|
|
175
|
+
const h = {
|
|
964
176
|
type: 102,
|
|
965
|
-
seq:
|
|
177
|
+
seq: c,
|
|
966
178
|
channelName: e,
|
|
967
179
|
method: n
|
|
968
180
|
};
|
|
969
|
-
this._sendRequest(
|
|
181
|
+
this._sendRequest(h);
|
|
970
182
|
};
|
|
971
183
|
});
|
|
972
184
|
}
|
|
973
185
|
_sendRequest(e) {
|
|
974
186
|
this._protocol.send(e);
|
|
975
187
|
}
|
|
976
|
-
|
|
188
|
+
_onMessage(e) {
|
|
977
189
|
var n;
|
|
978
190
|
switch (e.type) {
|
|
979
191
|
case 0:
|
|
980
192
|
this._initialized.next(!0);
|
|
981
193
|
break;
|
|
982
|
-
case 100:
|
|
983
|
-
case 101:
|
|
984
|
-
case 200:
|
|
985
|
-
case 202:
|
|
986
194
|
case 201:
|
|
195
|
+
case 202:
|
|
196
|
+
case 300:
|
|
197
|
+
case 302:
|
|
198
|
+
case 301:
|
|
987
199
|
(n = this._pendingRequests.get(e.seq)) == null || n.handle(e);
|
|
988
200
|
break;
|
|
989
201
|
}
|
|
990
202
|
}
|
|
991
203
|
}
|
|
992
|
-
class
|
|
204
|
+
class le extends M {
|
|
993
205
|
constructor(e) {
|
|
994
206
|
super();
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
this._protocol = e, this._protocol.onMessage.pipe(
|
|
207
|
+
a(this, "_channels", /* @__PURE__ */ new Map());
|
|
208
|
+
a(this, "_subscriptions", /* @__PURE__ */ new Map());
|
|
209
|
+
this._protocol = e, this._protocol.onMessage.pipe(v(this.dispose$)).subscribe((n) => this._onRequest(n)), this._sendResponse({
|
|
998
210
|
seq: -1,
|
|
999
211
|
type: 0
|
|
1000
212
|
/* INITIALIZE */
|
|
@@ -1017,48 +229,48 @@ class _t extends z {
|
|
|
1017
229
|
}
|
|
1018
230
|
}
|
|
1019
231
|
_onMethodCall(e) {
|
|
1020
|
-
const n = this._channels.get(
|
|
1021
|
-
let
|
|
232
|
+
const { channelName: n, method: r, args: i } = e, c = this._channels.get(n);
|
|
233
|
+
let h;
|
|
1022
234
|
try {
|
|
1023
|
-
if (!
|
|
1024
|
-
throw new Error(
|
|
1025
|
-
|
|
1026
|
-
} catch (
|
|
1027
|
-
|
|
235
|
+
if (!c)
|
|
236
|
+
throw new Error(`[ChannelServer]: Channel ${n} not found!`);
|
|
237
|
+
h = c.call(r, i);
|
|
238
|
+
} catch (o) {
|
|
239
|
+
h = Promise.reject(o);
|
|
1028
240
|
}
|
|
1029
|
-
|
|
1030
|
-
this._sendResponse({ seq: e.seq, type:
|
|
1031
|
-
}).catch((
|
|
1032
|
-
|
|
241
|
+
h.then((o) => {
|
|
242
|
+
this._sendResponse({ seq: e.seq, type: 201, data: o });
|
|
243
|
+
}).catch((o) => {
|
|
244
|
+
o instanceof Error ? this._sendResponse({ seq: e.seq, type: 202, data: o.message }) : this._sendResponse({ seq: e.seq, type: 202, data: String(o) });
|
|
1033
245
|
});
|
|
1034
246
|
}
|
|
1035
247
|
_onSubscribe(e) {
|
|
1036
|
-
const n = this._channels.get(
|
|
248
|
+
const { channelName: n, seq: r } = e, i = this._channels.get(n);
|
|
1037
249
|
try {
|
|
1038
|
-
if (!
|
|
1039
|
-
throw new Error(
|
|
1040
|
-
const
|
|
250
|
+
if (!i)
|
|
251
|
+
throw new Error(`[ChannelServer]: Channel ${n} not found!`);
|
|
252
|
+
const h = i.subscribe(e.method, e.args).subscribe({
|
|
1041
253
|
next: (o) => {
|
|
1042
|
-
this._sendResponse({ seq:
|
|
254
|
+
this._sendResponse({ seq: r, type: 300, data: o });
|
|
1043
255
|
},
|
|
1044
256
|
error: (o) => {
|
|
1045
|
-
this._sendResponse({ seq:
|
|
1046
|
-
seq:
|
|
1047
|
-
type:
|
|
257
|
+
this._sendResponse({ seq: r, type: 301, data: o.message }), this._sendResponse({
|
|
258
|
+
seq: r,
|
|
259
|
+
type: 302
|
|
1048
260
|
/* SUBSCRIBE_COMPLETE */
|
|
1049
261
|
});
|
|
1050
262
|
},
|
|
1051
263
|
complete: () => {
|
|
1052
264
|
this._sendResponse({
|
|
1053
|
-
seq:
|
|
1054
|
-
type:
|
|
265
|
+
seq: r,
|
|
266
|
+
type: 302
|
|
1055
267
|
/* SUBSCRIBE_COMPLETE */
|
|
1056
268
|
});
|
|
1057
269
|
}
|
|
1058
270
|
});
|
|
1059
|
-
this._subscriptions.set(e.seq,
|
|
1060
|
-
} catch (
|
|
1061
|
-
|
|
271
|
+
this._subscriptions.set(e.seq, h);
|
|
272
|
+
} catch (c) {
|
|
273
|
+
c instanceof Error ? this._sendResponse({ seq: e.seq, type: 301, data: c.message }) : this._sendResponse({ seq: e.seq, type: 301, data: String(c) });
|
|
1062
274
|
}
|
|
1063
275
|
}
|
|
1064
276
|
_onUnsubscribe(e) {
|
|
@@ -1069,190 +281,185 @@ class _t extends z {
|
|
|
1069
281
|
this._protocol.send(e);
|
|
1070
282
|
}
|
|
1071
283
|
}
|
|
1072
|
-
const
|
|
1073
|
-
class
|
|
1074
|
-
constructor(
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
this._client = new
|
|
284
|
+
const C = O("IRPChannelService");
|
|
285
|
+
class J {
|
|
286
|
+
constructor(t) {
|
|
287
|
+
a(this, "_client");
|
|
288
|
+
a(this, "_server");
|
|
289
|
+
this._client = new he(t), this._server = new le(t);
|
|
1078
290
|
}
|
|
1079
|
-
requestChannel(
|
|
1080
|
-
return this._client.getChannel(
|
|
291
|
+
requestChannel(t) {
|
|
292
|
+
return this._client.getChannel(t);
|
|
1081
293
|
}
|
|
1082
|
-
registerChannel(
|
|
1083
|
-
this._server.registerChannel(
|
|
294
|
+
registerChannel(t, e) {
|
|
295
|
+
this._server.registerChannel(t, e);
|
|
1084
296
|
}
|
|
1085
297
|
}
|
|
1086
|
-
var
|
|
1087
|
-
for (var
|
|
1088
|
-
(
|
|
1089
|
-
return n &&
|
|
1090
|
-
},
|
|
1091
|
-
let
|
|
1092
|
-
constructor(
|
|
298
|
+
var _e = Object.defineProperty, ue = Object.getOwnPropertyDescriptor, pe = (s, t, e, n) => {
|
|
299
|
+
for (var r = n > 1 ? void 0 : n ? ue(t, e) : t, i = s.length - 1, c; i >= 0; i--)
|
|
300
|
+
(c = s[i]) && (r = (n ? c(t, e, r) : c(r)) || r);
|
|
301
|
+
return n && r && _e(t, e, r), r;
|
|
302
|
+
}, _ = (s, t) => (e, n) => t(e, n, s);
|
|
303
|
+
let u = class extends M {
|
|
304
|
+
constructor(t, e, n, r, i) {
|
|
1093
305
|
super();
|
|
1094
|
-
|
|
1095
|
-
this
|
|
306
|
+
a(this, "_remoteInstanceService");
|
|
307
|
+
a(this, "_syncingUnits", /* @__PURE__ */ new Set());
|
|
308
|
+
this._injector = t, this._commandService = e, this._univerInstanceService = n, this._rpcChannelService = r, this._remoteSyncService = i, this._initRPCChannels(), this._init();
|
|
1096
309
|
}
|
|
1097
310
|
_initRPCChannels() {
|
|
1098
|
-
this._rpcChannelService.registerChannel(
|
|
1099
|
-
|
|
311
|
+
this._rpcChannelService.registerChannel(U, G(this._remoteSyncService)), this._injector.add([
|
|
312
|
+
f,
|
|
1100
313
|
{
|
|
1101
|
-
useFactory: () =>
|
|
314
|
+
useFactory: () => B(this._rpcChannelService.requestChannel(D))
|
|
1102
315
|
}
|
|
1103
|
-
]), this._remoteInstanceService = this._injector.get(
|
|
316
|
+
]), this._remoteInstanceService = this._injector.get(f);
|
|
1104
317
|
}
|
|
1105
318
|
_init() {
|
|
1106
|
-
this._univerInstanceService.sheetAdded$.pipe(
|
|
1107
|
-
this._remoteInstanceService.createInstance({
|
|
1108
|
-
unitID:
|
|
1109
|
-
type:
|
|
1110
|
-
snapshot:
|
|
319
|
+
this._univerInstanceService.sheetAdded$.pipe(v(this.dispose$)).subscribe((t) => {
|
|
320
|
+
this._syncingUnits.add(t.getUnitId()), this._remoteInstanceService.createInstance({
|
|
321
|
+
unitID: t.getUnitId(),
|
|
322
|
+
type: T.SHEET,
|
|
323
|
+
snapshot: t.getSnapshot()
|
|
1111
324
|
});
|
|
1112
|
-
}), this._univerInstanceService.sheetDisposed$.pipe(
|
|
1113
|
-
this._remoteInstanceService.disposeInstance({
|
|
1114
|
-
unitID:
|
|
325
|
+
}), this._univerInstanceService.sheetDisposed$.pipe(v(this.dispose$)).subscribe((t) => {
|
|
326
|
+
this._syncingUnits.delete(t.getUnitId()), this._remoteInstanceService.disposeInstance({
|
|
327
|
+
unitID: t.getUnitId()
|
|
1115
328
|
});
|
|
1116
329
|
}), this.disposeWithMe(
|
|
1117
330
|
// Mutations executed on the main thread should be synced to the worker thread.
|
|
1118
|
-
this._commandService.onCommandExecuted((
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
331
|
+
this._commandService.onCommandExecuted((t, e) => {
|
|
332
|
+
const { type: n, params: r } = t, i = (r == null ? void 0 : r.unitId) || "";
|
|
333
|
+
// only sync mutations to the worker thread
|
|
334
|
+
n === A.MUTATION && (!i || this._syncingUnits.has(i)) && // do not sync mutations from the web worker back to the web worker
|
|
335
|
+
!(e != null && e.fromSync) && this._remoteInstanceService.syncMutation({ mutationInfo: t });
|
|
1122
336
|
})
|
|
1123
337
|
);
|
|
1124
338
|
}
|
|
1125
339
|
};
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
],
|
|
1134
|
-
var
|
|
1135
|
-
for (var
|
|
1136
|
-
(
|
|
1137
|
-
return n &&
|
|
1138
|
-
},
|
|
1139
|
-
let
|
|
1140
|
-
constructor(
|
|
340
|
+
u = pe([
|
|
341
|
+
W(N.Starting, u),
|
|
342
|
+
_(0, S(b)),
|
|
343
|
+
_(1, y),
|
|
344
|
+
_(2, L),
|
|
345
|
+
_(3, C),
|
|
346
|
+
_(4, m)
|
|
347
|
+
], u);
|
|
348
|
+
var de = Object.defineProperty, ve = Object.getOwnPropertyDescriptor, me = (s, t, e, n) => {
|
|
349
|
+
for (var r = n > 1 ? void 0 : n ? ve(t, e) : t, i = s.length - 1, c; i >= 0; i--)
|
|
350
|
+
(c = s[i]) && (r = (n ? c(t, e, r) : c(r)) || r);
|
|
351
|
+
return n && r && de(t, e, r), r;
|
|
352
|
+
}, d = (s, t) => (e, n) => t(e, n, s);
|
|
353
|
+
let p = class extends k {
|
|
354
|
+
constructor(t, e, n, r) {
|
|
1141
355
|
super();
|
|
1142
|
-
|
|
1143
|
-
this._injector =
|
|
356
|
+
a(this, "_remoteSyncService");
|
|
357
|
+
this._injector = t, this._remoteInstanceService = e, this._commandService = n, this._rpcChannelService = r, this._initRPCChannels(), this._init();
|
|
1144
358
|
}
|
|
1145
359
|
_initRPCChannels() {
|
|
1146
|
-
this._rpcChannelService.registerChannel(
|
|
1147
|
-
|
|
360
|
+
this._rpcChannelService.registerChannel(D, G(this._remoteInstanceService)), this._injector.add([
|
|
361
|
+
m,
|
|
1148
362
|
{
|
|
1149
|
-
useFactory: () =>
|
|
363
|
+
useFactory: () => B(this._rpcChannelService.requestChannel(U))
|
|
1150
364
|
}
|
|
1151
|
-
]), this._remoteSyncService = this._injector.get(
|
|
365
|
+
]), this._remoteSyncService = this._injector.get(m);
|
|
1152
366
|
}
|
|
1153
367
|
_init() {
|
|
1154
368
|
this.disposeWithMe(
|
|
1155
369
|
// Mutations executed on the main thread should be synced to the worker thread.
|
|
1156
|
-
this._commandService.onCommandExecuted((
|
|
1157
|
-
|
|
1158
|
-
mutationInfo:
|
|
370
|
+
this._commandService.onCommandExecuted((t, e) => {
|
|
371
|
+
t.type === A.MUTATION && !(e != null && e.fromSync) && this._remoteSyncService.syncMutation({
|
|
372
|
+
mutationInfo: t
|
|
1159
373
|
});
|
|
1160
374
|
})
|
|
1161
375
|
);
|
|
1162
376
|
}
|
|
1163
377
|
};
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
],
|
|
1171
|
-
function
|
|
378
|
+
p = me([
|
|
379
|
+
W(N.Starting, p),
|
|
380
|
+
d(0, S(b)),
|
|
381
|
+
d(1, f),
|
|
382
|
+
d(2, y),
|
|
383
|
+
d(3, C)
|
|
384
|
+
], p);
|
|
385
|
+
function fe() {
|
|
1172
386
|
return {
|
|
1173
|
-
send(
|
|
1174
|
-
postMessage(
|
|
387
|
+
send(s) {
|
|
388
|
+
postMessage(s);
|
|
1175
389
|
},
|
|
1176
|
-
onMessage: new
|
|
1177
|
-
const
|
|
1178
|
-
|
|
390
|
+
onMessage: new $((s) => {
|
|
391
|
+
const t = (e) => {
|
|
392
|
+
s.next(e.data);
|
|
1179
393
|
};
|
|
1180
|
-
return addEventListener("message",
|
|
1181
|
-
}).pipe(
|
|
394
|
+
return addEventListener("message", t), () => removeEventListener("message", t);
|
|
395
|
+
}).pipe(z(1))
|
|
1182
396
|
};
|
|
1183
397
|
}
|
|
1184
|
-
function
|
|
398
|
+
function ye(s) {
|
|
1185
399
|
return {
|
|
1186
|
-
send(
|
|
1187
|
-
|
|
400
|
+
send(t) {
|
|
401
|
+
s.postMessage(t);
|
|
1188
402
|
},
|
|
1189
|
-
onMessage: new
|
|
403
|
+
onMessage: new $((t) => {
|
|
1190
404
|
const e = (n) => {
|
|
1191
|
-
|
|
405
|
+
t.next(n.data);
|
|
1192
406
|
};
|
|
1193
|
-
return
|
|
1194
|
-
}).pipe(
|
|
407
|
+
return s.addEventListener("message", e), () => s.removeEventListener("message", e);
|
|
408
|
+
}).pipe(z(1))
|
|
1195
409
|
};
|
|
1196
410
|
}
|
|
1197
|
-
var
|
|
1198
|
-
for (var
|
|
1199
|
-
(
|
|
1200
|
-
return n &&
|
|
1201
|
-
},
|
|
1202
|
-
let
|
|
1203
|
-
constructor(
|
|
1204
|
-
super("UNIVER_RPC_MAIN_THREAD_PLUGIN"), this._config =
|
|
1205
|
-
}
|
|
1206
|
-
async onStarting(
|
|
1207
|
-
const
|
|
411
|
+
var Se = Object.defineProperty, be = Object.getOwnPropertyDescriptor, Q = (s, t, e, n) => {
|
|
412
|
+
for (var r = n > 1 ? void 0 : n ? be(t, e) : t, i = s.length - 1, c; i >= 0; i--)
|
|
413
|
+
(c = s[i]) && (r = (n ? c(t, e, r) : c(r)) || r);
|
|
414
|
+
return n && r && Se(t, e, r), r;
|
|
415
|
+
}, X = (s, t) => (e, n) => t(e, n, s), w;
|
|
416
|
+
let j = (w = class extends H {
|
|
417
|
+
constructor(s, t) {
|
|
418
|
+
super("UNIVER_RPC_MAIN_THREAD_PLUGIN"), this._config = s, this._injector = t;
|
|
419
|
+
}
|
|
420
|
+
async onStarting(s) {
|
|
421
|
+
const t = new Worker(this._config.workerURL), e = ye(t);
|
|
1208
422
|
[
|
|
1209
423
|
[
|
|
1210
|
-
|
|
424
|
+
C,
|
|
1211
425
|
{
|
|
1212
|
-
useFactory: () => new
|
|
426
|
+
useFactory: () => new J(e)
|
|
1213
427
|
}
|
|
1214
428
|
],
|
|
1215
|
-
[
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
}
|
|
1228
|
-
|
|
1229
|
-
Ce(1, q(A))
|
|
1230
|
-
], oe);
|
|
1231
|
-
var L;
|
|
1232
|
-
let ce = (L = class extends pe {
|
|
1233
|
-
constructor(t, r) {
|
|
1234
|
-
super("UNIVER_RPC_WORKER_THREAD_PLUGIN"), this._config = t, this._injector = r;
|
|
1235
|
-
}
|
|
1236
|
-
onStarting(t) {
|
|
429
|
+
[u],
|
|
430
|
+
[m, { useClass: E }]
|
|
431
|
+
].forEach((r) => s.add(r)), s.get(u);
|
|
432
|
+
}
|
|
433
|
+
}, a(w, "type", F.Univer), w);
|
|
434
|
+
j = Q([
|
|
435
|
+
X(1, S(b))
|
|
436
|
+
], j);
|
|
437
|
+
var I;
|
|
438
|
+
let x = (I = class extends H {
|
|
439
|
+
constructor(s, t) {
|
|
440
|
+
super("UNIVER_RPC_WORKER_THREAD_PLUGIN"), this._config = s, this._injector = t;
|
|
441
|
+
}
|
|
442
|
+
onStarting(s) {
|
|
1237
443
|
[
|
|
1238
|
-
[
|
|
444
|
+
[p],
|
|
1239
445
|
[
|
|
1240
|
-
|
|
446
|
+
C,
|
|
1241
447
|
{
|
|
1242
|
-
useFactory: () => new
|
|
448
|
+
useFactory: () => new J(fe())
|
|
1243
449
|
}
|
|
1244
450
|
],
|
|
1245
|
-
[
|
|
1246
|
-
].forEach((
|
|
451
|
+
[f, { useClass: q }]
|
|
452
|
+
].forEach((t) => s.add(t)), s.get(p);
|
|
1247
453
|
}
|
|
1248
|
-
},
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
],
|
|
454
|
+
}, a(I, "type", F.Univer), I);
|
|
455
|
+
x = Q([
|
|
456
|
+
X(1, S(b))
|
|
457
|
+
], x);
|
|
1252
458
|
export {
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
459
|
+
he as ChannelClient,
|
|
460
|
+
le as ChannelServer,
|
|
461
|
+
C as IRPChannelService,
|
|
462
|
+
f as IRemoteInstanceService,
|
|
463
|
+
j as UniverRPCMainThreadPlugin,
|
|
464
|
+
x as UniverRPCWorkerThreadPlugin
|
|
1258
465
|
};
|