@waku/core 0.0.34-c41b319.0 → 0.0.34-c43cec2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundle/{base_protocol-CCK9RCtH.js → base_protocol-DxFKDXX2.js} +20 -19
- package/bundle/{index-Db7LxDrL.js → index-yLOEQnIE.js} +39 -75
- package/bundle/index.js +133 -1815
- package/bundle/lib/base_protocol.js +2 -2
- package/bundle/lib/message/version_0.js +2 -2
- package/bundle/{version_0-ANFNAdFD.js → version_0-Che4t3mN.js} +42 -163
- package/dist/.tsbuildinfo +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/lib/base_protocol.d.ts +2 -2
- package/dist/lib/base_protocol.js +2 -2
- package/dist/lib/base_protocol.js.map +1 -1
- package/dist/lib/connection_manager/connection_manager.d.ts +3 -56
- package/dist/lib/connection_manager/connection_manager.js +13 -96
- package/dist/lib/connection_manager/connection_manager.js.map +1 -1
- package/dist/lib/filter/index.d.ts +18 -1
- package/dist/lib/filter/index.js +208 -1
- package/dist/lib/filter/index.js.map +1 -1
- package/dist/lib/health_manager.d.ts +14 -0
- package/dist/lib/health_manager.js +70 -0
- package/dist/lib/health_manager.js.map +1 -0
- package/dist/lib/light_push/index.d.ts +15 -1
- package/dist/lib/light_push/index.js +144 -1
- package/dist/lib/light_push/index.js.map +1 -1
- package/dist/lib/metadata/index.d.ts +3 -1
- package/dist/lib/metadata/index.js +118 -1
- package/dist/lib/metadata/index.js.map +1 -1
- package/dist/lib/store/index.d.ts +9 -1
- package/dist/lib/store/index.js +82 -1
- package/dist/lib/store/index.js.map +1 -1
- package/dist/lib/stream_manager/stream_manager.d.ts +2 -2
- package/dist/lib/stream_manager/stream_manager.js +17 -16
- package/dist/lib/stream_manager/stream_manager.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +2 -0
- package/src/lib/base_protocol.ts +3 -3
- package/src/lib/connection_manager/connection_manager.ts +20 -114
- package/src/lib/filter/index.ts +315 -1
- package/src/lib/health_manager.ts +90 -0
- package/src/lib/light_push/index.ts +189 -1
- package/src/lib/metadata/index.ts +182 -1
- package/src/lib/store/index.ts +136 -1
- package/src/lib/stream_manager/stream_manager.ts +18 -16
- package/dist/lib/filter/filter.d.ts +0 -18
- package/dist/lib/filter/filter.js +0 -209
- package/dist/lib/filter/filter.js.map +0 -1
- package/dist/lib/light_push/light_push.d.ts +0 -15
- package/dist/lib/light_push/light_push.js +0 -144
- package/dist/lib/light_push/light_push.js.map +0 -1
- package/dist/lib/metadata/metadata.d.ts +0 -3
- package/dist/lib/metadata/metadata.js +0 -119
- package/dist/lib/metadata/metadata.js.map +0 -1
- package/dist/lib/store/store.d.ts +0 -9
- package/dist/lib/store/store.js +0 -83
- package/dist/lib/store/store.js.map +0 -1
- package/src/lib/filter/filter.ts +0 -315
- package/src/lib/light_push/light_push.ts +0 -188
- package/src/lib/metadata/metadata.ts +0 -182
- package/src/lib/store/store.ts +0 -136
@@ -1,4 +1,4 @@
|
|
1
|
-
import { L as Logger } from './index-
|
1
|
+
import { L as Logger } from './index-yLOEQnIE.js';
|
2
2
|
|
3
3
|
function selectOpenConnection(connections) {
|
4
4
|
return connections
|
@@ -22,36 +22,36 @@ class StreamManager {
|
|
22
22
|
this.log = new Logger(`stream-manager:${multicodec}`);
|
23
23
|
this.addEventListener("peer:update", this.handlePeerUpdateStreamPool);
|
24
24
|
}
|
25
|
-
async getStream(
|
26
|
-
const
|
27
|
-
const scheduledStream = this.streamPool.get(
|
25
|
+
async getStream(peer) {
|
26
|
+
const peerId = peer.id.toString();
|
27
|
+
const scheduledStream = this.streamPool.get(peerId);
|
28
28
|
if (scheduledStream) {
|
29
|
-
this.streamPool.delete(
|
29
|
+
this.streamPool.delete(peerId);
|
30
30
|
await scheduledStream;
|
31
31
|
}
|
32
|
-
let stream = this.getOpenStreamForCodec(
|
32
|
+
let stream = this.getOpenStreamForCodec(peer.id);
|
33
33
|
if (stream) {
|
34
|
-
this.log.info(`Found existing stream peerId=${
|
35
|
-
this.lockStream(
|
34
|
+
this.log.info(`Found existing stream peerId=${peer.id.toString()} multicodec=${this.multicodec}`);
|
35
|
+
this.lockStream(peer.id.toString(), stream);
|
36
36
|
return stream;
|
37
37
|
}
|
38
|
-
stream = await this.createStream(
|
39
|
-
this.lockStream(
|
38
|
+
stream = await this.createStream(peer);
|
39
|
+
this.lockStream(peer.id.toString(), stream);
|
40
40
|
return stream;
|
41
41
|
}
|
42
|
-
async createStream(
|
43
|
-
const connections = this.getConnections(
|
42
|
+
async createStream(peer, retries = 0) {
|
43
|
+
const connections = this.getConnections(peer.id);
|
44
44
|
const connection = selectOpenConnection(connections);
|
45
45
|
if (!connection) {
|
46
|
-
throw new Error(`Failed to get a connection to the peer peerId=${
|
46
|
+
throw new Error(`Failed to get a connection to the peer peerId=${peer.id.toString()} multicodec=${this.multicodec}`);
|
47
47
|
}
|
48
48
|
let lastError;
|
49
49
|
let stream;
|
50
50
|
for (let i = 0; i < retries + 1; i++) {
|
51
51
|
try {
|
52
|
-
this.log.info(`Attempting to create a stream for peerId=${
|
52
|
+
this.log.info(`Attempting to create a stream for peerId=${peer.id.toString()} multicodec=${this.multicodec}`);
|
53
53
|
stream = await connection.newStream(this.multicodec);
|
54
|
-
this.log.info(`Created stream for peerId=${
|
54
|
+
this.log.info(`Created stream for peerId=${peer.id.toString()} multicodec=${this.multicodec}`);
|
55
55
|
break;
|
56
56
|
}
|
57
57
|
catch (error) {
|
@@ -59,7 +59,8 @@ class StreamManager {
|
|
59
59
|
}
|
60
60
|
}
|
61
61
|
if (!stream) {
|
62
|
-
throw new Error(`Failed to create a new stream for ${
|
62
|
+
throw new Error(`Failed to create a new stream for ${peer.id.toString()} -- ` +
|
63
|
+
lastError);
|
63
64
|
}
|
64
65
|
return stream;
|
65
66
|
}
|
@@ -71,7 +72,7 @@ class StreamManager {
|
|
71
72
|
}
|
72
73
|
try {
|
73
74
|
this.ongoingCreation.add(peerId);
|
74
|
-
await this.createStream(peer
|
75
|
+
await this.createStream(peer);
|
75
76
|
}
|
76
77
|
catch (error) {
|
77
78
|
this.log.error(`Failed to createStreamWithLock:`, error);
|
@@ -144,8 +145,8 @@ class BaseProtocol {
|
|
144
145
|
this.removeLibp2pEventListener = components.events.removeEventListener.bind(components.events);
|
145
146
|
this.streamManager = new StreamManager(multicodec, components.connectionManager.getConnections.bind(components.connectionManager), this.addLibp2pEventListener);
|
146
147
|
}
|
147
|
-
async getStream(
|
148
|
-
return this.streamManager.getStream(
|
148
|
+
async getStream(peer) {
|
149
|
+
return this.streamManager.getStream(peer);
|
149
150
|
}
|
150
151
|
}
|
151
152
|
|
@@ -1,16 +1,3 @@
|
|
1
|
-
function equals(aa, bb) {
|
2
|
-
if (aa === bb)
|
3
|
-
return true;
|
4
|
-
if (aa.byteLength !== bb.byteLength) {
|
5
|
-
return false;
|
6
|
-
}
|
7
|
-
for (let ii = 0; ii < aa.byteLength; ii++) {
|
8
|
-
if (aa[ii] !== bb[ii]) {
|
9
|
-
return false;
|
10
|
-
}
|
11
|
-
}
|
12
|
-
return true;
|
13
|
-
}
|
14
1
|
function coerce(o) {
|
15
2
|
if (o instanceof Uint8Array && o.constructor.name === 'Uint8Array')
|
16
3
|
return o;
|
@@ -759,10 +746,6 @@ var EConnectionStateEvents;
|
|
759
746
|
EConnectionStateEvents["CONNECTION_STATUS"] = "waku:connection";
|
760
747
|
})(EConnectionStateEvents || (EConnectionStateEvents = {}));
|
761
748
|
|
762
|
-
var HealthStatusChangeEvents;
|
763
|
-
(function (HealthStatusChangeEvents) {
|
764
|
-
HealthStatusChangeEvents["StatusChange"] = "health:change";
|
765
|
-
})(HealthStatusChangeEvents || (HealthStatusChangeEvents = {}));
|
766
749
|
var HealthStatus;
|
767
750
|
(function (HealthStatus) {
|
768
751
|
HealthStatus["Unhealthy"] = "Unhealthy";
|
@@ -1114,62 +1097,24 @@ function setup(env) {
|
|
1114
1097
|
createDebug.names = [];
|
1115
1098
|
createDebug.skips = [];
|
1116
1099
|
|
1117
|
-
|
1118
|
-
|
1119
|
-
|
1120
|
-
.split(',')
|
1121
|
-
.filter(Boolean);
|
1100
|
+
let i;
|
1101
|
+
const split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/);
|
1102
|
+
const len = split.length;
|
1122
1103
|
|
1123
|
-
for (
|
1124
|
-
if (
|
1125
|
-
|
1126
|
-
|
1127
|
-
createDebug.names.push(ns);
|
1104
|
+
for (i = 0; i < len; i++) {
|
1105
|
+
if (!split[i]) {
|
1106
|
+
// ignore empty strings
|
1107
|
+
continue;
|
1128
1108
|
}
|
1129
|
-
}
|
1130
|
-
}
|
1131
1109
|
|
1132
|
-
|
1133
|
-
|
1134
|
-
|
1135
|
-
|
1136
|
-
* @param {String} search
|
1137
|
-
* @param {String} template
|
1138
|
-
* @return {Boolean}
|
1139
|
-
*/
|
1140
|
-
function matchesTemplate(search, template) {
|
1141
|
-
let searchIndex = 0;
|
1142
|
-
let templateIndex = 0;
|
1143
|
-
let starIndex = -1;
|
1144
|
-
let matchIndex = 0;
|
1145
|
-
|
1146
|
-
while (searchIndex < search.length) {
|
1147
|
-
if (templateIndex < template.length && (template[templateIndex] === search[searchIndex] || template[templateIndex] === '*')) {
|
1148
|
-
// Match character or proceed with wildcard
|
1149
|
-
if (template[templateIndex] === '*') {
|
1150
|
-
starIndex = templateIndex;
|
1151
|
-
matchIndex = searchIndex;
|
1152
|
-
templateIndex++; // Skip the '*'
|
1153
|
-
} else {
|
1154
|
-
searchIndex++;
|
1155
|
-
templateIndex++;
|
1156
|
-
}
|
1157
|
-
} else if (starIndex !== -1) { // eslint-disable-line no-negated-condition
|
1158
|
-
// Backtrack to the last '*' and try to match more characters
|
1159
|
-
templateIndex = starIndex + 1;
|
1160
|
-
matchIndex++;
|
1161
|
-
searchIndex = matchIndex;
|
1110
|
+
namespaces = split[i].replace(/\*/g, '.*?');
|
1111
|
+
|
1112
|
+
if (namespaces[0] === '-') {
|
1113
|
+
createDebug.skips.push(new RegExp('^' + namespaces.slice(1) + '$'));
|
1162
1114
|
} else {
|
1163
|
-
|
1115
|
+
createDebug.names.push(new RegExp('^' + namespaces + '$'));
|
1164
1116
|
}
|
1165
1117
|
}
|
1166
|
-
|
1167
|
-
// Handle trailing '*' in template
|
1168
|
-
while (templateIndex < template.length && template[templateIndex] === '*') {
|
1169
|
-
templateIndex++;
|
1170
|
-
}
|
1171
|
-
|
1172
|
-
return templateIndex === template.length;
|
1173
1118
|
}
|
1174
1119
|
|
1175
1120
|
/**
|
@@ -1180,8 +1125,8 @@ function setup(env) {
|
|
1180
1125
|
*/
|
1181
1126
|
function disable() {
|
1182
1127
|
const namespaces = [
|
1183
|
-
...createDebug.names,
|
1184
|
-
...createDebug.skips.map(namespace => '-' + namespace)
|
1128
|
+
...createDebug.names.map(toNamespace),
|
1129
|
+
...createDebug.skips.map(toNamespace).map(namespace => '-' + namespace)
|
1185
1130
|
].join(',');
|
1186
1131
|
createDebug.enable('');
|
1187
1132
|
return namespaces;
|
@@ -1195,14 +1140,21 @@ function setup(env) {
|
|
1195
1140
|
* @api public
|
1196
1141
|
*/
|
1197
1142
|
function enabled(name) {
|
1198
|
-
|
1199
|
-
|
1143
|
+
if (name[name.length - 1] === '*') {
|
1144
|
+
return true;
|
1145
|
+
}
|
1146
|
+
|
1147
|
+
let i;
|
1148
|
+
let len;
|
1149
|
+
|
1150
|
+
for (i = 0, len = createDebug.skips.length; i < len; i++) {
|
1151
|
+
if (createDebug.skips[i].test(name)) {
|
1200
1152
|
return false;
|
1201
1153
|
}
|
1202
1154
|
}
|
1203
1155
|
|
1204
|
-
for (
|
1205
|
-
if (
|
1156
|
+
for (i = 0, len = createDebug.names.length; i < len; i++) {
|
1157
|
+
if (createDebug.names[i].test(name)) {
|
1206
1158
|
return true;
|
1207
1159
|
}
|
1208
1160
|
}
|
@@ -1210,6 +1162,19 @@ function setup(env) {
|
|
1210
1162
|
return false;
|
1211
1163
|
}
|
1212
1164
|
|
1165
|
+
/**
|
1166
|
+
* Convert regexp to namespace
|
1167
|
+
*
|
1168
|
+
* @param {RegExp} regxep
|
1169
|
+
* @return {String} namespace
|
1170
|
+
* @api private
|
1171
|
+
*/
|
1172
|
+
function toNamespace(regexp) {
|
1173
|
+
return regexp.toString()
|
1174
|
+
.substring(2, regexp.toString().length - 2)
|
1175
|
+
.replace(/\.\*\?$/, '*');
|
1176
|
+
}
|
1177
|
+
|
1213
1178
|
/**
|
1214
1179
|
* Coerce `val`.
|
1215
1180
|
*
|
@@ -1371,7 +1336,6 @@ var common = setup;
|
|
1371
1336
|
|
1372
1337
|
// Is webkit? http://stackoverflow.com/a/16459606/376773
|
1373
1338
|
// document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
|
1374
|
-
// eslint-disable-next-line no-return-assign
|
1375
1339
|
return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||
|
1376
1340
|
// Is firebug? http://stackoverflow.com/a/398120/376773
|
1377
1341
|
(typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||
|
@@ -1545,4 +1509,4 @@ class Logger {
|
|
1545
1509
|
}
|
1546
1510
|
}
|
1547
1511
|
|
1548
|
-
export { EPeersByDiscoveryEvents as E, Logger as L, ProtocolError as P, Tags as T,
|
1512
|
+
export { EPeersByDiscoveryEvents as E, HealthStatus as H, Logger as L, ProtocolError as P, Tags as T, EConnectionStateEvents as a, Protocols as b, base2$1 as c, base8$1 as d, base10$1 as e, base16$1 as f, base32$1 as g, base36$1 as h, identityBase as i, base58 as j, base64$1 as k, base256emoji$1 as l };
|