@dxos/teleport-extension-replicator 0.8.4-main.dedc0f3 → 0.8.4-main.dfabb4ec29
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/dist/lib/{browser → neutral}/index.mjs +56 -210
- package/dist/lib/neutral/index.mjs.map +7 -0
- package/dist/lib/{browser → neutral}/meta.json +1 -1
- package/dist/types/src/replicator-extension.d.ts +0 -7
- package/dist/types/src/replicator-extension.d.ts.map +1 -1
- package/dist/types/src/testing.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +21 -21
- package/src/replicator-extension.ts +1 -2
- package/src/testing.ts +0 -1
- package/dist/lib/browser/index.mjs.map +0 -7
- package/dist/lib/node-esm/index.mjs +0 -433
- package/dist/lib/node-esm/index.mjs.map +0 -7
- package/dist/lib/node-esm/meta.json +0 -1
|
@@ -11,27 +11,46 @@ import { RpcClosedError, TimeoutError } from "@dxos/protocols";
|
|
|
11
11
|
import { schema } from "@dxos/protocols/proto";
|
|
12
12
|
import { createProtoRpcPeer } from "@dxos/rpc";
|
|
13
13
|
import { ComplexMap } from "@dxos/util";
|
|
14
|
-
|
|
15
|
-
if (key in obj) {
|
|
16
|
-
Object.defineProperty(obj, key, {
|
|
17
|
-
value,
|
|
18
|
-
enumerable: true,
|
|
19
|
-
configurable: true,
|
|
20
|
-
writable: true
|
|
21
|
-
});
|
|
22
|
-
} else {
|
|
23
|
-
obj[key] = value;
|
|
24
|
-
}
|
|
25
|
-
return obj;
|
|
26
|
-
}
|
|
14
|
+
var __dxlog_file = "/__w/dxos/dxos/packages/core/mesh/teleport-extension-replicator/src/replicator-extension.ts";
|
|
27
15
|
function _ts_decorate(decorators, target, key, desc) {
|
|
28
16
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
29
17
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
30
18
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
31
19
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
32
20
|
}
|
|
33
|
-
var __dxlog_file = "/__w/dxos/dxos/packages/core/mesh/teleport-extension-replicator/src/replicator-extension.ts";
|
|
34
21
|
var ReplicatorExtension = class {
|
|
22
|
+
_ctx = new Context({
|
|
23
|
+
onError: (err) => {
|
|
24
|
+
this._extensionContext?.close(err);
|
|
25
|
+
}
|
|
26
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 23 });
|
|
27
|
+
_feeds = new ComplexMap(PublicKey.hash);
|
|
28
|
+
_streams = new ComplexMap(PublicKey.hash);
|
|
29
|
+
_rpc;
|
|
30
|
+
_extensionContext;
|
|
31
|
+
_options = {
|
|
32
|
+
upload: false
|
|
33
|
+
};
|
|
34
|
+
_updateTask = new DeferredTask(this._ctx, async () => {
|
|
35
|
+
try {
|
|
36
|
+
if (this._extensionContext.initiator === false) {
|
|
37
|
+
await this._rpc.rpc.ReplicatorService.updateFeeds({
|
|
38
|
+
feeds: Array.from(this._feeds.values()).map((feed) => ({
|
|
39
|
+
feedKey: feed.key,
|
|
40
|
+
download: true,
|
|
41
|
+
upload: this._options.upload
|
|
42
|
+
}))
|
|
43
|
+
});
|
|
44
|
+
} else if (this._extensionContext.initiator === true) {
|
|
45
|
+
await this._reevaluateFeeds();
|
|
46
|
+
}
|
|
47
|
+
} catch (err) {
|
|
48
|
+
if (err instanceof RpcClosedError) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
throw err;
|
|
52
|
+
}
|
|
53
|
+
});
|
|
35
54
|
get extensionInfo() {
|
|
36
55
|
return {
|
|
37
56
|
initiator: this._extensionContext?.initiator,
|
|
@@ -44,12 +63,7 @@ var ReplicatorExtension = class {
|
|
|
44
63
|
this._options = options;
|
|
45
64
|
log("setOptions", {
|
|
46
65
|
options
|
|
47
|
-
}, {
|
|
48
|
-
F: __dxlog_file,
|
|
49
|
-
L: 80,
|
|
50
|
-
S: this,
|
|
51
|
-
C: (f, a) => f(...a)
|
|
52
|
-
});
|
|
66
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 65, S: this });
|
|
53
67
|
if (this._extensionContext) {
|
|
54
68
|
this._updateTask.schedule();
|
|
55
69
|
}
|
|
@@ -59,24 +73,14 @@ var ReplicatorExtension = class {
|
|
|
59
73
|
this._feeds.set(feed.key, feed);
|
|
60
74
|
log("addFeed", {
|
|
61
75
|
feedKey: feed.key
|
|
62
|
-
}, {
|
|
63
|
-
F: __dxlog_file,
|
|
64
|
-
L: 89,
|
|
65
|
-
S: this,
|
|
66
|
-
C: (f, a) => f(...a)
|
|
67
|
-
});
|
|
76
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 75, S: this });
|
|
68
77
|
if (this._extensionContext) {
|
|
69
78
|
this._updateTask.schedule();
|
|
70
79
|
}
|
|
71
80
|
}
|
|
72
81
|
async onOpen(context) {
|
|
73
82
|
this._extensionContext = context;
|
|
74
|
-
log("open", void 0, {
|
|
75
|
-
F: __dxlog_file,
|
|
76
|
-
L: 97,
|
|
77
|
-
S: this,
|
|
78
|
-
C: (f, a) => f(...a)
|
|
79
|
-
});
|
|
83
|
+
log("open", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 84, S: this });
|
|
80
84
|
this._rpc = createProtoRpcPeer({
|
|
81
85
|
requested: {
|
|
82
86
|
ReplicatorService: schema.getService("dxos.mesh.teleport.replicator.ReplicatorService")
|
|
@@ -89,41 +93,15 @@ var ReplicatorExtension = class {
|
|
|
89
93
|
updateFeeds: async ({ feeds }) => {
|
|
90
94
|
log("received feed info", {
|
|
91
95
|
feeds
|
|
92
|
-
}, {
|
|
93
|
-
|
|
94
|
-
L: 109,
|
|
95
|
-
S: this,
|
|
96
|
-
C: (f, a) => f(...a)
|
|
97
|
-
});
|
|
98
|
-
invariant(this._extensionContext.initiator === true, "Invalid call", {
|
|
99
|
-
F: __dxlog_file,
|
|
100
|
-
L: 110,
|
|
101
|
-
S: this,
|
|
102
|
-
A: [
|
|
103
|
-
"this._extensionContext!.initiator === true",
|
|
104
|
-
"'Invalid call'"
|
|
105
|
-
]
|
|
106
|
-
});
|
|
96
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 95, S: this });
|
|
97
|
+
invariant(this._extensionContext.initiator === true, "Invalid call", { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 98, S: this, A: ["this._extensionContext.initiator === true", "'Invalid call'"] });
|
|
107
98
|
this._updateTask.schedule();
|
|
108
99
|
},
|
|
109
100
|
startReplication: async ({ info }) => {
|
|
110
101
|
log("starting replication...", {
|
|
111
102
|
info
|
|
112
|
-
}, {
|
|
113
|
-
|
|
114
|
-
L: 114,
|
|
115
|
-
S: this,
|
|
116
|
-
C: (f, a) => f(...a)
|
|
117
|
-
});
|
|
118
|
-
invariant(this._extensionContext.initiator === false, "Invalid call", {
|
|
119
|
-
F: __dxlog_file,
|
|
120
|
-
L: 115,
|
|
121
|
-
S: this,
|
|
122
|
-
A: [
|
|
123
|
-
"this._extensionContext!.initiator === false",
|
|
124
|
-
"'Invalid call'"
|
|
125
|
-
]
|
|
126
|
-
});
|
|
103
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 102, S: this });
|
|
104
|
+
invariant(this._extensionContext.initiator === false, "Invalid call", { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 105, S: this, A: ["this._extensionContext.initiator === false", "'Invalid call'"] });
|
|
127
105
|
const streamTag = await this._acceptReplication(info);
|
|
128
106
|
return {
|
|
129
107
|
streamTag
|
|
@@ -132,21 +110,8 @@ var ReplicatorExtension = class {
|
|
|
132
110
|
stopReplication: async ({ info }) => {
|
|
133
111
|
log("stopping replication...", {
|
|
134
112
|
info
|
|
135
|
-
}, {
|
|
136
|
-
|
|
137
|
-
L: 123,
|
|
138
|
-
S: this,
|
|
139
|
-
C: (f, a) => f(...a)
|
|
140
|
-
});
|
|
141
|
-
invariant(this._extensionContext.initiator === false, "Invalid call", {
|
|
142
|
-
F: __dxlog_file,
|
|
143
|
-
L: 125,
|
|
144
|
-
S: this,
|
|
145
|
-
A: [
|
|
146
|
-
"this._extensionContext!.initiator === false",
|
|
147
|
-
"'Invalid call'"
|
|
148
|
-
]
|
|
149
|
-
});
|
|
113
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 112, S: this });
|
|
114
|
+
invariant(this._extensionContext.initiator === false, "Invalid call", { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 116, S: this, A: ["this._extensionContext.initiator === false", "'Invalid call'"] });
|
|
150
115
|
await this._stopReplication(info.feedKey);
|
|
151
116
|
}
|
|
152
117
|
}
|
|
@@ -162,12 +127,7 @@ var ReplicatorExtension = class {
|
|
|
162
127
|
async onClose(err) {
|
|
163
128
|
log("close", {
|
|
164
129
|
err
|
|
165
|
-
}, {
|
|
166
|
-
F: __dxlog_file,
|
|
167
|
-
L: 142,
|
|
168
|
-
S: this,
|
|
169
|
-
C: (f, a) => f(...a)
|
|
170
|
-
});
|
|
130
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 130, S: this });
|
|
171
131
|
await this._ctx.dispose();
|
|
172
132
|
await this._rpc?.close();
|
|
173
133
|
for (const feedKey of this._streams.keys()) {
|
|
@@ -177,12 +137,7 @@ var ReplicatorExtension = class {
|
|
|
177
137
|
async onAbort(err) {
|
|
178
138
|
log("abort", {
|
|
179
139
|
err
|
|
180
|
-
}, {
|
|
181
|
-
F: __dxlog_file,
|
|
182
|
-
L: 151,
|
|
183
|
-
S: this,
|
|
184
|
-
C: (f, a) => f(...a)
|
|
185
|
-
});
|
|
140
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 140, S: this });
|
|
186
141
|
await this._ctx.dispose();
|
|
187
142
|
await this._rpc?.abort();
|
|
188
143
|
for (const feedKey of this._streams.keys()) {
|
|
@@ -190,12 +145,7 @@ var ReplicatorExtension = class {
|
|
|
190
145
|
}
|
|
191
146
|
}
|
|
192
147
|
async _reevaluateFeeds() {
|
|
193
|
-
log("_reevaluateFeeds", void 0, {
|
|
194
|
-
F: __dxlog_file,
|
|
195
|
-
L: 162,
|
|
196
|
-
S: this,
|
|
197
|
-
C: (f, a) => f(...a)
|
|
198
|
-
});
|
|
148
|
+
log("_reevaluateFeeds", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 150, S: this });
|
|
199
149
|
for (const feedKey of this._feeds.keys()) {
|
|
200
150
|
if (this._ctx.disposed) {
|
|
201
151
|
return;
|
|
@@ -204,12 +154,7 @@ var ReplicatorExtension = class {
|
|
|
204
154
|
try {
|
|
205
155
|
await asyncTimeout(this._stopReplication(feedKey), 1e3);
|
|
206
156
|
} catch (err) {
|
|
207
|
-
log.catch(err, void 0, {
|
|
208
|
-
F: __dxlog_file,
|
|
209
|
-
L: 171,
|
|
210
|
-
S: this,
|
|
211
|
-
C: (f, a) => f(...a)
|
|
212
|
-
});
|
|
157
|
+
log.catch(err, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 159, S: this });
|
|
213
158
|
}
|
|
214
159
|
}
|
|
215
160
|
if (this._ctx.disposed) {
|
|
@@ -230,30 +175,9 @@ var ReplicatorExtension = class {
|
|
|
230
175
|
async _initiateReplication(feedInfo) {
|
|
231
176
|
log("initiating replication", {
|
|
232
177
|
feedInfo
|
|
233
|
-
}, {
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
S: this,
|
|
237
|
-
C: (f, a) => f(...a)
|
|
238
|
-
});
|
|
239
|
-
invariant(this._extensionContext.initiator === true, "Invalid call", {
|
|
240
|
-
F: __dxlog_file,
|
|
241
|
-
L: 193,
|
|
242
|
-
S: this,
|
|
243
|
-
A: [
|
|
244
|
-
"this._extensionContext!.initiator === true",
|
|
245
|
-
"'Invalid call'"
|
|
246
|
-
]
|
|
247
|
-
});
|
|
248
|
-
invariant(!this._streams.has(feedInfo.feedKey), `Replication already in progress for feed: ${feedInfo.feedKey}`, {
|
|
249
|
-
F: __dxlog_file,
|
|
250
|
-
L: 194,
|
|
251
|
-
S: this,
|
|
252
|
-
A: [
|
|
253
|
-
"!this._streams.has(feedInfo.feedKey)",
|
|
254
|
-
"`Replication already in progress for feed: ${feedInfo.feedKey}`"
|
|
255
|
-
]
|
|
256
|
-
});
|
|
178
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 177, S: this });
|
|
179
|
+
invariant(this._extensionContext.initiator === true, "Invalid call", { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 180, S: this, A: ["this._extensionContext.initiator === true", "'Invalid call'"] });
|
|
180
|
+
invariant(!this._streams.has(feedInfo.feedKey), `Replication already in progress for feed: ${feedInfo.feedKey}`, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 181, S: this, A: ["!this._streams.has(feedInfo.feedKey)", "`Replication already in progress for feed: ${feedInfo.feedKey}`"] });
|
|
257
181
|
const { streamTag } = await this._rpc.rpc.ReplicatorService.startReplication({
|
|
258
182
|
info: feedInfo
|
|
259
183
|
});
|
|
@@ -267,15 +191,7 @@ var ReplicatorExtension = class {
|
|
|
267
191
|
* @returns A stream tag for the replication stream or `undefined` if we don't want to replicate.
|
|
268
192
|
*/
|
|
269
193
|
async _acceptReplication(feedInfo) {
|
|
270
|
-
invariant(this._extensionContext.initiator === false, "Invalid call", {
|
|
271
|
-
F: __dxlog_file,
|
|
272
|
-
L: 209,
|
|
273
|
-
S: this,
|
|
274
|
-
A: [
|
|
275
|
-
"this._extensionContext!.initiator === false",
|
|
276
|
-
"'Invalid call'"
|
|
277
|
-
]
|
|
278
|
-
});
|
|
194
|
+
invariant(this._extensionContext.initiator === false, "Invalid call", { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 194, S: this, A: ["this._extensionContext.initiator === false", "'Invalid call'"] });
|
|
279
195
|
if (!this._feeds.has(feedInfo.feedKey) || this._streams.has(feedInfo.feedKey)) {
|
|
280
196
|
return void 0;
|
|
281
197
|
}
|
|
@@ -287,21 +203,8 @@ var ReplicatorExtension = class {
|
|
|
287
203
|
log("replicate", {
|
|
288
204
|
info,
|
|
289
205
|
streamTag
|
|
290
|
-
}, {
|
|
291
|
-
|
|
292
|
-
L: 221,
|
|
293
|
-
S: this,
|
|
294
|
-
C: (f, a) => f(...a)
|
|
295
|
-
});
|
|
296
|
-
invariant(!this._streams.has(info.feedKey), `Replication already in progress for feed: ${info.feedKey}`, {
|
|
297
|
-
F: __dxlog_file,
|
|
298
|
-
L: 222,
|
|
299
|
-
S: this,
|
|
300
|
-
A: [
|
|
301
|
-
"!this._streams.has(info.feedKey)",
|
|
302
|
-
"`Replication already in progress for feed: ${info.feedKey}`"
|
|
303
|
-
]
|
|
304
|
-
});
|
|
206
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 203, S: this });
|
|
207
|
+
invariant(!this._streams.has(info.feedKey), `Replication already in progress for feed: ${info.feedKey}`, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 207, S: this, A: ["!this._streams.has(info.feedKey)", "`Replication already in progress for feed: ${info.feedKey}`"] });
|
|
305
208
|
const feed = this._feeds.get(info.feedKey) ?? failUndefined();
|
|
306
209
|
const networkStream = await this._extensionContext.createStream(streamTag, {
|
|
307
210
|
contentType: "application/x-hypercore"
|
|
@@ -320,47 +223,27 @@ var ReplicatorExtension = class {
|
|
|
320
223
|
log.info("replication stream timeout", {
|
|
321
224
|
err,
|
|
322
225
|
info
|
|
323
|
-
}, {
|
|
324
|
-
F: __dxlog_file,
|
|
325
|
-
L: 258,
|
|
326
|
-
S: this,
|
|
327
|
-
C: (f, a) => f(...a)
|
|
328
|
-
});
|
|
226
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 239, S: this });
|
|
329
227
|
return;
|
|
330
228
|
}
|
|
331
229
|
if (err?.message === "Writable stream closed prematurely" || err?.message === "Cannot call write after a stream was destroyed") {
|
|
332
230
|
log("replication stream closed", {
|
|
333
231
|
err,
|
|
334
232
|
info
|
|
335
|
-
}, {
|
|
336
|
-
F: __dxlog_file,
|
|
337
|
-
L: 266,
|
|
338
|
-
S: this,
|
|
339
|
-
C: (f, a) => f(...a)
|
|
340
|
-
});
|
|
233
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 247, S: this });
|
|
341
234
|
return;
|
|
342
235
|
}
|
|
343
236
|
if (replicationStreamErrors === 0) {
|
|
344
237
|
log.info("replication stream error", {
|
|
345
238
|
err,
|
|
346
239
|
info
|
|
347
|
-
}, {
|
|
348
|
-
F: __dxlog_file,
|
|
349
|
-
L: 272,
|
|
350
|
-
S: this,
|
|
351
|
-
C: (f, a) => f(...a)
|
|
352
|
-
});
|
|
240
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 255, S: this });
|
|
353
241
|
} else {
|
|
354
242
|
log.info("replication stream error", {
|
|
355
243
|
err,
|
|
356
244
|
feedKey: info.feedKey,
|
|
357
245
|
count: replicationStreamErrors
|
|
358
|
-
}, {
|
|
359
|
-
F: __dxlog_file,
|
|
360
|
-
L: 274,
|
|
361
|
-
S: this,
|
|
362
|
-
C: (f, a) => f(...a)
|
|
363
|
-
});
|
|
246
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 260, S: this });
|
|
364
247
|
}
|
|
365
248
|
replicationStreamErrors++;
|
|
366
249
|
});
|
|
@@ -380,43 +263,6 @@ var ReplicatorExtension = class {
|
|
|
380
263
|
stream.networkStream.destroy();
|
|
381
264
|
this._streams.delete(feedKey);
|
|
382
265
|
}
|
|
383
|
-
constructor() {
|
|
384
|
-
_define_property(this, "_ctx", new Context({
|
|
385
|
-
onError: (err) => {
|
|
386
|
-
this._extensionContext?.close(err);
|
|
387
|
-
}
|
|
388
|
-
}, {
|
|
389
|
-
F: __dxlog_file,
|
|
390
|
-
L: 31
|
|
391
|
-
}));
|
|
392
|
-
_define_property(this, "_feeds", new ComplexMap(PublicKey.hash));
|
|
393
|
-
_define_property(this, "_streams", new ComplexMap(PublicKey.hash));
|
|
394
|
-
_define_property(this, "_rpc", void 0);
|
|
395
|
-
_define_property(this, "_extensionContext", void 0);
|
|
396
|
-
_define_property(this, "_options", {
|
|
397
|
-
upload: false
|
|
398
|
-
});
|
|
399
|
-
_define_property(this, "_updateTask", new DeferredTask(this._ctx, async () => {
|
|
400
|
-
try {
|
|
401
|
-
if (this._extensionContext.initiator === false) {
|
|
402
|
-
await this._rpc.rpc.ReplicatorService.updateFeeds({
|
|
403
|
-
feeds: Array.from(this._feeds.values()).map((feed) => ({
|
|
404
|
-
feedKey: feed.key,
|
|
405
|
-
download: true,
|
|
406
|
-
upload: this._options.upload
|
|
407
|
-
}))
|
|
408
|
-
});
|
|
409
|
-
} else if (this._extensionContext.initiator === true) {
|
|
410
|
-
await this._reevaluateFeeds();
|
|
411
|
-
}
|
|
412
|
-
} catch (err) {
|
|
413
|
-
if (err instanceof RpcClosedError) {
|
|
414
|
-
return;
|
|
415
|
-
}
|
|
416
|
-
throw err;
|
|
417
|
-
}
|
|
418
|
-
}));
|
|
419
|
-
}
|
|
420
266
|
};
|
|
421
267
|
_ts_decorate([
|
|
422
268
|
logInfo
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/replicator-extension.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2022 DXOS.org\n//\n\nimport type { ProtocolStream } from 'hypercore-protocol';\nimport { type Duplex } from 'node:stream';\n\nimport { DeferredTask, asyncTimeout, synchronized } from '@dxos/async';\nimport { Context } from '@dxos/context';\nimport { failUndefined } from '@dxos/debug';\nimport { type FeedWrapper } from '@dxos/feed-store';\nimport { invariant } from '@dxos/invariant';\nimport { PublicKey } from '@dxos/keys';\nimport { log, logInfo } from '@dxos/log';\nimport { RpcClosedError, TimeoutError } from '@dxos/protocols';\nimport { schema } from '@dxos/protocols/proto';\nimport { type FeedInfo, type ReplicatorService } from '@dxos/protocols/proto/dxos/mesh/teleport/replicator';\nimport { type ProtoRpcPeer, createProtoRpcPeer } from '@dxos/rpc';\nimport { type ExtensionContext, type TeleportExtension } from '@dxos/teleport';\nimport { ComplexMap } from '@dxos/util';\n\nexport type ReplicationOptions = {\n upload: boolean;\n};\n\n/**\n * Manages replication between a set of feeds for a single teleport session.\n */\nexport class ReplicatorExtension implements TeleportExtension {\n private readonly _ctx = new Context({\n onError: (err) => {\n this._extensionContext?.close(err);\n },\n });\n\n private readonly _feeds = new ComplexMap<PublicKey, FeedWrapper<any>>(PublicKey.hash);\n private readonly _streams = new ComplexMap<PublicKey, ActiveStream>(PublicKey.hash);\n\n private _rpc?: ProtoRpcPeer<ServiceBundle>;\n private _extensionContext?: ExtensionContext;\n\n private _options: ReplicationOptions = {\n upload: false,\n };\n\n private readonly _updateTask = new DeferredTask(this._ctx, async () => {\n try {\n if (this._extensionContext!.initiator === false) {\n await this._rpc!.rpc.ReplicatorService.updateFeeds({\n feeds: Array.from(this._feeds.values()).map((feed) => ({\n feedKey: feed.key,\n download: true,\n upload: this._options.upload,\n })),\n });\n } else if (this._extensionContext!.initiator === true) {\n await this._reevaluateFeeds();\n }\n } catch (err) {\n if (err instanceof RpcClosedError) {\n return; // Some RPC requests might be pending while closing.\n }\n throw err;\n }\n });\n\n @logInfo\n private get extensionInfo() {\n return {\n initiator: this._extensionContext?.initiator,\n localPeerId: this._extensionContext?.localPeerId,\n remotePeerId: this._extensionContext?.remotePeerId,\n feeds: Array.from(this._feeds.keys()),\n };\n }\n\n setOptions(options: ReplicationOptions): this {\n this._options = options;\n log('setOptions', { options });\n if (this._extensionContext) {\n this._updateTask.schedule();\n }\n return this;\n }\n\n addFeed(feed: FeedWrapper<any>): void {\n this._feeds.set(feed.key, feed);\n log('addFeed', { feedKey: feed.key });\n if (this._extensionContext) {\n this._updateTask.schedule();\n }\n }\n\n async onOpen(context: ExtensionContext): Promise<void> {\n this._extensionContext = context;\n log('open');\n\n this._rpc = createProtoRpcPeer<ServiceBundle, ServiceBundle>({\n requested: {\n ReplicatorService: schema.getService('dxos.mesh.teleport.replicator.ReplicatorService'),\n },\n exposed: {\n ReplicatorService: schema.getService('dxos.mesh.teleport.replicator.ReplicatorService'),\n },\n handlers: {\n ReplicatorService: {\n updateFeeds: async ({ feeds }) => {\n log('received feed info', { feeds });\n invariant(this._extensionContext!.initiator === true, 'Invalid call');\n this._updateTask.schedule();\n },\n startReplication: async ({ info }) => {\n log('starting replication...', { info });\n invariant(this._extensionContext!.initiator === false, 'Invalid call');\n\n const streamTag = await this._acceptReplication(info);\n return {\n streamTag,\n };\n },\n stopReplication: async ({ info }) => {\n log('stopping replication...', { info });\n // TODO(dmaretskyi): Make sure any peer can stop replication.\n invariant(this._extensionContext!.initiator === false, 'Invalid call');\n\n await this._stopReplication(info.feedKey);\n },\n },\n },\n port: await context.createPort('rpc', {\n contentType: 'application/x-protobuf; messageType=\"dxos.rpc.Message\"',\n }),\n timeout: 10_000,\n });\n await this._rpc.open();\n\n this._updateTask.schedule();\n }\n\n async onClose(err?: Error | undefined): Promise<void> {\n log('close', { err });\n await this._ctx.dispose();\n await this._rpc?.close();\n for (const feedKey of this._streams.keys()) {\n await this._stopReplication(feedKey);\n }\n }\n\n async onAbort(err?: Error | undefined): Promise<void> {\n log('abort', { err });\n\n await this._ctx.dispose();\n await this._rpc?.abort();\n for (const feedKey of this._streams.keys()) {\n await this._stopReplication(feedKey);\n }\n }\n\n @synchronized\n private async _reevaluateFeeds(): Promise<void> {\n log('_reevaluateFeeds');\n for (const feedKey of this._feeds.keys()) {\n if (this._ctx.disposed) {\n return;\n }\n if (this._streams.has(feedKey) && this._options.upload !== this._streams.get(feedKey)?.info.upload) {\n try {\n await asyncTimeout(this._stopReplication(feedKey), 1000);\n } catch (err) {\n log.catch(err);\n }\n }\n\n if (this._ctx.disposed) {\n return;\n }\n if (!this._streams.has(feedKey)) {\n await this._initiateReplication({\n feedKey,\n download: true,\n upload: this._options.upload,\n });\n }\n }\n }\n\n /**\n * Try to initiate feed replication.\n */\n private async _initiateReplication(feedInfo: FeedInfo): Promise<void> {\n log('initiating replication', { feedInfo });\n invariant(this._extensionContext!.initiator === true, 'Invalid call');\n invariant(!this._streams.has(feedInfo.feedKey), `Replication already in progress for feed: ${feedInfo.feedKey}`);\n const { streamTag } = await this._rpc!.rpc.ReplicatorService.startReplication({ info: feedInfo });\n if (!streamTag) {\n return;\n }\n\n await this._replicateFeed(feedInfo, streamTag);\n }\n\n /**\n * Respond to a remote request to replicate a feed.\n * @returns A stream tag for the replication stream or `undefined` if we don't want to replicate.\n */\n @synchronized\n private async _acceptReplication(feedInfo: FeedInfo): Promise<string | undefined> {\n invariant(this._extensionContext!.initiator === false, 'Invalid call');\n\n if (!this._feeds.has(feedInfo.feedKey) || this._streams.has(feedInfo.feedKey)) {\n return undefined; // We don't have the feed or we are already replicating it.\n }\n\n const tag = `feed-${feedInfo.feedKey.toHex()}-${PublicKey.random().toHex().slice(0, 8)}`; // Generate a unique tag for the stream.\n await this._replicateFeed(feedInfo, tag);\n return tag;\n }\n\n private async _replicateFeed(info: FeedInfo, streamTag: string): Promise<void> {\n log('replicate', { info, streamTag });\n invariant(!this._streams.has(info.feedKey), `Replication already in progress for feed: ${info.feedKey}`);\n\n const feed = this._feeds.get(info.feedKey) ?? failUndefined();\n const networkStream = await this._extensionContext!.createStream(streamTag, {\n contentType: 'application/x-hypercore',\n });\n let replicationStreamErrors = 0;\n\n // https://github.com/holepunchto/hypercore/tree/v9.12.0#var-stream--feedreplicateisinitiator-options\n const replicationStream = feed.replicate(true, {\n live: true,\n upload: info.upload,\n download: info.download,\n noise: false,\n encrypted: false,\n maxRequests: 1024,\n });\n\n // Left for testing.\n // const debug = true;\n // if (debug) {\n // feed.on('sync', () => {\n // log.info('sync', { key: feed.key, length: feed.length });\n // });\n // feed.on('download', (index: number, data: any) => {\n // log.info('download', {\n // key: feed.key,\n // index,\n // length: feed.length,\n // data: data.length,\n // });\n // });\n // }\n\n replicationStream.on('error', (err) => {\n if (err instanceof TimeoutError) {\n log.info('replication stream timeout', { err, info });\n return;\n }\n // TODO(nf): use sentinel errors\n if (\n err?.message === 'Writable stream closed prematurely' ||\n err?.message === 'Cannot call write after a stream was destroyed'\n ) {\n log('replication stream closed', { err, info });\n return;\n }\n\n // TODO(nf): WARN on first error? log full info on some subsequent errors?\n if (replicationStreamErrors === 0) {\n log.info('replication stream error', { err, info });\n } else {\n log.info('replication stream error', { err, feedKey: info.feedKey, count: replicationStreamErrors });\n }\n replicationStreamErrors++;\n });\n\n this._streams.set(info.feedKey, {\n streamTag,\n networkStream,\n replicationStream,\n info,\n });\n\n networkStream.pipe(replicationStream as any).pipe(networkStream);\n }\n\n private async _stopReplication(feedKey: PublicKey): Promise<void> {\n const stream = this._streams.get(feedKey);\n if (!stream) {\n return;\n }\n\n stream.networkStream.destroy();\n this._streams.delete(feedKey);\n }\n}\n\ntype ServiceBundle = {\n ReplicatorService: ReplicatorService;\n};\n\ntype ActiveStream = {\n streamTag: string;\n networkStream: Duplex;\n replicationStream: ProtocolStream;\n info: FeedInfo;\n};\n"],
|
|
5
|
+
"mappings": ";;;AAQA,SAASA,cAAO,cAAQ,oBAAgB;AACxC,SAASC,eAAa;AAEtB,SAASC,qBAAiB;AAC1B,SAASC,iBAAiB;AAC1B,SAASC,iBAAY;AACrB,SAASC,KAAAA,eAAgBC;AACzB,SAASC,gBAAc,oBAAA;AAEvB,SAA4BC,cAAAA;AAE5B,SAASC,0BAAkB;AAM3B,SAAA,kBAAA;AAzBA,IAAE,eAAA;;;;;;AAOF;AAsB0B,IAAIT,sBAAJ,MAAY;SAClCU,IAAAA,QAAUC;aACHC,CAAAA,QAAAA;AACP,WAAA,mBAAA,MAAA,GAAA;IACC;EAEcC,GAAAA,EAAAA,YAAaJ,YAAwCN,GAAAA,cAAgB,GAAA,GAAA,CAAA;EACrEW,SAAAA,IAAW,WAAIL,UAAoCN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,aAAA;EAEA;QACE,iBAAmB,SAAS;AAC5B,UAAKS,SAAQ,KAAA,SAAA,IAAA,OAAA;QACX,CAAA,QAAA;AACF;IAEAA;AACA,WAAK1D,cAAgBa,QAAAA;AACvB,SAAA,SAAA,OAAA,OAAA;EACF;;;;;;;;;;;",
|
|
6
|
+
"names": ["Context", "failUndefined", "invariant", "PublicKey", "log", "RpcClosedError", "TimeoutError", "schema", "createProtoRpcPeer", "ComplexMap", "onError", "err", "_extensionContext", "_feeds", "_streams", "hash", "_rpc", "_options", "upload", "_updateTask", "ReplicatorService", "updateFeeds", "feeds", "Array", "from", "values", "feed", "feedKey", "key", "download", "_reevaluateFeeds", "initiator", "localPeerId", "remotePeerId", "setOptions", "options", "schedule", "addFeed", "requested", "exposed", "handlers", "startReplication", "info", "streamTag", "_acceptReplication", "stopReplication", "_stopReplication", "port", "contentType", "timeout", "_ctx", "close", "abort", "disposed", "catch", "_initiateReplication", "feedInfo", "rpc", "undefined", "_replicateFeed", "tag", "has", "get", "networkStream", "createStream", "live", "noise", "encrypted", "maxRequests", "count", "replicationStreamErrors", "replicationStream", "stream"]
|
|
7
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs":{"src/replicator-extension.ts":{"bytes":
|
|
1
|
+
{"inputs":{"src/replicator-extension.ts":{"bytes":36158,"imports":[{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"@dxos/protocols/proto","kind":"import-statement","external":true},{"path":"@dxos/rpc","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"format":"esm"},"src/index.ts":{"bytes":408,"imports":[{"path":"src/replicator-extension.ts","kind":"import-statement","original":"./replicator-extension"}],"format":"esm"}},"outputs":{"dist/lib/neutral/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":16928},"dist/lib/neutral/index.mjs":{"imports":[{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"@dxos/protocols/proto","kind":"import-statement","external":true},{"path":"@dxos/rpc","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"exports":["ReplicatorExtension"],"entryPoint":"src/index.ts","inputs":{"src/replicator-extension.ts":{"bytesInOutput":10583},"src/index.ts":{"bytesInOutput":0}},"bytes":10717}}}
|
|
@@ -21,14 +21,7 @@ export declare class ReplicatorExtension implements TeleportExtension {
|
|
|
21
21
|
onClose(err?: Error | undefined): Promise<void>;
|
|
22
22
|
onAbort(err?: Error | undefined): Promise<void>;
|
|
23
23
|
private _reevaluateFeeds;
|
|
24
|
-
/**
|
|
25
|
-
* Try to initiate feed replication.
|
|
26
|
-
*/
|
|
27
24
|
private _initiateReplication;
|
|
28
|
-
/**
|
|
29
|
-
* Respond to a remote request to replicate a feed.
|
|
30
|
-
* @returns A stream tag for the replication stream or `undefined` if we don't want to replicate.
|
|
31
|
-
*/
|
|
32
25
|
private _acceptReplication;
|
|
33
26
|
private _replicateFeed;
|
|
34
27
|
private _stopReplication;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"replicator-extension.d.ts","sourceRoot":"","sources":["../../../src/replicator-extension.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"replicator-extension.d.ts","sourceRoot":"","sources":["../../../src/replicator-extension.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAQpD,OAAO,EAAE,KAAK,gBAAgB,EAAE,KAAK,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAG/E,MAAM,MAAM,kBAAkB,GAAG;IAC/B,MAAM,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF;;GAEG;AACH,qBAAa,mBAAoB,YAAW,iBAAiB;IAC3D,OAAO,CAAC,QAAQ,CAAC,IAAI,CAIlB;IAEH,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA+D;IACtF,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA2D;IAEpF,OAAO,CAAC,IAAI,CAAC,CAA8B;IAC3C,OAAO,CAAC,iBAAiB,CAAC,CAAmB;IAE7C,OAAO,CAAC,QAAQ,CAEd;IAEF,OAAO,CAAC,QAAQ,CAAC,WAAW,CAmBzB;IAGH,OAAO,KAAK,aAAa,GAOxB;IAED,UAAU,CAAC,OAAO,EAAE,kBAAkB,GAAG,IAAI,CAO5C;IAED,OAAO,CAAC,IAAI,EAAE,WAAW,CAAC,GAAG,CAAC,GAAG,IAAI,CAMpC;IAEK,MAAM,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CA4CrD;IAEK,OAAO,CAAC,GAAG,CAAC,EAAE,KAAK,GAAG,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAOpD;IAEK,OAAO,CAAC,GAAG,CAAC,EAAE,KAAK,GAAG,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAQpD;YAGa,gBAAgB;YA8BhB,oBAAoB;YAiBpB,kBAAkB;YAYlB,cAAc;YAqEd,gBAAgB;CAS/B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../../../src/testing.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../../../src/testing.ts"],"names":[],"mappings":"AAOA,OAAO,EAAe,KAAK,WAAW,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC5E,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAGvC,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAG1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAE7D,qBAAa,WAAW;IACtB,WAAW,IAAI,SAAS,CAEvB;CACF;AAGD,qBAAa,SAAS;IACb,OAAO,gDAA4C;IACnD,OAAO,UAAwD;IAC/D,SAAS,gBAEb;IAEG,eAAe,CAAC,SAAS,SAAI,uDAQlC;IAED,cAAc,CAAC,GAAG,EAAE,SAAS,EAAE,IAAI,CAAC,EAAE,WAAW,uDAEhD;CACF;AAED;;GAEG;AACH,eAAO,MAAM,gBAAgB;;;EAuB5B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,oBAAoB;;;EAUhC,CAAC"}
|