chore: add '.js' extensions to local import

As per ESM standard.
This commit is contained in:
fryorcraken.eth 2022-12-02 15:43:46 +11:00
parent e678b84119
commit 88c6ec6ef4
No known key found for this signature in database
GPG Key ID: A82ED75A8DFC50A4
38 changed files with 266 additions and 270 deletions

206
package-lock.json generated
View File

@ -984,6 +984,19 @@
"uint8arraylist": "^2.3.2"
}
},
"node_modules/@libp2p/interface-address-manager": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/@libp2p/interface-address-manager/-/interface-address-manager-2.0.1.tgz",
"integrity": "sha512-JjlQUJ0cF1h0wsOS22PNRQiiiMLwftd5QttjJK2jDsou5FkZETeQ9eYL05I0ykQKZvEJqwH8G5WLwxWtwsj7Ag==",
"dependencies": {
"@libp2p/interfaces": "^3.0.0",
"@multiformats/multiaddr": "^11.0.0"
},
"engines": {
"node": ">=16.0.0",
"npm": ">=7.0.0"
}
},
"node_modules/@libp2p/interface-connection": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/@libp2p/interface-connection/-/interface-connection-3.0.3.tgz",
@ -1015,9 +1028,9 @@
}
},
"node_modules/@libp2p/interface-connection-manager": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/@libp2p/interface-connection-manager/-/interface-connection-manager-1.3.0.tgz",
"integrity": "sha512-25tlCE8ECX/ARP+yV+j2+MQeZ9+HfzvwYEU2TymywP83Q5v6oKZM8pmS51yiNwcKPZMMZiHQk1eFmaOrJB25zQ==",
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/@libp2p/interface-connection-manager/-/interface-connection-manager-1.3.1.tgz",
"integrity": "sha512-aaRFzpIU6f2DKo6q9fx7W3xPfT2iW/J5mnGTHvvndCtPGmoziCY90cFYJiZ4nJJfX5YKs+v/kDTztXVWgPA9Nw==",
"dependencies": {
"@libp2p/interface-connection": "^3.0.0",
"@libp2p/interface-peer-id": "^1.0.0",
@ -1030,9 +1043,9 @@
}
},
"node_modules/@libp2p/interface-content-routing": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/@libp2p/interface-content-routing/-/interface-content-routing-1.0.3.tgz",
"integrity": "sha512-8oARfHOkf3NAMaDQWBM3nbVNg+Skj1hjGAjomakZ/jZPjOjbQ9BfPZAsrnDRrV0snnnJNrxiYz6w58y8ehg+cA==",
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/@libp2p/interface-content-routing/-/interface-content-routing-1.0.4.tgz",
"integrity": "sha512-zJn7wH8KWaAdlc6kNUMsq9cYx1bEdTj0yAEhzIsrfdXX/XTlBqCeWmMBuFMwj4vBp0pKI0nlt3fUHON1cIGX1w==",
"dependencies": {
"@libp2p/interface-peer-info": "^1.0.0",
"@libp2p/interfaces": "^3.0.0",
@ -1044,9 +1057,9 @@
}
},
"node_modules/@libp2p/interface-dht": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/@libp2p/interface-dht/-/interface-dht-1.0.2.tgz",
"integrity": "sha512-vBMR90VFQbNwUdgf7yYO6buDP8K6srb+Z0KdoHMklZd9UIx6k/SVUANkHWw/tGAX4C2EZ0qMdSiivkJg2dcPjg==",
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/@libp2p/interface-dht/-/interface-dht-1.0.3.tgz",
"integrity": "sha512-8SuGn2QIztqHjMPZLNKAZ+UlWc4EDB9rIt53KfjWZnQrRJzkyqFYXvT9VhnqtFX7iblf4N4I3Z42OFAM8ezCvg==",
"dependencies": {
"@libp2p/interface-peer-discovery": "^1.0.0",
"@libp2p/interface-peer-id": "^1.0.0",
@ -1120,9 +1133,9 @@
}
},
"node_modules/@libp2p/interface-peer-routing": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/@libp2p/interface-peer-routing/-/interface-peer-routing-1.0.1.tgz",
"integrity": "sha512-MKx2g0mIUI6qNuLv3xApKXR2ZrO9CUTT9ZPL0gvRlhpFCXovEkdWJ1h8KnmkR7tGPxKHt2bsCCJ8gqUaFeNstA==",
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/@libp2p/interface-peer-routing/-/interface-peer-routing-1.0.2.tgz",
"integrity": "sha512-TPv9ALS3FUG+q95jyvT0jOQd2k17bdzn0jw0nGwTo7beoeRMVehTHAXPn2Hh5tRjc2eH/Y+SSmb0gR3eAQpn6w==",
"dependencies": {
"@libp2p/interface-peer-id": "^1.0.0",
"@libp2p/interface-peer-info": "^1.0.0",
@ -1205,6 +1218,22 @@
"npm": ">=7.0.0"
}
},
"node_modules/@libp2p/interface-transport": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/@libp2p/interface-transport/-/interface-transport-2.0.1.tgz",
"integrity": "sha512-yrL6YZmPQX4JT/E/60XgNgNSCu9tNPjjq2HuWZs1n1k8cstV0/WvViUE8aoOlJlKZSVjQNcpRAy9LgVxznK7/g==",
"dependencies": {
"@libp2p/interface-connection": "^3.0.0",
"@libp2p/interface-stream-muxer": "^3.0.0",
"@libp2p/interfaces": "^3.0.0",
"@multiformats/multiaddr": "^11.0.0",
"it-stream-types": "^1.0.4"
},
"engines": {
"node": ">=16.0.0",
"npm": ">=7.0.0"
}
},
"node_modules/@libp2p/interfaces": {
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/@libp2p/interfaces/-/interfaces-3.0.4.tgz",
@ -1628,22 +1657,6 @@
"npm": ">=7.0.0"
}
},
"node_modules/@libp2p/websockets/node_modules/@libp2p/interface-transport": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/@libp2p/interface-transport/-/interface-transport-2.0.1.tgz",
"integrity": "sha512-yrL6YZmPQX4JT/E/60XgNgNSCu9tNPjjq2HuWZs1n1k8cstV0/WvViUE8aoOlJlKZSVjQNcpRAy9LgVxznK7/g==",
"dependencies": {
"@libp2p/interface-connection": "^3.0.0",
"@libp2p/interface-stream-muxer": "^3.0.0",
"@libp2p/interfaces": "^3.0.0",
"@multiformats/multiaddr": "^11.0.0",
"it-stream-types": "^1.0.4"
},
"engines": {
"node": ">=16.0.0",
"npm": ">=7.0.0"
}
},
"node_modules/@manypkg/find-root": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/@manypkg/find-root/-/find-root-1.1.0.tgz",
@ -8486,35 +8499,6 @@
"npm": ">=7.0.0"
}
},
"node_modules/libp2p/node_modules/@libp2p/interface-address-manager": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/@libp2p/interface-address-manager/-/interface-address-manager-2.0.1.tgz",
"integrity": "sha512-JjlQUJ0cF1h0wsOS22PNRQiiiMLwftd5QttjJK2jDsou5FkZETeQ9eYL05I0ykQKZvEJqwH8G5WLwxWtwsj7Ag==",
"dependencies": {
"@libp2p/interfaces": "^3.0.0",
"@multiformats/multiaddr": "^11.0.0"
},
"engines": {
"node": ">=16.0.0",
"npm": ">=7.0.0"
}
},
"node_modules/libp2p/node_modules/@libp2p/interface-transport": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/@libp2p/interface-transport/-/interface-transport-2.0.1.tgz",
"integrity": "sha512-yrL6YZmPQX4JT/E/60XgNgNSCu9tNPjjq2HuWZs1n1k8cstV0/WvViUE8aoOlJlKZSVjQNcpRAy9LgVxznK7/g==",
"dependencies": {
"@libp2p/interface-connection": "^3.0.0",
"@libp2p/interface-stream-muxer": "^3.0.0",
"@libp2p/interfaces": "^3.0.0",
"@multiformats/multiaddr": "^11.0.0",
"it-stream-types": "^1.0.4"
},
"engines": {
"node": ">=16.0.0",
"npm": ">=7.0.0"
}
},
"node_modules/libp2p/node_modules/it-all": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/it-all/-/it-all-2.0.0.tgz",
@ -17321,11 +17305,24 @@
"dependencies": {
"@chainsafe/libp2p-noise": "^10.1.0",
"@libp2p/bootstrap": "^5.0.0",
"@libp2p/interface-address-manager": "^2.0.1",
"@libp2p/interface-connection": "^3.0.3",
"@libp2p/interface-connection-manager": "^1.3.1",
"@libp2p/interface-content-routing": "^1.0.4",
"@libp2p/interface-dht": "^1.0.3",
"@libp2p/interface-metrics": "^3.0.0",
"@libp2p/interface-peer-discovery": "^1.0.2",
"@libp2p/interface-peer-id": "^1.0.6",
"@libp2p/interface-peer-routing": "^1.0.2",
"@libp2p/interface-peer-store": "^1.2.3",
"@libp2p/interface-pubsub": "^3.0.1",
"@libp2p/interface-registrar": "^2.0.4",
"@libp2p/interface-transport": "^2.0.1",
"@libp2p/mplex": "^7.0.0",
"@libp2p/websockets": "^5.0.0",
"@waku/core": "*",
"@waku/interfaces": "*"
"@waku/interfaces": "*",
"interface-datastore": "^7.0.1"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^22.0.0",
@ -18318,6 +18315,15 @@
}
}
},
"@libp2p/interface-address-manager": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/@libp2p/interface-address-manager/-/interface-address-manager-2.0.1.tgz",
"integrity": "sha512-JjlQUJ0cF1h0wsOS22PNRQiiiMLwftd5QttjJK2jDsou5FkZETeQ9eYL05I0ykQKZvEJqwH8G5WLwxWtwsj7Ag==",
"requires": {
"@libp2p/interfaces": "^3.0.0",
"@multiformats/multiaddr": "^11.0.0"
}
},
"@libp2p/interface-connection": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/@libp2p/interface-connection/-/interface-connection-3.0.3.tgz",
@ -18341,9 +18347,9 @@
}
},
"@libp2p/interface-connection-manager": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/@libp2p/interface-connection-manager/-/interface-connection-manager-1.3.0.tgz",
"integrity": "sha512-25tlCE8ECX/ARP+yV+j2+MQeZ9+HfzvwYEU2TymywP83Q5v6oKZM8pmS51yiNwcKPZMMZiHQk1eFmaOrJB25zQ==",
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/@libp2p/interface-connection-manager/-/interface-connection-manager-1.3.1.tgz",
"integrity": "sha512-aaRFzpIU6f2DKo6q9fx7W3xPfT2iW/J5mnGTHvvndCtPGmoziCY90cFYJiZ4nJJfX5YKs+v/kDTztXVWgPA9Nw==",
"requires": {
"@libp2p/interface-connection": "^3.0.0",
"@libp2p/interface-peer-id": "^1.0.0",
@ -18352,9 +18358,9 @@
}
},
"@libp2p/interface-content-routing": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/@libp2p/interface-content-routing/-/interface-content-routing-1.0.3.tgz",
"integrity": "sha512-8oARfHOkf3NAMaDQWBM3nbVNg+Skj1hjGAjomakZ/jZPjOjbQ9BfPZAsrnDRrV0snnnJNrxiYz6w58y8ehg+cA==",
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/@libp2p/interface-content-routing/-/interface-content-routing-1.0.4.tgz",
"integrity": "sha512-zJn7wH8KWaAdlc6kNUMsq9cYx1bEdTj0yAEhzIsrfdXX/XTlBqCeWmMBuFMwj4vBp0pKI0nlt3fUHON1cIGX1w==",
"requires": {
"@libp2p/interface-peer-info": "^1.0.0",
"@libp2p/interfaces": "^3.0.0",
@ -18362,9 +18368,9 @@
}
},
"@libp2p/interface-dht": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/@libp2p/interface-dht/-/interface-dht-1.0.2.tgz",
"integrity": "sha512-vBMR90VFQbNwUdgf7yYO6buDP8K6srb+Z0KdoHMklZd9UIx6k/SVUANkHWw/tGAX4C2EZ0qMdSiivkJg2dcPjg==",
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/@libp2p/interface-dht/-/interface-dht-1.0.3.tgz",
"integrity": "sha512-8SuGn2QIztqHjMPZLNKAZ+UlWc4EDB9rIt53KfjWZnQrRJzkyqFYXvT9VhnqtFX7iblf4N4I3Z42OFAM8ezCvg==",
"requires": {
"@libp2p/interface-peer-discovery": "^1.0.0",
"@libp2p/interface-peer-id": "^1.0.0",
@ -18414,9 +18420,9 @@
}
},
"@libp2p/interface-peer-routing": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/@libp2p/interface-peer-routing/-/interface-peer-routing-1.0.1.tgz",
"integrity": "sha512-MKx2g0mIUI6qNuLv3xApKXR2ZrO9CUTT9ZPL0gvRlhpFCXovEkdWJ1h8KnmkR7tGPxKHt2bsCCJ8gqUaFeNstA==",
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/@libp2p/interface-peer-routing/-/interface-peer-routing-1.0.2.tgz",
"integrity": "sha512-TPv9ALS3FUG+q95jyvT0jOQd2k17bdzn0jw0nGwTo7beoeRMVehTHAXPn2Hh5tRjc2eH/Y+SSmb0gR3eAQpn6w==",
"requires": {
"@libp2p/interface-peer-id": "^1.0.0",
"@libp2p/interface-peer-info": "^1.0.0",
@ -18475,6 +18481,18 @@
"it-stream-types": "^1.0.4"
}
},
"@libp2p/interface-transport": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/@libp2p/interface-transport/-/interface-transport-2.0.1.tgz",
"integrity": "sha512-yrL6YZmPQX4JT/E/60XgNgNSCu9tNPjjq2HuWZs1n1k8cstV0/WvViUE8aoOlJlKZSVjQNcpRAy9LgVxznK7/g==",
"requires": {
"@libp2p/interface-connection": "^3.0.0",
"@libp2p/interface-stream-muxer": "^3.0.0",
"@libp2p/interfaces": "^3.0.0",
"@multiformats/multiaddr": "^11.0.0",
"it-stream-types": "^1.0.4"
}
},
"@libp2p/interfaces": {
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/@libp2p/interfaces/-/interfaces-3.0.4.tgz",
@ -18813,20 +18831,6 @@
"p-defer": "^4.0.0",
"p-timeout": "^6.0.0",
"wherearewe": "^2.0.1"
},
"dependencies": {
"@libp2p/interface-transport": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/@libp2p/interface-transport/-/interface-transport-2.0.1.tgz",
"integrity": "sha512-yrL6YZmPQX4JT/E/60XgNgNSCu9tNPjjq2HuWZs1n1k8cstV0/WvViUE8aoOlJlKZSVjQNcpRAy9LgVxznK7/g==",
"requires": {
"@libp2p/interface-connection": "^3.0.0",
"@libp2p/interface-stream-muxer": "^3.0.0",
"@libp2p/interfaces": "^3.0.0",
"@multiformats/multiaddr": "^11.0.0",
"it-stream-types": "^1.0.4"
}
}
}
},
"@manypkg/find-root": {
@ -20152,7 +20156,19 @@
"requires": {
"@chainsafe/libp2p-noise": "^10.1.0",
"@libp2p/bootstrap": "^5.0.0",
"@libp2p/interface-address-manager": "^2.0.1",
"@libp2p/interface-connection": "^3.0.3",
"@libp2p/interface-connection-manager": "^1.3.1",
"@libp2p/interface-content-routing": "^1.0.4",
"@libp2p/interface-dht": "^1.0.3",
"@libp2p/interface-metrics": "^3.0.0",
"@libp2p/interface-peer-discovery": "^1.0.2",
"@libp2p/interface-peer-id": "^1.0.6",
"@libp2p/interface-peer-routing": "^1.0.2",
"@libp2p/interface-peer-store": "^1.2.3",
"@libp2p/interface-pubsub": "^3.0.1",
"@libp2p/interface-registrar": "^2.0.4",
"@libp2p/interface-transport": "^2.0.1",
"@libp2p/mplex": "^7.0.0",
"@libp2p/websockets": "^5.0.0",
"@rollup/plugin-commonjs": "^22.0.0",
@ -20169,6 +20185,7 @@
"eslint-plugin-functional": "^4.0.2",
"eslint-plugin-import": "^2.25.3",
"eslint-plugin-prettier": "^4.0.0",
"interface-datastore": "^7.0.1",
"npm-run-all": "^4.1.5",
"prettier": "^2.1.1",
"rollup": "^2.75.0",
@ -24372,27 +24389,6 @@
"xsalsa20": "^1.1.0"
},
"dependencies": {
"@libp2p/interface-address-manager": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/@libp2p/interface-address-manager/-/interface-address-manager-2.0.1.tgz",
"integrity": "sha512-JjlQUJ0cF1h0wsOS22PNRQiiiMLwftd5QttjJK2jDsou5FkZETeQ9eYL05I0ykQKZvEJqwH8G5WLwxWtwsj7Ag==",
"requires": {
"@libp2p/interfaces": "^3.0.0",
"@multiformats/multiaddr": "^11.0.0"
}
},
"@libp2p/interface-transport": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/@libp2p/interface-transport/-/interface-transport-2.0.1.tgz",
"integrity": "sha512-yrL6YZmPQX4JT/E/60XgNgNSCu9tNPjjq2HuWZs1n1k8cstV0/WvViUE8aoOlJlKZSVjQNcpRAy9LgVxznK7/g==",
"requires": {
"@libp2p/interface-connection": "^3.0.0",
"@libp2p/interface-stream-muxer": "^3.0.0",
"@libp2p/interfaces": "^3.0.0",
"@multiformats/multiaddr": "^11.0.0",
"it-stream-types": "^1.0.4"
}
},
"it-all": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/it-all/-/it-all-2.0.0.tgz",

View File

@ -1,69 +0,0 @@
import path from "path";
import fs from "fs";
const START_PATH = path.join(process.cwd(), "dist/");
const IMPORT_REGEXP =
/^((import|export) [^';]* from "(\.[^@";]*\/[^";]*)[^";]*)"/g;
const JUST_ADD_AN_EXTENSION = '$1.js"';
const ADD_INDEX_FILE = '$1/index.js"';
const JS_EXT = ".js";
function fixImportsAtFolder(rootPath) {
const entries = fs.readdirSync(rootPath);
entries.forEach((entry) => {
const entryPath = path.join(rootPath, entry);
if (entry.endsWith(JS_EXT)) {
fixImportsAtFile(entryPath);
} else {
const extName = path.extname(entry);
if (!extName) {
const stat = fs.statSync(entryPath);
if (stat.isDirectory()) {
fixImportsAtFolder(entryPath);
}
}
}
});
}
function fixImportsAtFile(filePath) {
const content = fs.readFileSync(filePath).toString("utf8");
const lines = content.split("\n");
const fixedLines = lines.map((l) => {
if (!l.match(IMPORT_REGEXP)) {
return l;
}
const [_, importPath] = l.split(`"`);
let exists;
let fullPath;
if (importPath.startsWith(".")) {
fullPath = path.join(filePath, "..", importPath);
exists = fs.existsSync(fullPath);
} else {
fullPath = path.join(process.cwd(), "node_modules", importPath);
exists = fs.existsSync(fullPath);
}
if (exists === false) {
console.log("Update ", l);
return l.replace(IMPORT_REGEXP, JUST_ADD_AN_EXTENSION);
}
const stat = fs.statSync(fullPath);
const isDirectory = stat.isDirectory();
if (isDirectory === true) {
console.log("Update ", l);
return l.replace(IMPORT_REGEXP, ADD_INDEX_FILE);
}
return l;
});
const withFixedImports = fixedLines.join("\n");
fs.writeFileSync(filePath, withFixedImports);
}
fixImportsAtFolder(START_PATH);
console.log("imports fixed...");
console.log("================");

View File

@ -53,7 +53,7 @@
],
"scripts": {
"build": "run-s build:**",
"build:esm": "tsc && node build-scripts/fix-imports.js",
"build:esm": "tsc",
"build:bundle": "rollup --config rollup.config.js",
"fix": "run-s fix:*",
"fix:prettier": "prettier . --write",

View File

@ -1,29 +1,29 @@
export { DefaultPubSubTopic } from "./lib/constants";
export { DefaultUserAgent } from "./lib/waku";
export { DefaultPubSubTopic } from "./lib/constants.js";
export { DefaultUserAgent } from "./lib/waku.js";
export * as proto_message from "./proto/message";
export * as proto_topic_only_message from "./proto/topic_only_message";
export * as proto_message from "./proto/message.js";
export * as proto_topic_only_message from "./proto/topic_only_message.js";
export * as waku from "./lib/waku";
export { WakuNode } from "./lib/waku";
export * as waku from "./lib/waku.js";
export { WakuNode } from "./lib/waku.js";
export * as waku_filter from "./lib/waku_filter";
export { wakuFilter } from "./lib/waku_filter";
export * as waku_filter from "./lib/waku_filter/index.js";
export { wakuFilter } from "./lib/waku_filter/index.js";
export * as waku_light_push from "./lib/waku_light_push";
export * as waku_light_push from "./lib/waku_light_push/index.js";
export {
wakuLightPush,
LightPushCodec,
PushResponse,
} from "./lib/waku_light_push";
} from "./lib/waku_light_push/index.js";
export * as waku_relay from "./lib/waku_relay";
export { wakuRelay } from "./lib/waku_relay";
export * as waku_relay from "./lib/waku_relay/index.js";
export { wakuRelay } from "./lib/waku_relay/index.js";
export * as waku_store from "./lib/waku_store";
export * as waku_store from "./lib/waku_store/index.js";
export {
PageDirection,
wakuStore,
StoreCodec,
createCursor,
} from "./lib/waku_store";
} from "./lib/waku_store/index.js";

View File

@ -1,4 +1,4 @@
import { getPseudoRandomSubset } from "./random_subset";
import { getPseudoRandomSubset } from "./random_subset.js";
export const DefaultWantedNumber = 1;

View File

@ -1,6 +1,6 @@
import { expect } from "chai";
import { pushOrInitMapSet } from "./push_or_init_map";
import { pushOrInitMapSet } from "./push_or_init_map.js";
describe("pushOrInitMapSet", () => {
it("Init the array if not present", () => {

View File

@ -1,8 +1,8 @@
import { expect } from "chai";
import { WakuMessage as WakuMessageProto } from "../proto/message";
import { WakuMessage as WakuMessageProto } from "../proto/message.js";
import { toProtoMessage } from "./to_proto_message";
import { toProtoMessage } from "./to_proto_message.js";
describe("to proto message", () => {
it("Fields are not dropped", () => {

View File

@ -1,6 +1,6 @@
import { ProtoMessage } from "@waku/interfaces";
import { WakuMessage as WakuMessageProto } from "../proto/message";
import { WakuMessage as WakuMessageProto } from "../proto/message.js";
const EmptyMessage: ProtoMessage = {
payload: undefined,

View File

@ -4,9 +4,9 @@ import { Protocols } from "@waku/interfaces";
import debug from "debug";
import { pEvent } from "p-event";
import { FilterCodec } from "./waku_filter";
import { LightPushCodec } from "./waku_light_push";
import { StoreCodec } from "./waku_store";
import { FilterCodec } from "./waku_filter/index.js";
import { LightPushCodec } from "./waku_light_push/index.js";
import { StoreCodec } from "./waku_store/index.js";
const log = debug("waku:wait-for-remote-peer");

View File

@ -7,12 +7,15 @@ import { Protocols } from "@waku/interfaces";
import debug from "debug";
import type { Libp2p } from "libp2p";
import { FilterCodec, FilterComponents } from "./waku_filter";
import { LightPushCodec, LightPushComponents } from "./waku_light_push";
import { EncoderV0 } from "./waku_message/version_0";
import * as relayConstants from "./waku_relay/constants";
import { RelayCodecs, RelayPingContentTopic } from "./waku_relay/constants";
import { StoreCodec, StoreComponents } from "./waku_store";
import { FilterCodec, FilterComponents } from "./waku_filter/index.js";
import {
LightPushCodec,
LightPushComponents,
} from "./waku_light_push/index.js";
import { EncoderV0 } from "./waku_message/version_0.js";
import * as relayConstants from "./waku_relay/constants.js";
import { RelayCodecs, RelayPingContentTopic } from "./waku_relay/constants.js";
import { StoreCodec, StoreComponents } from "./waku_store/index.js";
export const DefaultPingKeepAliveValueSecs = 0;
export const DefaultRelayKeepAliveValueSecs = 5 * 60;

View File

@ -1,6 +1,6 @@
import { v4 as uuid } from "uuid";
import * as proto from "../../proto/filter";
import * as proto from "../../proto/filter.js";
export type ContentFilter = {
contentTopic: string;

View File

@ -18,18 +18,18 @@ import all from "it-all";
import * as lp from "it-length-prefixed";
import { pipe } from "it-pipe";
import { WakuMessage as WakuMessageProto } from "../../proto/message";
import { DefaultPubSubTopic } from "../constants";
import { groupByContentTopic } from "../group_by";
import { selectConnection } from "../select_connection";
import { WakuMessage as WakuMessageProto } from "../../proto/message.js";
import { DefaultPubSubTopic } from "../constants.js";
import { groupByContentTopic } from "../group_by.js";
import { selectConnection } from "../select_connection.js";
import {
getPeersForProtocol,
selectPeerForProtocol,
selectRandomPeer,
} from "../select_peer";
import { toProtoMessage } from "../to_proto_message";
} from "../select_peer.js";
import { toProtoMessage } from "../to_proto_message.js";
import { ContentFilter, FilterRPC } from "./filter_rpc";
import { ContentFilter, FilterRPC } from "./filter_rpc.js";
export { ContentFilter };

View File

@ -15,16 +15,16 @@ import * as lp from "it-length-prefixed";
import { pipe } from "it-pipe";
import { Uint8ArrayList } from "uint8arraylist";
import { PushResponse } from "../../proto/light_push";
import { DefaultPubSubTopic } from "../constants";
import { selectConnection } from "../select_connection";
import { PushResponse } from "../../proto/light_push.js";
import { DefaultPubSubTopic } from "../constants.js";
import { selectConnection } from "../select_connection.js";
import {
getPeersForProtocol,
selectPeerForProtocol,
selectRandomPeer,
} from "../select_peer";
} from "../select_peer.js";
import { PushRPC } from "./push_rpc";
import { PushRPC } from "./push_rpc.js";
const log = debug("waku:light-push");

View File

@ -1,7 +1,7 @@
import type { Uint8ArrayList } from "uint8arraylist";
import { v4 as uuid } from "uuid";
import * as proto from "../../proto/light_push";
import * as proto from "../../proto/light_push.js";
export class PushRPC {
public constructor(public proto: proto.PushRPC) {}

View File

@ -1,7 +1,7 @@
import type { DecodedMessage, Decoder, ProtoMessage } from "@waku/interfaces";
import debug from "debug";
import * as proto from "../../proto/topic_only_message";
import * as proto from "../../proto/topic_only_message.js";
const log = debug("waku:message:topic-only");

View File

@ -1,7 +1,7 @@
import { expect } from "chai";
import fc from "fast-check";
import { DecoderV0, EncoderV0, MessageV0 } from "./version_0";
import { DecoderV0, EncoderV0, MessageV0 } from "./version_0.js";
const TestContentTopic = "/test/1/waku-message/utf8";

View File

@ -8,7 +8,7 @@ import type {
} from "@waku/interfaces";
import debug from "debug";
import * as proto from "../../proto/message";
import * as proto from "../../proto/message.js";
const log = debug("waku:message:version-0");
const OneMillion = BigInt(1_000_000);

View File

@ -4,10 +4,7 @@ import {
GossipsubMessage,
GossipsubOpts,
} from "@chainsafe/libp2p-gossipsub";
import {
PeerIdStr,
TopicStr,
} from "@chainsafe/libp2p-gossipsub/dist/src/types";
import type { PeerIdStr, TopicStr } from "@chainsafe/libp2p-gossipsub/types";
import { SignaturePolicy } from "@chainsafe/libp2p-gossipsub/types";
import type {
Callback,
@ -20,11 +17,11 @@ import type {
import { DecodedMessage } from "@waku/interfaces";
import debug from "debug";
import { DefaultPubSubTopic } from "../constants";
import { pushOrInitMapSet } from "../push_or_init_map";
import { TopicOnlyDecoder } from "../waku_message/topic_only_message";
import { DefaultPubSubTopic } from "../constants.js";
import { pushOrInitMapSet } from "../push_or_init_map.js";
import { TopicOnlyDecoder } from "../waku_message/topic_only_message.js";
import * as constants from "./constants";
import * as constants from "./constants.js";
const log = debug("waku:relay");

View File

@ -1,7 +1,7 @@
import type { Uint8ArrayList } from "uint8arraylist";
import { v4 as uuid } from "uuid";
import * as proto from "../../proto/store";
import * as proto from "../../proto/store.js";
const OneMillion = BigInt(1_000_000);

View File

@ -17,13 +17,13 @@ import * as lp from "it-length-prefixed";
import { pipe } from "it-pipe";
import { Uint8ArrayList } from "uint8arraylist";
import * as proto from "../../proto/store";
import { DefaultPubSubTopic } from "../constants";
import { selectConnection } from "../select_connection";
import { getPeersForProtocol, selectPeerForProtocol } from "../select_peer";
import { toProtoMessage } from "../to_proto_message";
import * as proto from "../../proto/store.js";
import { DefaultPubSubTopic } from "../constants.js";
import { selectConnection } from "../select_connection.js";
import { getPeersForProtocol, selectPeerForProtocol } from "../select_peer.js";
import { toProtoMessage } from "../to_proto_message.js";
import { HistoryRPC, PageDirection, Params } from "./history_rpc";
import { HistoryRPC, PageDirection, Params } from "./history_rpc.js";
import HistoryError = proto.HistoryResponse.HistoryError;

View File

@ -52,11 +52,24 @@
"dependencies": {
"@chainsafe/libp2p-noise": "^10.1.0",
"@libp2p/bootstrap": "^5.0.0",
"@libp2p/interface-address-manager": "^2.0.1",
"@libp2p/interface-connection": "^3.0.3",
"@libp2p/interface-connection-manager": "^1.3.1",
"@libp2p/interface-content-routing": "^1.0.4",
"@libp2p/interface-dht": "^1.0.3",
"@libp2p/interface-metrics": "^3.0.0",
"@libp2p/interface-peer-discovery": "^1.0.2",
"@libp2p/interface-peer-id": "^1.0.6",
"@libp2p/interface-peer-routing": "^1.0.2",
"@libp2p/interface-peer-store": "^1.2.3",
"@libp2p/interface-pubsub": "^3.0.1",
"@libp2p/interface-registrar": "^2.0.4",
"@libp2p/interface-transport": "^2.0.1",
"@libp2p/mplex": "^7.0.0",
"@libp2p/websockets": "^5.0.0",
"@waku/core": "*",
"@waku/interfaces": "*"
"@waku/interfaces": "*",
"interface-datastore": "^7.0.1"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^22.0.0",

View File

@ -18,7 +18,10 @@ import { getPredefinedBootstrapNodes } from "@waku/core/lib/predefined_bootstrap
import type { Relay, WakuFull, WakuLight, WakuPrivacy } from "@waku/interfaces";
import type { Libp2p } from "libp2p";
import { createLibp2p, Libp2pOptions } from "libp2p";
import type { Components } from "libp2p/components";
import type { Libp2pComponents } from "./libp2p_components.js";
export { Libp2pComponents };
type WakuOptions = waku.WakuOptions;
type RelayCreateOptions = waku_relay.CreateOptions;
@ -158,13 +161,13 @@ export async function createFullNode(
}
export function defaultPeerDiscovery(): (
components: Components
components: Libp2pComponents
) => PeerDiscovery {
return bootstrap({ list: getPredefinedBootstrapNodes() });
}
export async function defaultLibp2p(
wakuRelay?: (components: Components) => Relay,
wakuRelay?: (components: Libp2pComponents) => Relay,
options?: Partial<Libp2pOptions>,
userAgent?: string
): Promise<Libp2p> {

View File

@ -0,0 +1,39 @@
import type { AddressManager } from "@libp2p/interface-address-manager";
import type {
ConnectionGater,
ConnectionProtector,
} from "@libp2p/interface-connection";
import type {
ConnectionManager,
Dialer,
} from "@libp2p/interface-connection-manager";
import type { ContentRouting } from "@libp2p/interface-content-routing";
import type { DualDHT } from "@libp2p/interface-dht";
import type { Metrics } from "@libp2p/interface-metrics";
import type { PeerId } from "@libp2p/interface-peer-id";
import type { PeerRouting } from "@libp2p/interface-peer-routing";
import type { PeerStore } from "@libp2p/interface-peer-store";
import type { PubSub } from "@libp2p/interface-pubsub";
import type { Registrar } from "@libp2p/interface-registrar";
import type { TransportManager, Upgrader } from "@libp2p/interface-transport";
import type { Datastore } from "interface-datastore";
// TODO: Get libp2p to export this.
export interface Libp2pComponents {
peerId: PeerId;
addressManager: AddressManager;
peerStore: PeerStore;
upgrader: Upgrader;
registrar: Registrar;
connectionManager: ConnectionManager;
transportManager: TransportManager;
connectionGater: ConnectionGater;
contentRouting: ContentRouting;
peerRouting: PeerRouting;
datastore: Datastore;
connectionProtector?: ConnectionProtector;
dialer: Dialer;
metrics?: Metrics;
dht?: DualDHT;
pubsub?: PubSub;
}

View File

@ -27,12 +27,12 @@ import {
createPeerIdFromKeypair,
IKeypair,
KeypairType,
} from "./keypair";
import { multiaddrFromFields } from "./multiaddr_from_fields";
import { decodeMultiaddrs, encodeMultiaddrs } from "./multiaddrs_codec";
import { ENRKey, ENRValue, NodeId, SequenceNumber } from "./types";
import * as v4 from "./v4";
import { decodeWaku2, encodeWaku2, Waku2 } from "./waku2_codec";
} from "./keypair/index.js";
import { multiaddrFromFields } from "./multiaddr_from_fields.js";
import { decodeMultiaddrs, encodeMultiaddrs } from "./multiaddrs_codec.js";
import { ENRKey, ENRValue, NodeId, SequenceNumber } from "./types.js";
import * as v4 from "./v4.js";
import { decodeWaku2, encodeWaku2, Waku2 } from "./waku2_codec.js";
const log = debug("waku:enr");

View File

@ -8,7 +8,7 @@
import fs, { promises as asyncFs } from "fs";
import { promisify } from "util";
import { delay } from "./delay";
import { delay } from "./delay.js";
export const existsAsync = (filepath: string): Promise<void> =>
asyncFs.access(filepath, fs.constants.F_OK);

View File

@ -5,7 +5,8 @@
* @module
*/
export * from "./async_fs";
export * from "./constants";
export * from "./log_file";
export * from "./nwaku";
export * from "./async_fs.js";
export * from "./constants.js";
export * from "./delay.js";
export * from "./log_file.js";
export * from "./nwaku.js";

View File

@ -9,7 +9,7 @@ import { Context } from "mocha";
import pTimeout from "p-timeout";
import { Tail } from "tail";
import { waitForFile } from "./async_fs";
import { waitForFile } from "./async_fs.js";
export default async function waitForLine(
filepath: string,

View File

@ -9,9 +9,9 @@ import appRoot from "app-root-path";
import debug from "debug";
import portfinder from "portfinder";
import { existsAsync, mkdirAsync, openAsync } from "./async_fs";
import { delay } from "./delay";
import waitForLine from "./log_file";
import { existsAsync, mkdirAsync, openAsync } from "./async_fs.js";
import { delay } from "./delay.js";
import waitForLine from "./log_file.js";
const log = debug("waku:nwaku");

View File

@ -5,7 +5,7 @@ import type { WakuPrivacy } from "@waku/interfaces";
import { Protocols } from "@waku/interfaces";
import { expect } from "chai";
import { makeLogFileName, NOISE_KEY_1, Nwaku } from "../src";
import { makeLogFileName, NOISE_KEY_1, Nwaku } from "../src/index.js";
describe("ENR Interop: nwaku", function () {
let waku: WakuPrivacy;

View File

@ -15,8 +15,13 @@ import {
import { expect } from "chai";
import debug from "debug";
import { makeLogFileName, NOISE_KEY_1, NOISE_KEY_2, Nwaku } from "../src";
import { delay } from "../src/delay";
import {
delay,
makeLogFileName,
NOISE_KEY_1,
NOISE_KEY_2,
Nwaku,
} from "../src/index.js";
const log = debug("waku:test:ephemeral");

View File

@ -7,8 +7,7 @@ import { Protocols } from "@waku/interfaces";
import { expect } from "chai";
import debug from "debug";
import { makeLogFileName, NOISE_KEY_1, Nwaku } from "../src";
import { delay } from "../src/delay";
import { delay, makeLogFileName, NOISE_KEY_1, Nwaku } from "../src/index.js";
const log = debug("waku:test");

View File

@ -8,12 +8,12 @@ import { expect } from "chai";
import debug from "debug";
import {
delay,
makeLogFileName,
MessageRpcResponse,
NOISE_KEY_1,
Nwaku,
} from "../src";
import { delay } from "../src/delay";
} from "../src/index.js";
const log = debug("waku:test:lightpush");

View File

@ -1,6 +1,6 @@
import { expect } from "chai";
import { makeLogFileName } from "../src";
import { makeLogFileName } from "../src/index.js";
describe("This", function () {
describe("Is", function () {

View File

@ -1,6 +1,6 @@
import { expect } from "chai";
import { argsToArray, defaultArgs } from "../src";
import { argsToArray, defaultArgs } from "../src/index.js";
describe("nwaku", () => {
it("Correctly serialized arguments", function () {

View File

@ -23,14 +23,14 @@ import { expect } from "chai";
import debug from "debug";
import {
delay,
makeLogFileName,
MessageRpcResponse,
NOISE_KEY_1,
NOISE_KEY_2,
NOISE_KEY_3,
Nwaku,
} from "../src";
import { delay } from "../src/delay";
} from "../src/index.js";
const log = debug("waku:test");

View File

@ -17,8 +17,13 @@ import {
import { expect } from "chai";
import debug from "debug";
import { makeLogFileName, NOISE_KEY_1, NOISE_KEY_2, Nwaku } from "../src";
import { delay } from "../src/delay";
import {
delay,
makeLogFileName,
NOISE_KEY_1,
NOISE_KEY_2,
Nwaku,
} from "../src/index.js";
const log = debug("waku:test:store");

View File

@ -4,8 +4,7 @@ import type { WakuLight, WakuPrivacy } from "@waku/interfaces";
import { Protocols } from "@waku/interfaces";
import { expect } from "chai";
import { makeLogFileName, NOISE_KEY_1, Nwaku } from "../src";
import { delay } from "../src/delay";
import { delay, makeLogFileName, NOISE_KEY_1, Nwaku } from "../src/index.js";
describe("Wait for remote peer", function () {
let waku1: WakuPrivacy;

View File

@ -18,7 +18,12 @@ import {
} from "@waku/message-encryption";
import { expect } from "chai";
import { makeLogFileName, NOISE_KEY_1, NOISE_KEY_2, Nwaku } from "../src/";
import {
makeLogFileName,
NOISE_KEY_1,
NOISE_KEY_2,
Nwaku,
} from "../src/index.js";
const TestContentTopic = "/test/1/waku/utf8";