@libp2p/mplex 8.0.2 → 8.0.4-05abd49f

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.
@@ -1 +1 @@
1
- {"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../../src/stream.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AACjD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAW7C,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,IAAI,CAAA;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,KAAK,IAAI,CAAA;IAC7B,IAAI,CAAC,EAAE,WAAW,GAAG,UAAU,CAAA;IAC/B,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB;AAED,wBAAgB,YAAY,CAAE,OAAO,EAAE,OAAO,GAAG,WAAW,CA8N3D"}
1
+ {"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../../src/stream.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,KAAK,kBAAkB,EAAE,MAAM,uCAAuC,CAAA;AAC/F,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAI/C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AAEjD,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,IAAI,CAAA;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,KAAK,IAAI,CAAA;IAC7B,IAAI,CAAC,EAAE,WAAW,GAAG,UAAU,CAAA;IAC/B,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB;AAED,UAAU,eAAgB,SAAQ,kBAAkB;IAClD,QAAQ,EAAE,MAAM,CAAA;IAChB,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,IAAI,CAAA;CAC7B;AAED,cAAM,WAAY,SAAQ,cAAc;IACtC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAQ;IAC7B,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAQ;IACjC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAwB;IAC7C,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAwB;gBAEjC,IAAI,EAAE,eAAe;IASlC,aAAa,IAAK,IAAI;IAItB,QAAQ,CAAE,IAAI,EAAE,cAAc,GAAG,IAAI;IAIrC,SAAS,IAAK,IAAI;IAIlB,cAAc,IAAK,IAAI;IAIvB,aAAa,IAAK,IAAI;CAGvB;AAED,wBAAgB,YAAY,CAAE,OAAO,EAAE,OAAO,GAAG,WAAW,CAY3D"}
@@ -1,198 +1,46 @@
1
- import { CodeError } from '@libp2p/interfaces/errors';
2
- import { logger } from '@libp2p/logger';
3
- import { abortableSource } from 'abortable-iterator';
4
- import { anySignal } from 'any-signal';
5
- import { pushable } from 'it-pushable';
1
+ import { AbstractStream } from '@libp2p/interface/stream-muxer/stream';
6
2
  import { Uint8ArrayList } from 'uint8arraylist';
7
3
  import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string';
8
4
  import { MAX_MSG_SIZE } from './decode.js';
9
5
  import { InitiatorMessageTypes, ReceiverMessageTypes } from './message-types.js';
10
- const log = logger('libp2p:mplex:stream');
11
- const ERR_STREAM_RESET = 'ERR_STREAM_RESET';
12
- const ERR_STREAM_ABORT = 'ERR_STREAM_ABORT';
13
- const ERR_SINK_ENDED = 'ERR_SINK_ENDED';
14
- const ERR_DOUBLE_SINK = 'ERR_DOUBLE_SINK';
6
+ class MplexStream extends AbstractStream {
7
+ name;
8
+ streamId;
9
+ send;
10
+ types;
11
+ constructor(init) {
12
+ super(init);
13
+ this.types = init.direction === 'outbound' ? InitiatorMessageTypes : ReceiverMessageTypes;
14
+ this.send = init.send;
15
+ this.name = init.name;
16
+ this.streamId = init.streamId;
17
+ }
18
+ sendNewStream() {
19
+ this.send({ id: this.streamId, type: InitiatorMessageTypes.NEW_STREAM, data: new Uint8ArrayList(uint8ArrayFromString(this.name)) });
20
+ }
21
+ sendData(data) {
22
+ this.send({ id: this.streamId, type: this.types.MESSAGE, data });
23
+ }
24
+ sendReset() {
25
+ this.send({ id: this.streamId, type: this.types.RESET });
26
+ }
27
+ sendCloseWrite() {
28
+ this.send({ id: this.streamId, type: this.types.CLOSE });
29
+ }
30
+ sendCloseRead() {
31
+ // mplex does not support close read, only close write
32
+ }
33
+ }
15
34
  export function createStream(options) {
16
35
  const { id, name, send, onEnd, type = 'initiator', maxMsgSize = MAX_MSG_SIZE } = options;
17
- const abortController = new AbortController();
18
- const resetController = new AbortController();
19
- const closeController = new AbortController();
20
- const Types = type === 'initiator' ? InitiatorMessageTypes : ReceiverMessageTypes;
21
- const externalId = type === 'initiator' ? (`i${id}`) : `r${id}`;
22
- const streamName = `${name == null ? id : name}`;
23
- let sourceEnded = false;
24
- let sinkEnded = false;
25
- let sinkSunk = false;
26
- let endErr;
27
- const timeline = {
28
- open: Date.now()
29
- };
30
- const onSourceEnd = (err) => {
31
- if (sourceEnded) {
32
- return;
33
- }
34
- sourceEnded = true;
35
- log.trace('%s stream %s source end - err: %o', type, streamName, err);
36
- if (err != null && endErr == null) {
37
- endErr = err;
38
- }
39
- if (sinkEnded) {
40
- stream.stat.timeline.close = Date.now();
41
- if (onEnd != null) {
42
- onEnd(endErr);
43
- }
44
- }
45
- };
46
- const onSinkEnd = (err) => {
47
- if (sinkEnded) {
48
- return;
49
- }
50
- sinkEnded = true;
51
- log.trace('%s stream %s sink end - err: %o', type, streamName, err);
52
- if (err != null && endErr == null) {
53
- endErr = err;
54
- }
55
- if (sourceEnded) {
56
- timeline.close = Date.now();
57
- if (onEnd != null) {
58
- onEnd(endErr);
59
- }
60
- }
61
- };
62
- const streamSource = pushable({
63
- onEnd: onSourceEnd
36
+ return new MplexStream({
37
+ id: type === 'initiator' ? (`i${id}`) : `r${id}`,
38
+ streamId: id,
39
+ name: `${name == null ? id : name}`,
40
+ direction: type === 'initiator' ? 'outbound' : 'inbound',
41
+ maxDataSize: maxMsgSize,
42
+ onEnd,
43
+ send
64
44
  });
65
- const stream = {
66
- // Close for both Reading and Writing
67
- close: () => {
68
- log.trace('%s stream %s close', type, streamName);
69
- stream.closeRead();
70
- stream.closeWrite();
71
- },
72
- // Close for reading
73
- closeRead: () => {
74
- log.trace('%s stream %s closeRead', type, streamName);
75
- if (sourceEnded) {
76
- return;
77
- }
78
- streamSource.end();
79
- },
80
- // Close for writing
81
- closeWrite: () => {
82
- log.trace('%s stream %s closeWrite', type, streamName);
83
- if (sinkEnded) {
84
- return;
85
- }
86
- closeController.abort();
87
- try {
88
- send({ id, type: Types.CLOSE });
89
- }
90
- catch (err) {
91
- log.trace('%s stream %s error sending close', type, name, err);
92
- }
93
- onSinkEnd();
94
- },
95
- // Close for reading and writing (local error)
96
- abort: (err) => {
97
- log.trace('%s stream %s abort', type, streamName, err);
98
- // End the source with the passed error
99
- streamSource.end(err);
100
- abortController.abort();
101
- onSinkEnd(err);
102
- },
103
- // Close immediately for reading and writing (remote error)
104
- reset: () => {
105
- const err = new CodeError('stream reset', ERR_STREAM_RESET);
106
- resetController.abort();
107
- streamSource.end(err);
108
- onSinkEnd(err);
109
- },
110
- sink: async (source) => {
111
- if (sinkSunk) {
112
- throw new CodeError('sink already called on stream', ERR_DOUBLE_SINK);
113
- }
114
- sinkSunk = true;
115
- if (sinkEnded) {
116
- throw new CodeError('stream closed for writing', ERR_SINK_ENDED);
117
- }
118
- const signal = anySignal([
119
- abortController.signal,
120
- resetController.signal,
121
- closeController.signal
122
- ]);
123
- try {
124
- source = abortableSource(source, signal);
125
- if (type === 'initiator') { // If initiator, open a new stream
126
- send({ id, type: InitiatorMessageTypes.NEW_STREAM, data: new Uint8ArrayList(uint8ArrayFromString(streamName)) });
127
- }
128
- for await (let data of source) {
129
- while (data.length > 0) {
130
- if (data.length <= maxMsgSize) {
131
- send({ id, type: Types.MESSAGE, data: data instanceof Uint8Array ? new Uint8ArrayList(data) : data });
132
- break;
133
- }
134
- data = data instanceof Uint8Array ? new Uint8ArrayList(data) : data;
135
- send({ id, type: Types.MESSAGE, data: data.sublist(0, maxMsgSize) });
136
- data.consume(maxMsgSize);
137
- }
138
- }
139
- }
140
- catch (err) {
141
- if (err.type === 'aborted' && err.message === 'The operation was aborted') {
142
- if (closeController.signal.aborted) {
143
- return;
144
- }
145
- if (resetController.signal.aborted) {
146
- err.message = 'stream reset';
147
- err.code = ERR_STREAM_RESET;
148
- }
149
- if (abortController.signal.aborted) {
150
- err.message = 'stream aborted';
151
- err.code = ERR_STREAM_ABORT;
152
- }
153
- }
154
- // Send no more data if this stream was remotely reset
155
- if (err.code === ERR_STREAM_RESET) {
156
- log.trace('%s stream %s reset', type, name);
157
- }
158
- else {
159
- log.trace('%s stream %s error', type, name, err);
160
- try {
161
- send({ id, type: Types.RESET });
162
- }
163
- catch (err) {
164
- log.trace('%s stream %s error sending reset', type, name, err);
165
- }
166
- }
167
- streamSource.end(err);
168
- onSinkEnd(err);
169
- return;
170
- }
171
- finally {
172
- signal.clear();
173
- }
174
- try {
175
- send({ id, type: Types.CLOSE });
176
- }
177
- catch (err) {
178
- log.trace('%s stream %s error sending close', type, name, err);
179
- }
180
- onSinkEnd();
181
- },
182
- source: streamSource,
183
- sourcePush: (data) => {
184
- streamSource.push(data);
185
- },
186
- sourceReadableLength() {
187
- return streamSource.readableLength;
188
- },
189
- stat: {
190
- direction: type === 'initiator' ? 'outbound' : 'inbound',
191
- timeline
192
- },
193
- metadata: {},
194
- id: externalId
195
- };
196
- return stream;
197
45
  }
198
46
  //# sourceMappingURL=stream.js.map
@@ -1 +1 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AAE,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,CAAA;IAC1D,CAAC;IAED,cAAc;QACZ,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,CAAA;IAC1D,CAAC;IAED,aAAa;QACX,sDAAsD;IACxD,CAAC;CACF;AAED,MAAM,UAAU,YAAY,CAAE,OAAgB;IAC5C,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,GAAG,WAAW,EAAE,UAAU,GAAG,YAAY,EAAE,GAAG,OAAO,CAAA;IAExF,OAAO,IAAI,WAAW,CAAC;QACrB,EAAE,EAAE,IAAI,KAAK,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE;QAChD,QAAQ,EAAE,EAAE;QACZ,IAAI,EAAE,GAAG,IAAI,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE;QACnC,SAAS,EAAE,IAAI,KAAK,WAAW,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS;QACxD,WAAW,EAAE,UAAU;QACvB,KAAK;QACL,IAAI;KACL,CAAC,CAAA;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "@libp2p/mplex",
3
- "version": "8.0.2",
3
+ "version": "8.0.4-05abd49f",
4
4
  "description": "JavaScript implementation of https://github.com/libp2p/mplex",
5
5
  "license": "Apache-2.0 OR MIT",
6
- "homepage": "https://github.com/libp2p/js-libp2p-mplex#readme",
6
+ "homepage": "https://github.com/libp2p/js-libp2p/tree/master/packages/stream-multiplexer-mplex#readme",
7
7
  "repository": {
8
8
  "type": "git",
9
- "url": "git+https://github.com/libp2p/js-libp2p-mplex.git"
9
+ "url": "git+https://github.com/libp2p/js-libp2p.git"
10
10
  },
11
11
  "bugs": {
12
- "url": "https://github.com/libp2p/js-libp2p-mplex/issues"
12
+ "url": "https://github.com/libp2p/js-libp2p/issues"
13
13
  },
14
14
  "keywords": [
15
15
  "IPFS",
@@ -21,10 +21,6 @@
21
21
  "muxer",
22
22
  "stream"
23
23
  ],
24
- "engines": {
25
- "node": ">=16.0.0",
26
- "npm": ">=7.0.0"
27
- },
28
24
  "type": "module",
29
25
  "types": "./dist/src/index.d.ts",
30
26
  "files": [
@@ -45,91 +41,6 @@
45
41
  "sourceType": "module"
46
42
  }
47
43
  },
48
- "release": {
49
- "branches": [
50
- "master"
51
- ],
52
- "plugins": [
53
- [
54
- "@semantic-release/commit-analyzer",
55
- {
56
- "preset": "conventionalcommits",
57
- "releaseRules": [
58
- {
59
- "breaking": true,
60
- "release": "major"
61
- },
62
- {
63
- "revert": true,
64
- "release": "patch"
65
- },
66
- {
67
- "type": "feat",
68
- "release": "minor"
69
- },
70
- {
71
- "type": "fix",
72
- "release": "patch"
73
- },
74
- {
75
- "type": "docs",
76
- "release": "patch"
77
- },
78
- {
79
- "type": "test",
80
- "release": "patch"
81
- },
82
- {
83
- "type": "deps",
84
- "release": "patch"
85
- },
86
- {
87
- "scope": "no-release",
88
- "release": false
89
- }
90
- ]
91
- }
92
- ],
93
- [
94
- "@semantic-release/release-notes-generator",
95
- {
96
- "preset": "conventionalcommits",
97
- "presetConfig": {
98
- "types": [
99
- {
100
- "type": "feat",
101
- "section": "Features"
102
- },
103
- {
104
- "type": "fix",
105
- "section": "Bug Fixes"
106
- },
107
- {
108
- "type": "chore",
109
- "section": "Trivial Changes"
110
- },
111
- {
112
- "type": "docs",
113
- "section": "Documentation"
114
- },
115
- {
116
- "type": "deps",
117
- "section": "Dependencies"
118
- },
119
- {
120
- "type": "test",
121
- "section": "Tests"
122
- }
123
- ]
124
- }
125
- }
126
- ],
127
- "@semantic-release/changelog",
128
- "@semantic-release/npm",
129
- "@semantic-release/github",
130
- "@semantic-release/git"
131
- ]
132
- },
133
44
  "scripts": {
134
45
  "clean": "aegir clean",
135
46
  "lint": "aegir lint",
@@ -142,37 +53,33 @@
142
53
  "test:firefox": "aegir test -t browser -- --browser firefox",
143
54
  "test:firefox-webworker": "aegir test -t webworker -- --browser firefox",
144
55
  "test:node": "aegir test -t node --cov",
145
- "test:electron-main": "aegir test -t electron-main",
146
- "release": "aegir release",
147
- "docs": "aegir docs"
56
+ "test:electron-main": "aegir test -t electron-main"
148
57
  },
149
58
  "dependencies": {
150
- "@libp2p/interface-connection": "^5.0.0",
151
- "@libp2p/interface-stream-muxer": "^4.0.0",
152
- "@libp2p/interfaces": "^3.2.0",
153
- "@libp2p/logger": "^2.0.0",
154
- "abortable-iterator": "^5.0.0",
155
- "any-signal": "^4.0.1",
59
+ "@libp2p/interface": "0.0.1-05abd49f",
60
+ "@libp2p/logger": "2.1.1-05abd49f",
61
+ "abortable-iterator": "^5.0.1",
62
+ "any-signal": "^4.1.1",
156
63
  "benchmark": "^2.1.4",
157
64
  "it-batched-bytes": "^2.0.2",
158
- "it-pushable": "^3.1.0",
65
+ "it-pushable": "^3.1.3",
159
66
  "it-stream-types": "^2.0.1",
160
- "rate-limiter-flexible": "^2.3.9",
161
- "uint8arraylist": "^2.1.1",
162
- "uint8arrays": "^4.0.2",
67
+ "rate-limiter-flexible": "^2.3.11",
68
+ "uint8arraylist": "^2.4.3",
69
+ "uint8arrays": "^4.0.4",
163
70
  "varint": "^6.0.0"
164
71
  },
165
72
  "devDependencies": {
166
- "@libp2p/interface-stream-muxer-compliance-tests": "^7.0.0",
73
+ "@libp2p/interface-compliance-tests": "3.0.7-05abd49f",
167
74
  "@types/varint": "^6.0.0",
168
- "aegir": "^39.0.7",
169
- "cborg": "^1.8.1",
170
- "delay": "^5.0.0",
75
+ "aegir": "^39.0.10",
76
+ "cborg": "^2.0.1",
77
+ "delay": "^6.0.0",
171
78
  "iso-random-stream": "^2.0.2",
172
79
  "it-all": "^3.0.1",
173
- "it-drain": "^3.0.1",
80
+ "it-drain": "^3.0.2",
174
81
  "it-foreach": "^2.0.2",
175
- "it-map": "^3.0.1",
82
+ "it-map": "^3.0.3",
176
83
  "it-pipe": "^3.0.1",
177
84
  "it-to-buffer": "^4.0.1",
178
85
  "p-defer": "^4.0.0",
@@ -180,5 +87,8 @@
180
87
  },
181
88
  "browser": {
182
89
  "./dist/src/alloc-unsafe.js": "./dist/src/alloc-unsafe-browser.js"
90
+ },
91
+ "typedoc": {
92
+ "entryPoint": "./src/index.ts"
183
93
  }
184
94
  }
package/src/index.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { MplexStreamMuxer } from './mplex.js'
2
- import type { StreamMuxer, StreamMuxerFactory, StreamMuxerInit } from '@libp2p/interface-stream-muxer'
2
+ import type { StreamMuxer, StreamMuxerFactory, StreamMuxerInit } from '@libp2p/interface/stream-muxer'
3
3
 
4
4
  export interface MplexInit {
5
5
  /**
package/src/mplex.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { CodeError } from '@libp2p/interfaces/errors'
1
+ import { CodeError } from '@libp2p/interface/errors'
2
2
  import { logger } from '@libp2p/logger'
3
3
  import { abortableSource } from 'abortable-iterator'
4
4
  import { anySignal } from 'any-signal'
@@ -10,8 +10,8 @@ import { encode } from './encode.js'
10
10
  import { MessageTypes, MessageTypeNames, type Message } from './message-types.js'
11
11
  import { createStream } from './stream.js'
12
12
  import type { MplexInit } from './index.js'
13
- import type { Stream } from '@libp2p/interface-connection'
14
- import type { StreamMuxer, StreamMuxerInit } from '@libp2p/interface-stream-muxer'
13
+ import type { Stream } from '@libp2p/interface/connection'
14
+ import type { StreamMuxer, StreamMuxerInit } from '@libp2p/interface/stream-muxer'
15
15
  import type { Sink, Source } from 'it-stream-types'
16
16
  import type { Uint8ArrayList } from 'uint8arraylist'
17
17