Rework exports for an easy use of the library

This commit is contained in:
Franck Royer 2021-05-10 15:26:14 +10:00
parent 83c17fdcc2
commit 3663ce260d
No known key found for this signature in database
GPG Key ID: A82ED75A8DFC50A4
19 changed files with 52 additions and 31 deletions

View File

@ -11,7 +11,7 @@
"dependencies": {
"libp2p-tcp": "^0.15.4",
"prompt-sync": "^4.2.0",
"waku": "../../build/main/lib"
"waku": "../../build/main"
},
"devDependencies": {
"@istanbuljs/nyc-config-typescript": "^1.0.1",
@ -41,7 +41,10 @@
"node": ">=14"
}
},
"../../build/main/lib": {},
"../../build/main": {},
"../../build/main/lib": {
"extraneous": true
},
"node_modules/@babel/code-frame": {
"version": "7.12.11",
"resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.12.11.tgz",
@ -7507,7 +7510,7 @@
"dev": true
},
"node_modules/waku": {
"resolved": "../../build/main/lib",
"resolved": "../../build/main",
"link": true
},
"node_modules/which": {
@ -13561,7 +13564,7 @@
"dev": true
},
"waku": {
"version": "file:../../build/main/lib"
"version": "file:../../build/main"
},
"which": {
"version": "2.0.2",

View File

@ -33,7 +33,7 @@
"dependencies": {
"libp2p-tcp": "^0.15.4",
"prompt-sync": "^4.2.0",
"waku": "../../build/main/lib"
"waku": "../../build/main"
},
"devDependencies": {
"@istanbuljs/nyc-config-typescript": "^1.0.1",

View File

@ -1,5 +1,5 @@
import { expect } from 'chai';
import { ChatMessage } from 'waku/chat_message';
import { ChatMessage } from 'waku';
import { formatMessage } from './chat';

View File

@ -3,10 +3,7 @@ import util from 'util';
import TCP from 'libp2p-tcp';
import { multiaddr, Multiaddr } from 'multiaddr';
import { ChatMessage } from 'waku/chat_message';
import Waku from 'waku/waku';
import { WakuMessage } from 'waku/waku_message';
import { StoreCodec } from 'waku/waku_store';
import { ChatMessage, StoreCodec, Waku, WakuMessage } from 'waku';
const ChatContentTopic = 'dingpu';

View File

@ -11,7 +11,7 @@
"react": "^16.14.0",
"react-dom": "^16.14.0",
"server-name-generator": "^1.0.5",
"waku": "../../build/main/lib",
"waku": "../../build/main",
"web-vitals": "^1.1.1"
},
"devDependencies": {
@ -30,7 +30,10 @@
"typescript": "^4.2.4"
}
},
"../../build/main/lib": {},
"../../build/main": {},
"../../build/main/lib": {
"extraneous": true
},
"node_modules/@babel/code-frame": {
"version": "7.12.13",
"resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.12.13.tgz",
@ -22883,7 +22886,7 @@
}
},
"node_modules/waku": {
"resolved": "../../build/main/lib",
"resolved": "../../build/main",
"link": true
},
"node_modules/walker": {
@ -43268,7 +43271,7 @@
}
},
"waku": {
"version": "file:../../build/main/lib"
"version": "file:../../build/main"
},
"walker": {
"version": "1.0.7",

View File

@ -8,7 +8,7 @@
"react": "^16.14.0",
"react-dom": "^16.14.0",
"server-name-generator": "^1.0.5",
"waku": "../../build/main/lib",
"waku": "../../build/main",
"web-vitals": "^1.1.1"
},
"devDependencies": {

View File

@ -2,12 +2,9 @@ import { multiaddr } from 'multiaddr';
import PeerId from 'peer-id';
import { useEffect, useState } from 'react';
import './App.css';
import { ChatMessage } from 'waku/chat_message';
import { WakuMessage } from 'waku/waku_message';
import { StoreCodec } from 'waku/waku_store';
import { ChatMessage, WakuMessage, StoreCodec, Waku } from 'waku';
import handleCommand from './command';
import Room from './Room';
import Waku from 'waku/waku';
import { WakuContext } from './WakuContext';
import { ThemeProvider } from '@livechat/ui-kit';
import { generate } from 'server-name-generator';

View File

@ -1,5 +1,5 @@
import { useEffect, useRef, useState } from 'react';
import { ChatMessage } from 'waku/chat_message';
import { ChatMessage } from 'waku';
import {
Message,
MessageText,

View File

@ -1,5 +1,4 @@
import { ChatMessage } from 'waku/chat_message';
import { WakuMessage } from 'waku/waku_message';
import { ChatMessage, WakuMessage } from 'waku';
import { ChatContentTopic } from './App';
import ChatList from './ChatList';
import MessageInput from './MessageInput';

View File

@ -1,5 +1,5 @@
import { createContext, useContext } from 'react';
import Waku from 'waku/waku';
import { Waku } from 'waku';
export type WakuContextType = {
waku?: Waku;

View File

@ -1,6 +1,6 @@
import { multiaddr } from 'multiaddr';
import PeerId from 'peer-id';
import Waku from 'waku/waku';
import { Waku } from 'waku';
function help(): string[] {
return [

10
src/index.ts Normal file
View File

@ -0,0 +1,10 @@
export { Waku } from './lib/waku';
export { WakuMessage } from './lib/waku_message';
export { ChatMessage } from './lib/chat_message';
export { WakuRelay, RelayCodec } from './lib/waku_relay';
export { WakuStore, StoreCodec } from './lib/waku_store';
export * as proto from './proto';

View File

@ -2,7 +2,6 @@ import { Reader } from 'protobufjs/minimal';
import * as proto from '../../proto/chat/v2/chat_message';
// TODO: Move to waku library?
export class ChatMessage {
public constructor(public proto: proto.ChatMessage) {}

View File

@ -8,7 +8,7 @@ import {
NOISE_KEY_2,
} from '../test_utils/';
import Waku from './waku';
import { Waku } from './waku';
import { RelayCodec } from './waku_relay';
describe('Waku Dial', function () {

View File

@ -21,7 +21,7 @@ export type CreateOptions =
}
| (Libp2pOptions & import('libp2p').CreateOptions);
export default class Waku {
export class Waku {
public libp2p: Libp2p;
public relay: WakuRelay;
public store: WakuStore;

View File

@ -8,7 +8,7 @@ import {
NOISE_KEY_2,
} from '../../test_utils';
import { delay } from '../delay';
import Waku from '../waku';
import { Waku } from '../waku';
import { WakuMessage } from '../waku_message';
import { RelayCodec, RelayDefaultTopic } from './index';

View File

@ -19,11 +19,11 @@ import PeerId from 'peer-id';
import { WakuMessage } from '../waku_message';
import * as constants from './constants';
import { RelayCodec, RelayDefaultTopic } from './constants';
import { getRelayPeers } from './get_relay_peers';
import { RelayHeartbeat } from './relay_heartbeat';
export * from './constants';
export * from './relay_heartbeat';
export { RelayCodec, RelayDefaultTopic };
/**
* See {GossipOptions} from libp2p-gossipsub

View File

@ -2,7 +2,7 @@ import { expect } from 'chai';
import TCP from 'libp2p-tcp';
import { makeLogFileName, NimWaku, NOISE_KEY_1 } from '../../test_utils';
import Waku from '../waku';
import { Waku } from '../waku';
import { WakuMessage } from '../waku_message';
describe('Waku Store', () => {

13
src/proto/index.ts Normal file
View File

@ -0,0 +1,13 @@
export { ChatMessage } from './chat/v2/chat_message';
export { WakuMessage } from './waku/v2/message';
export {
Index,
PagingInfo,
PagingInfo_Direction,
ContentFilter,
HistoryQuery,
HistoryResponse,
HistoryRPC,
} from './waku/v2/store';