@dxos/teleport-extension-replicator 0.6.9 → 0.6.10-main.3cfcc89
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/index.mjs +26 -25
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +27 -26
- package/dist/lib/node/index.cjs.map +2 -2
- package/dist/lib/node/meta.json +1 -1
- package/dist/types/src/replicator-extension.d.ts.map +1 -1
- package/package.json +15 -15
- package/src/replicator-extension.ts +2 -1
|
@@ -14,7 +14,8 @@ import { failUndefined } from "@dxos/debug";
|
|
|
14
14
|
import { invariant } from "@dxos/invariant";
|
|
15
15
|
import { PublicKey } from "@dxos/keys";
|
|
16
16
|
import { log, logInfo } from "@dxos/log";
|
|
17
|
-
import {
|
|
17
|
+
import { RpcClosedError, TimeoutError } from "@dxos/protocols";
|
|
18
|
+
import { schema } from "@dxos/protocols/proto";
|
|
18
19
|
import { createProtoRpcPeer } from "@dxos/rpc";
|
|
19
20
|
import { ComplexMap } from "@dxos/util";
|
|
20
21
|
function _ts_decorate(decorators, target, key, desc) {
|
|
@@ -36,7 +37,7 @@ var ReplicatorExtension = class {
|
|
|
36
37
|
}
|
|
37
38
|
}, {
|
|
38
39
|
F: __dxlog_file,
|
|
39
|
-
L:
|
|
40
|
+
L: 30
|
|
40
41
|
});
|
|
41
42
|
this._feeds = new ComplexMap(PublicKey.hash);
|
|
42
43
|
this._streams = new ComplexMap(PublicKey.hash);
|
|
@@ -78,7 +79,7 @@ var ReplicatorExtension = class {
|
|
|
78
79
|
options
|
|
79
80
|
}, {
|
|
80
81
|
F: __dxlog_file,
|
|
81
|
-
L:
|
|
82
|
+
L: 79,
|
|
82
83
|
S: this,
|
|
83
84
|
C: (f, a) => f(...a)
|
|
84
85
|
});
|
|
@@ -93,7 +94,7 @@ var ReplicatorExtension = class {
|
|
|
93
94
|
feedKey: feed.key
|
|
94
95
|
}, {
|
|
95
96
|
F: __dxlog_file,
|
|
96
|
-
L:
|
|
97
|
+
L: 88,
|
|
97
98
|
S: this,
|
|
98
99
|
C: (f, a) => f(...a)
|
|
99
100
|
});
|
|
@@ -105,7 +106,7 @@ var ReplicatorExtension = class {
|
|
|
105
106
|
this._extensionContext = context;
|
|
106
107
|
log("open", void 0, {
|
|
107
108
|
F: __dxlog_file,
|
|
108
|
-
L:
|
|
109
|
+
L: 96,
|
|
109
110
|
S: this,
|
|
110
111
|
C: (f, a) => f(...a)
|
|
111
112
|
});
|
|
@@ -123,13 +124,13 @@ var ReplicatorExtension = class {
|
|
|
123
124
|
feeds
|
|
124
125
|
}, {
|
|
125
126
|
F: __dxlog_file,
|
|
126
|
-
L:
|
|
127
|
+
L: 108,
|
|
127
128
|
S: this,
|
|
128
129
|
C: (f, a) => f(...a)
|
|
129
130
|
});
|
|
130
131
|
invariant(this._extensionContext.initiator === true, "Invalid call", {
|
|
131
132
|
F: __dxlog_file,
|
|
132
|
-
L:
|
|
133
|
+
L: 109,
|
|
133
134
|
S: this,
|
|
134
135
|
A: [
|
|
135
136
|
"this._extensionContext!.initiator === true",
|
|
@@ -143,13 +144,13 @@ var ReplicatorExtension = class {
|
|
|
143
144
|
info
|
|
144
145
|
}, {
|
|
145
146
|
F: __dxlog_file,
|
|
146
|
-
L:
|
|
147
|
+
L: 113,
|
|
147
148
|
S: this,
|
|
148
149
|
C: (f, a) => f(...a)
|
|
149
150
|
});
|
|
150
151
|
invariant(this._extensionContext.initiator === false, "Invalid call", {
|
|
151
152
|
F: __dxlog_file,
|
|
152
|
-
L:
|
|
153
|
+
L: 114,
|
|
153
154
|
S: this,
|
|
154
155
|
A: [
|
|
155
156
|
"this._extensionContext!.initiator === false",
|
|
@@ -166,13 +167,13 @@ var ReplicatorExtension = class {
|
|
|
166
167
|
info
|
|
167
168
|
}, {
|
|
168
169
|
F: __dxlog_file,
|
|
169
|
-
L:
|
|
170
|
+
L: 122,
|
|
170
171
|
S: this,
|
|
171
172
|
C: (f, a) => f(...a)
|
|
172
173
|
});
|
|
173
174
|
invariant(this._extensionContext.initiator === false, "Invalid call", {
|
|
174
175
|
F: __dxlog_file,
|
|
175
|
-
L:
|
|
176
|
+
L: 124,
|
|
176
177
|
S: this,
|
|
177
178
|
A: [
|
|
178
179
|
"this._extensionContext!.initiator === false",
|
|
@@ -196,7 +197,7 @@ var ReplicatorExtension = class {
|
|
|
196
197
|
err
|
|
197
198
|
}, {
|
|
198
199
|
F: __dxlog_file,
|
|
199
|
-
L:
|
|
200
|
+
L: 141,
|
|
200
201
|
S: this,
|
|
201
202
|
C: (f, a) => f(...a)
|
|
202
203
|
});
|
|
@@ -211,7 +212,7 @@ var ReplicatorExtension = class {
|
|
|
211
212
|
err
|
|
212
213
|
}, {
|
|
213
214
|
F: __dxlog_file,
|
|
214
|
-
L:
|
|
215
|
+
L: 150,
|
|
215
216
|
S: this,
|
|
216
217
|
C: (f, a) => f(...a)
|
|
217
218
|
});
|
|
@@ -224,7 +225,7 @@ var ReplicatorExtension = class {
|
|
|
224
225
|
async _reevaluateFeeds() {
|
|
225
226
|
log("_reevaluateFeeds", void 0, {
|
|
226
227
|
F: __dxlog_file,
|
|
227
|
-
L:
|
|
228
|
+
L: 161,
|
|
228
229
|
S: this,
|
|
229
230
|
C: (f, a) => f(...a)
|
|
230
231
|
});
|
|
@@ -238,7 +239,7 @@ var ReplicatorExtension = class {
|
|
|
238
239
|
} catch (err) {
|
|
239
240
|
log.catch(err, void 0, {
|
|
240
241
|
F: __dxlog_file,
|
|
241
|
-
L:
|
|
242
|
+
L: 170,
|
|
242
243
|
S: this,
|
|
243
244
|
C: (f, a) => f(...a)
|
|
244
245
|
});
|
|
@@ -264,13 +265,13 @@ var ReplicatorExtension = class {
|
|
|
264
265
|
feedInfo
|
|
265
266
|
}, {
|
|
266
267
|
F: __dxlog_file,
|
|
267
|
-
L:
|
|
268
|
+
L: 191,
|
|
268
269
|
S: this,
|
|
269
270
|
C: (f, a) => f(...a)
|
|
270
271
|
});
|
|
271
272
|
invariant(this._extensionContext.initiator === true, "Invalid call", {
|
|
272
273
|
F: __dxlog_file,
|
|
273
|
-
L:
|
|
274
|
+
L: 192,
|
|
274
275
|
S: this,
|
|
275
276
|
A: [
|
|
276
277
|
"this._extensionContext!.initiator === true",
|
|
@@ -279,7 +280,7 @@ var ReplicatorExtension = class {
|
|
|
279
280
|
});
|
|
280
281
|
invariant(!this._streams.has(feedInfo.feedKey), `Replication already in progress for feed: ${feedInfo.feedKey}`, {
|
|
281
282
|
F: __dxlog_file,
|
|
282
|
-
L:
|
|
283
|
+
L: 193,
|
|
283
284
|
S: this,
|
|
284
285
|
A: [
|
|
285
286
|
"!this._streams.has(feedInfo.feedKey)",
|
|
@@ -301,7 +302,7 @@ var ReplicatorExtension = class {
|
|
|
301
302
|
async _acceptReplication(feedInfo) {
|
|
302
303
|
invariant(this._extensionContext.initiator === false, "Invalid call", {
|
|
303
304
|
F: __dxlog_file,
|
|
304
|
-
L:
|
|
305
|
+
L: 208,
|
|
305
306
|
S: this,
|
|
306
307
|
A: [
|
|
307
308
|
"this._extensionContext!.initiator === false",
|
|
@@ -321,13 +322,13 @@ var ReplicatorExtension = class {
|
|
|
321
322
|
streamTag
|
|
322
323
|
}, {
|
|
323
324
|
F: __dxlog_file,
|
|
324
|
-
L:
|
|
325
|
+
L: 220,
|
|
325
326
|
S: this,
|
|
326
327
|
C: (f, a) => f(...a)
|
|
327
328
|
});
|
|
328
329
|
invariant(!this._streams.has(info.feedKey), `Replication already in progress for feed: ${info.feedKey}`, {
|
|
329
330
|
F: __dxlog_file,
|
|
330
|
-
L:
|
|
331
|
+
L: 221,
|
|
331
332
|
S: this,
|
|
332
333
|
A: [
|
|
333
334
|
"!this._streams.has(info.feedKey)",
|
|
@@ -354,7 +355,7 @@ var ReplicatorExtension = class {
|
|
|
354
355
|
info
|
|
355
356
|
}, {
|
|
356
357
|
F: __dxlog_file,
|
|
357
|
-
L:
|
|
358
|
+
L: 257,
|
|
358
359
|
S: this,
|
|
359
360
|
C: (f, a) => f(...a)
|
|
360
361
|
});
|
|
@@ -366,7 +367,7 @@ var ReplicatorExtension = class {
|
|
|
366
367
|
info
|
|
367
368
|
}, {
|
|
368
369
|
F: __dxlog_file,
|
|
369
|
-
L:
|
|
370
|
+
L: 265,
|
|
370
371
|
S: this,
|
|
371
372
|
C: (f, a) => f(...a)
|
|
372
373
|
});
|
|
@@ -378,7 +379,7 @@ var ReplicatorExtension = class {
|
|
|
378
379
|
info
|
|
379
380
|
}, {
|
|
380
381
|
F: __dxlog_file,
|
|
381
|
-
L:
|
|
382
|
+
L: 271,
|
|
382
383
|
S: this,
|
|
383
384
|
C: (f, a) => f(...a)
|
|
384
385
|
});
|
|
@@ -389,7 +390,7 @@ var ReplicatorExtension = class {
|
|
|
389
390
|
count: replicationStreamErrors
|
|
390
391
|
}, {
|
|
391
392
|
F: __dxlog_file,
|
|
392
|
-
L:
|
|
393
|
+
L: 273,
|
|
393
394
|
S: this,
|
|
394
395
|
C: (f, a) => f(...a)
|
|
395
396
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
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 { asyncTimeout, DeferredTask, 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 {
|
|
5
|
-
"mappings": ";;;;;;;;;;AAOA,SAASA,cAAcC,cAAcC,oBAAoB;AACzD,SAASC,eAAe;AACxB,SAASC,qBAAqB;AAE9B,SAASC,iBAAiB;AAC1B,SAASC,iBAAiB;AAC1B,SAASC,KAAKC,eAAe;AAC7B,SAASC,
|
|
6
|
-
"names": ["asyncTimeout", "DeferredTask", "synchronized", "Context", "failUndefined", "invariant", "PublicKey", "log", "logInfo", "
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2022 DXOS.org\n//\n\nimport type { ProtocolStream } from 'hypercore-protocol';\nimport { type Duplex } from 'node:stream';\n\nimport { asyncTimeout, DeferredTask, 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 { createProtoRpcPeer, type ProtoRpcPeer } 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>) {\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) {\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) {\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) {\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() {\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) {\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) {\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) {\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": ";;;;;;;;;;AAOA,SAASA,cAAcC,cAAcC,oBAAoB;AACzD,SAASC,eAAe;AAC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AAMC,oBAAoBlD,KAAKmD,UAAU,MAAM;MAC7CC,MAAM;MACNhE,QAAQiC,KAAKjC;MACbe,UAAUkB,KAAKlB;MACfkD,OAAO;MACPC,WAAW;MACXC,aAAa;IACf,CAAA;AAkBAL,sBAAkBM,GAAG,SAAS,CAAC3E,QAAAA;AAC7B,UAAIA,eAAeP,cAAc;AAC/BH,YAAIkD,KAAK,8BAA8B;UAAExC;UAAKwC;QAAK,GAAA;;;;;;AACnD;MACF;AAEA,UACExC,KAAK4E,YAAY,wCACjB5E,KAAK4E,YAAY,kDACjB;AACAtF,YAAI,6BAA6B;UAAEU;UAAKwC;QAAK,GAAA;;;;;;AAC7C;MACF;AAGA,UAAI4B,4BAA4B,GAAG;AACjC9E,YAAIkD,KAAK,4BAA4B;UAAExC;UAAKwC;QAAK,GAAA;;;;;;MACnD,OAAO;AACLlD,YAAIkD,KAAK,4BAA4B;UAAExC;UAAKoB,SAASoB,KAAKpB;UAASyD,OAAOT;QAAwB,GAAA;;;;;;MACpG;AACAA;IACF,CAAA;AAEA,SAAK/D,SAAS2B,IAAIQ,KAAKpB,SAAS;MAC9BqB;MACAyB;MACAG;MACA7B;IACF,CAAA;AAEA0B,kBAAcY,KAAKT,iBAAAA,EAA0BS,KAAKZ,aAAAA;EACpD;EAEA,MAActB,iBAAiBxB,SAAoB;AACjD,UAAM2D,SAAS,KAAK1E,SAASmD,IAAIpC,OAAAA;AACjC,QAAI,CAAC2D,QAAQ;AACX;IACF;AAEAA,WAAOb,cAAcc,QAAO;AAC5B,SAAK3E,SAAS4E,OAAO7D,OAAAA;EACvB;AACF;;EAtOG7B;GAtCUM,oBAAAA,WAAAA,iBAAAA,IAAAA;;EAkIVZ;GAlIUY,oBAAAA,WAAAA,oBAAAA,IAAAA;;EAiLVZ;GAjLUY,oBAAAA,WAAAA,sBAAAA,IAAAA;",
|
|
6
|
+
"names": ["asyncTimeout", "DeferredTask", "synchronized", "Context", "failUndefined", "invariant", "PublicKey", "log", "logInfo", "RpcClosedError", "TimeoutError", "schema", "createProtoRpcPeer", "ComplexMap", "ReplicatorExtension", "_ctx", "onError", "err", "_extensionContext", "close", "_feeds", "hash", "_streams", "_options", "upload", "_updateTask", "initiator", "_rpc", "rpc", "ReplicatorService", "updateFeeds", "feeds", "Array", "from", "values", "map", "feed", "feedKey", "key", "download", "_reevaluateFeeds", "extensionInfo", "localPeerId", "remotePeerId", "keys", "setOptions", "options", "schedule", "addFeed", "set", "onOpen", "context", "requested", "getService", "exposed", "handlers", "startReplication", "info", "streamTag", "_acceptReplication", "stopReplication", "_stopReplication", "port", "createPort", "contentType", "timeout", "open", "onClose", "dispose", "onAbort", "abort", "disposed", "has", "get", "catch", "_initiateReplication", "feedInfo", "_replicateFeed", "undefined", "tag", "toHex", "random", "slice", "networkStream", "createStream", "replicationStreamErrors", "replicationStream", "replicate", "live", "noise", "encrypted", "maxRequests", "on", "message", "count", "pipe", "stream", "destroy", "delete"]
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs":{"inject-globals:@inject-globals":{"bytes":384,"imports":[{"path":"@dxos/node-std/inject-globals","kind":"import-statement","external":true}],"format":"esm"},"packages/core/mesh/teleport-extension-replicator/src/replicator-extension.ts":{"bytes":
|
|
1
|
+
{"inputs":{"inject-globals:@inject-globals":{"bytes":384,"imports":[{"path":"@dxos/node-std/inject-globals","kind":"import-statement","external":true}],"format":"esm"},"packages/core/mesh/teleport-extension-replicator/src/replicator-extension.ts":{"bytes":39372,"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},{"path":"@inject-globals","kind":"import-statement","external":true}],"format":"esm"},"packages/core/mesh/teleport-extension-replicator/src/index.ts":{"bytes":552,"imports":[{"path":"packages/core/mesh/teleport-extension-replicator/src/replicator-extension.ts","kind":"import-statement","original":"./replicator-extension"},{"path":"@inject-globals","kind":"import-statement","external":true}],"format":"esm"}},"outputs":{"packages/core/mesh/teleport-extension-replicator/dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":16545},"packages/core/mesh/teleport-extension-replicator/dist/lib/browser/index.mjs":{"imports":[{"path":"@dxos/node-std/inject-globals","kind":"import-statement","external":true},{"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":"packages/core/mesh/teleport-extension-replicator/src/index.ts","inputs":{"inject-globals:@inject-globals":{"bytesInOutput":79},"packages/core/mesh/teleport-extension-replicator/src/replicator-extension.ts":{"bytesInOutput":11729},"packages/core/mesh/teleport-extension-replicator/src/index.ts":{"bytesInOutput":0}},"bytes":12026}}}
|
package/dist/lib/node/index.cjs
CHANGED
|
@@ -28,6 +28,7 @@ var import_invariant = require("@dxos/invariant");
|
|
|
28
28
|
var import_keys = require("@dxos/keys");
|
|
29
29
|
var import_log = require("@dxos/log");
|
|
30
30
|
var import_protocols = require("@dxos/protocols");
|
|
31
|
+
var import_proto = require("@dxos/protocols/proto");
|
|
31
32
|
var import_rpc = require("@dxos/rpc");
|
|
32
33
|
var import_util = require("@dxos/util");
|
|
33
34
|
function _ts_decorate(decorators, target, key, desc) {
|
|
@@ -49,7 +50,7 @@ var ReplicatorExtension = class {
|
|
|
49
50
|
}
|
|
50
51
|
}, {
|
|
51
52
|
F: __dxlog_file,
|
|
52
|
-
L:
|
|
53
|
+
L: 30
|
|
53
54
|
});
|
|
54
55
|
this._feeds = new import_util.ComplexMap(import_keys.PublicKey.hash);
|
|
55
56
|
this._streams = new import_util.ComplexMap(import_keys.PublicKey.hash);
|
|
@@ -91,7 +92,7 @@ var ReplicatorExtension = class {
|
|
|
91
92
|
options
|
|
92
93
|
}, {
|
|
93
94
|
F: __dxlog_file,
|
|
94
|
-
L:
|
|
95
|
+
L: 79,
|
|
95
96
|
S: this,
|
|
96
97
|
C: (f, a) => f(...a)
|
|
97
98
|
});
|
|
@@ -106,7 +107,7 @@ var ReplicatorExtension = class {
|
|
|
106
107
|
feedKey: feed.key
|
|
107
108
|
}, {
|
|
108
109
|
F: __dxlog_file,
|
|
109
|
-
L:
|
|
110
|
+
L: 88,
|
|
110
111
|
S: this,
|
|
111
112
|
C: (f, a) => f(...a)
|
|
112
113
|
});
|
|
@@ -118,16 +119,16 @@ var ReplicatorExtension = class {
|
|
|
118
119
|
this._extensionContext = context;
|
|
119
120
|
(0, import_log.log)("open", void 0, {
|
|
120
121
|
F: __dxlog_file,
|
|
121
|
-
L:
|
|
122
|
+
L: 96,
|
|
122
123
|
S: this,
|
|
123
124
|
C: (f, a) => f(...a)
|
|
124
125
|
});
|
|
125
126
|
this._rpc = (0, import_rpc.createProtoRpcPeer)({
|
|
126
127
|
requested: {
|
|
127
|
-
ReplicatorService:
|
|
128
|
+
ReplicatorService: import_proto.schema.getService("dxos.mesh.teleport.replicator.ReplicatorService")
|
|
128
129
|
},
|
|
129
130
|
exposed: {
|
|
130
|
-
ReplicatorService:
|
|
131
|
+
ReplicatorService: import_proto.schema.getService("dxos.mesh.teleport.replicator.ReplicatorService")
|
|
131
132
|
},
|
|
132
133
|
handlers: {
|
|
133
134
|
ReplicatorService: {
|
|
@@ -136,13 +137,13 @@ var ReplicatorExtension = class {
|
|
|
136
137
|
feeds
|
|
137
138
|
}, {
|
|
138
139
|
F: __dxlog_file,
|
|
139
|
-
L:
|
|
140
|
+
L: 108,
|
|
140
141
|
S: this,
|
|
141
142
|
C: (f, a) => f(...a)
|
|
142
143
|
});
|
|
143
144
|
(0, import_invariant.invariant)(this._extensionContext.initiator === true, "Invalid call", {
|
|
144
145
|
F: __dxlog_file,
|
|
145
|
-
L:
|
|
146
|
+
L: 109,
|
|
146
147
|
S: this,
|
|
147
148
|
A: [
|
|
148
149
|
"this._extensionContext!.initiator === true",
|
|
@@ -156,13 +157,13 @@ var ReplicatorExtension = class {
|
|
|
156
157
|
info
|
|
157
158
|
}, {
|
|
158
159
|
F: __dxlog_file,
|
|
159
|
-
L:
|
|
160
|
+
L: 113,
|
|
160
161
|
S: this,
|
|
161
162
|
C: (f, a) => f(...a)
|
|
162
163
|
});
|
|
163
164
|
(0, import_invariant.invariant)(this._extensionContext.initiator === false, "Invalid call", {
|
|
164
165
|
F: __dxlog_file,
|
|
165
|
-
L:
|
|
166
|
+
L: 114,
|
|
166
167
|
S: this,
|
|
167
168
|
A: [
|
|
168
169
|
"this._extensionContext!.initiator === false",
|
|
@@ -179,13 +180,13 @@ var ReplicatorExtension = class {
|
|
|
179
180
|
info
|
|
180
181
|
}, {
|
|
181
182
|
F: __dxlog_file,
|
|
182
|
-
L:
|
|
183
|
+
L: 122,
|
|
183
184
|
S: this,
|
|
184
185
|
C: (f, a) => f(...a)
|
|
185
186
|
});
|
|
186
187
|
(0, import_invariant.invariant)(this._extensionContext.initiator === false, "Invalid call", {
|
|
187
188
|
F: __dxlog_file,
|
|
188
|
-
L:
|
|
189
|
+
L: 124,
|
|
189
190
|
S: this,
|
|
190
191
|
A: [
|
|
191
192
|
"this._extensionContext!.initiator === false",
|
|
@@ -209,7 +210,7 @@ var ReplicatorExtension = class {
|
|
|
209
210
|
err
|
|
210
211
|
}, {
|
|
211
212
|
F: __dxlog_file,
|
|
212
|
-
L:
|
|
213
|
+
L: 141,
|
|
213
214
|
S: this,
|
|
214
215
|
C: (f, a) => f(...a)
|
|
215
216
|
});
|
|
@@ -224,7 +225,7 @@ var ReplicatorExtension = class {
|
|
|
224
225
|
err
|
|
225
226
|
}, {
|
|
226
227
|
F: __dxlog_file,
|
|
227
|
-
L:
|
|
228
|
+
L: 150,
|
|
228
229
|
S: this,
|
|
229
230
|
C: (f, a) => f(...a)
|
|
230
231
|
});
|
|
@@ -237,7 +238,7 @@ var ReplicatorExtension = class {
|
|
|
237
238
|
async _reevaluateFeeds() {
|
|
238
239
|
(0, import_log.log)("_reevaluateFeeds", void 0, {
|
|
239
240
|
F: __dxlog_file,
|
|
240
|
-
L:
|
|
241
|
+
L: 161,
|
|
241
242
|
S: this,
|
|
242
243
|
C: (f, a) => f(...a)
|
|
243
244
|
});
|
|
@@ -251,7 +252,7 @@ var ReplicatorExtension = class {
|
|
|
251
252
|
} catch (err) {
|
|
252
253
|
import_log.log.catch(err, void 0, {
|
|
253
254
|
F: __dxlog_file,
|
|
254
|
-
L:
|
|
255
|
+
L: 170,
|
|
255
256
|
S: this,
|
|
256
257
|
C: (f, a) => f(...a)
|
|
257
258
|
});
|
|
@@ -277,13 +278,13 @@ var ReplicatorExtension = class {
|
|
|
277
278
|
feedInfo
|
|
278
279
|
}, {
|
|
279
280
|
F: __dxlog_file,
|
|
280
|
-
L:
|
|
281
|
+
L: 191,
|
|
281
282
|
S: this,
|
|
282
283
|
C: (f, a) => f(...a)
|
|
283
284
|
});
|
|
284
285
|
(0, import_invariant.invariant)(this._extensionContext.initiator === true, "Invalid call", {
|
|
285
286
|
F: __dxlog_file,
|
|
286
|
-
L:
|
|
287
|
+
L: 192,
|
|
287
288
|
S: this,
|
|
288
289
|
A: [
|
|
289
290
|
"this._extensionContext!.initiator === true",
|
|
@@ -292,7 +293,7 @@ var ReplicatorExtension = class {
|
|
|
292
293
|
});
|
|
293
294
|
(0, import_invariant.invariant)(!this._streams.has(feedInfo.feedKey), `Replication already in progress for feed: ${feedInfo.feedKey}`, {
|
|
294
295
|
F: __dxlog_file,
|
|
295
|
-
L:
|
|
296
|
+
L: 193,
|
|
296
297
|
S: this,
|
|
297
298
|
A: [
|
|
298
299
|
"!this._streams.has(feedInfo.feedKey)",
|
|
@@ -314,7 +315,7 @@ var ReplicatorExtension = class {
|
|
|
314
315
|
async _acceptReplication(feedInfo) {
|
|
315
316
|
(0, import_invariant.invariant)(this._extensionContext.initiator === false, "Invalid call", {
|
|
316
317
|
F: __dxlog_file,
|
|
317
|
-
L:
|
|
318
|
+
L: 208,
|
|
318
319
|
S: this,
|
|
319
320
|
A: [
|
|
320
321
|
"this._extensionContext!.initiator === false",
|
|
@@ -334,13 +335,13 @@ var ReplicatorExtension = class {
|
|
|
334
335
|
streamTag
|
|
335
336
|
}, {
|
|
336
337
|
F: __dxlog_file,
|
|
337
|
-
L:
|
|
338
|
+
L: 220,
|
|
338
339
|
S: this,
|
|
339
340
|
C: (f, a) => f(...a)
|
|
340
341
|
});
|
|
341
342
|
(0, import_invariant.invariant)(!this._streams.has(info.feedKey), `Replication already in progress for feed: ${info.feedKey}`, {
|
|
342
343
|
F: __dxlog_file,
|
|
343
|
-
L:
|
|
344
|
+
L: 221,
|
|
344
345
|
S: this,
|
|
345
346
|
A: [
|
|
346
347
|
"!this._streams.has(info.feedKey)",
|
|
@@ -367,7 +368,7 @@ var ReplicatorExtension = class {
|
|
|
367
368
|
info
|
|
368
369
|
}, {
|
|
369
370
|
F: __dxlog_file,
|
|
370
|
-
L:
|
|
371
|
+
L: 257,
|
|
371
372
|
S: this,
|
|
372
373
|
C: (f, a) => f(...a)
|
|
373
374
|
});
|
|
@@ -379,7 +380,7 @@ var ReplicatorExtension = class {
|
|
|
379
380
|
info
|
|
380
381
|
}, {
|
|
381
382
|
F: __dxlog_file,
|
|
382
|
-
L:
|
|
383
|
+
L: 265,
|
|
383
384
|
S: this,
|
|
384
385
|
C: (f, a) => f(...a)
|
|
385
386
|
});
|
|
@@ -391,7 +392,7 @@ var ReplicatorExtension = class {
|
|
|
391
392
|
info
|
|
392
393
|
}, {
|
|
393
394
|
F: __dxlog_file,
|
|
394
|
-
L:
|
|
395
|
+
L: 271,
|
|
395
396
|
S: this,
|
|
396
397
|
C: (f, a) => f(...a)
|
|
397
398
|
});
|
|
@@ -402,7 +403,7 @@ var ReplicatorExtension = class {
|
|
|
402
403
|
count: replicationStreamErrors
|
|
403
404
|
}, {
|
|
404
405
|
F: __dxlog_file,
|
|
405
|
-
L:
|
|
406
|
+
L: 273,
|
|
406
407
|
S: this,
|
|
407
408
|
C: (f, a) => f(...a)
|
|
408
409
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
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 { asyncTimeout, DeferredTask, 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 {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAOA,mBAAyD;AACzD,qBAAwB;AACxB,mBAA8B;AAE9B,uBAA0B;AAC1B,kBAA0B;AAC1B,iBAA6B;AAC7B,
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2022 DXOS.org\n//\n\nimport type { ProtocolStream } from 'hypercore-protocol';\nimport { type Duplex } from 'node:stream';\n\nimport { asyncTimeout, DeferredTask, 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 { createProtoRpcPeer, type ProtoRpcPeer } 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>) {\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) {\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) {\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) {\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() {\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) {\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) {\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) {\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": ";;;;;;;;;;;;;;;;;;;;;;;AAOA,mBAAyD;AACzD,qBAAwB;AACxB,mBAA8B;AAE9B,uBAA0B;AAC1B,kBAA0B;AAC1B,iBAA6B;AAC7B,uBAA6C;AAC7C,mBAAuB;AAEvB,iBAAsD;AAEtD,kBAA2B;;;;;;;;;;;;AASpB,IAAMA,sBAAN,MAAMA;EAAN,cAAA;AACYC,SAAAA,OAAO,IAAIC,uBAAQ;MAClCC,SAAS,CAACC,QAAAA;AACR,aAAKC,mBAAmBC,MAAMF,GAAAA;MAChC;IACF,GAAA;;;;AAEiBG,SAAAA,SAAS,IAAIC,uBAAwCC,sBAAUC,IAAI;AACnEC,SAAAA,WAAW,IAAIH,uBAAoCC,sBAAUC,IAAI;AAK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D;QAAK,GAAA;;;;;;AAC7C;MACF;AAGA,UAAI8B,4BAA4B,GAAG;AACjC5C,uBAAIc,KAAK,4BAA4B;UAAEhD;UAAKgD;QAAK,GAAA;;;;;;MACnD,OAAO;AACLd,uBAAIc,KAAK,4BAA4B;UAAEhD;UAAKuB,SAASyB,KAAKzB;UAASiE,OAAOV;QAAwB,GAAA;;;;;;MACpG;AACAA;IACF,CAAA;AAEA,SAAKvE,SAAS8B,IAAIW,KAAKzB,SAAS;MAC9B0B;MACA2B;MACAG;MACA/B;IACF,CAAA;AAEA4B,kBAAca,KAAKV,iBAAAA,EAA0BU,KAAKb,aAAAA;EACpD;EAEA,MAAcxB,iBAAiB7B,SAAoB;AACjD,UAAMmE,SAAS,KAAKnF,SAASyD,IAAIzC,OAAAA;AACjC,QAAI,CAACmE,QAAQ;AACX;IACF;AAEAA,WAAOd,cAAce,QAAO;AAC5B,SAAKpF,SAASqF,OAAOrE,OAAAA;EACvB;AACF;;EAtOGsE;GAtCUjG,oBAAAA,WAAAA,iBAAAA,IAAAA;;EAkIVkG;GAlIUlG,oBAAAA,WAAAA,oBAAAA,IAAAA;;EAiLVkG;GAjLUlG,oBAAAA,WAAAA,sBAAAA,IAAAA;",
|
|
6
6
|
"names": ["ReplicatorExtension", "_ctx", "Context", "onError", "err", "_extensionContext", "close", "_feeds", "ComplexMap", "PublicKey", "hash", "_streams", "_options", "upload", "_updateTask", "DeferredTask", "initiator", "_rpc", "rpc", "ReplicatorService", "updateFeeds", "feeds", "Array", "from", "values", "map", "feed", "feedKey", "key", "download", "_reevaluateFeeds", "RpcClosedError", "extensionInfo", "localPeerId", "remotePeerId", "keys", "setOptions", "options", "log", "schedule", "addFeed", "set", "onOpen", "context", "createProtoRpcPeer", "requested", "schema", "getService", "exposed", "handlers", "invariant", "startReplication", "info", "streamTag", "_acceptReplication", "stopReplication", "_stopReplication", "port", "createPort", "contentType", "timeout", "open", "onClose", "dispose", "onAbort", "abort", "disposed", "has", "get", "asyncTimeout", "catch", "_initiateReplication", "feedInfo", "_replicateFeed", "undefined", "tag", "toHex", "random", "slice", "failUndefined", "networkStream", "createStream", "replicationStreamErrors", "replicationStream", "replicate", "live", "noise", "encrypted", "maxRequests", "on", "TimeoutError", "message", "count", "pipe", "stream", "destroy", "delete", "logInfo", "synchronized"]
|
|
7
7
|
}
|
package/dist/lib/node/meta.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs":{"packages/core/mesh/teleport-extension-replicator/src/replicator-extension.ts":{"bytes":
|
|
1
|
+
{"inputs":{"packages/core/mesh/teleport-extension-replicator/src/replicator-extension.ts":{"bytes":39372,"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"},"packages/core/mesh/teleport-extension-replicator/src/index.ts":{"bytes":552,"imports":[{"path":"packages/core/mesh/teleport-extension-replicator/src/replicator-extension.ts","kind":"import-statement","original":"./replicator-extension"}],"format":"esm"}},"outputs":{"packages/core/mesh/teleport-extension-replicator/dist/lib/node/index.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":16536},"packages/core/mesh/teleport-extension-replicator/dist/lib/node/index.cjs":{"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":"packages/core/mesh/teleport-extension-replicator/src/index.ts","inputs":{"packages/core/mesh/teleport-extension-replicator/src/replicator-extension.ts":{"bytesInOutput":11729},"packages/core/mesh/teleport-extension-replicator/src/index.ts":{"bytesInOutput":0}},"bytes":11878}}}
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
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;IAS7C,OAAO,CAAC,IAAI,EAAE,WAAW,CAAC,GAAG,CAAC;IAQxB,MAAM,CAAC,OAAO,EAAE,gBAAgB;IA8ChC,OAAO,CAAC,GAAG,CAAC,EAAE,KAAK,GAAG,SAAS;IAS/B,OAAO,CAAC,GAAG,CAAC,EAAE,KAAK,GAAG,SAAS;YAWvB,gBAAgB;IA2B9B;;OAEG;YACW,oBAAoB;IAYlC;;;OAGG;YAEW,kBAAkB;YAYlB,cAAc;YAqEd,gBAAgB;CAS/B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/teleport-extension-replicator",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.10-main.3cfcc89",
|
|
4
4
|
"description": "Replicator extension for teleport.",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -24,25 +24,25 @@
|
|
|
24
24
|
"src"
|
|
25
25
|
],
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@dxos/async": "0.6.
|
|
28
|
-
"@dxos/
|
|
29
|
-
"@dxos/
|
|
30
|
-
"@dxos/
|
|
31
|
-
"@dxos/
|
|
32
|
-
"@dxos/
|
|
33
|
-
"@dxos/
|
|
34
|
-
"@dxos/
|
|
35
|
-
"@dxos/
|
|
36
|
-
"@dxos/
|
|
37
|
-
"@dxos/
|
|
38
|
-
"@dxos/util": "0.6.
|
|
27
|
+
"@dxos/async": "0.6.10-main.3cfcc89",
|
|
28
|
+
"@dxos/debug": "0.6.10-main.3cfcc89",
|
|
29
|
+
"@dxos/invariant": "0.6.10-main.3cfcc89",
|
|
30
|
+
"@dxos/feed-store": "0.6.10-main.3cfcc89",
|
|
31
|
+
"@dxos/keys": "0.6.10-main.3cfcc89",
|
|
32
|
+
"@dxos/log": "0.6.10-main.3cfcc89",
|
|
33
|
+
"@dxos/context": "0.6.10-main.3cfcc89",
|
|
34
|
+
"@dxos/node-std": "0.6.10-main.3cfcc89",
|
|
35
|
+
"@dxos/protocols": "0.6.10-main.3cfcc89",
|
|
36
|
+
"@dxos/teleport": "0.6.10-main.3cfcc89",
|
|
37
|
+
"@dxos/rpc": "0.6.10-main.3cfcc89",
|
|
38
|
+
"@dxos/util": "0.6.10-main.3cfcc89"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"add": "^2.0.6",
|
|
42
42
|
"fast-check": "^3.19.0",
|
|
43
43
|
"typescript": "^5.5.4",
|
|
44
|
-
"@dxos/keyring": "0.6.
|
|
45
|
-
"@dxos/random-access-storage": "0.6.
|
|
44
|
+
"@dxos/keyring": "0.6.10-main.3cfcc89",
|
|
45
|
+
"@dxos/random-access-storage": "0.6.10-main.3cfcc89"
|
|
46
46
|
},
|
|
47
47
|
"publishConfig": {
|
|
48
48
|
"access": "public"
|
|
@@ -12,7 +12,8 @@ import { type FeedWrapper } from '@dxos/feed-store';
|
|
|
12
12
|
import { invariant } from '@dxos/invariant';
|
|
13
13
|
import { PublicKey } from '@dxos/keys';
|
|
14
14
|
import { log, logInfo } from '@dxos/log';
|
|
15
|
-
import {
|
|
15
|
+
import { RpcClosedError, TimeoutError } from '@dxos/protocols';
|
|
16
|
+
import { schema } from '@dxos/protocols/proto';
|
|
16
17
|
import { type FeedInfo, type ReplicatorService } from '@dxos/protocols/proto/dxos/mesh/teleport/replicator';
|
|
17
18
|
import { createProtoRpcPeer, type ProtoRpcPeer } from '@dxos/rpc';
|
|
18
19
|
import { type ExtensionContext, type TeleportExtension } from '@dxos/teleport';
|