mirror of https://github.com/waku-org/js-waku.git
`ChatMessage` has been moved from js-waku to web-chat example
It is a type used for the [TOY-CHAT](https://rfc.vac.dev/spec/22/) protocol; js-waku users should not build on top if this toy protocol and instead design message data structures appropriate to their use case.
This commit is contained in:
parent
0c3995a810
commit
ad9d629daa
|
@ -11,6 +11,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
- Examples (cli-chat): The focus of this library is Web environment;
|
- Examples (cli-chat): The focus of this library is Web environment;
|
||||||
Several examples now cover usage of Waku Relay and Waku Store making cli-chat example obsolete;
|
Several examples now cover usage of Waku Relay and Waku Store making cli-chat example obsolete;
|
||||||
web-chat POC should be preferred to use the [TOY-CHAT](https://rfc.vac.dev/spec/22/) protocol.
|
web-chat POC should be preferred to use the [TOY-CHAT](https://rfc.vac.dev/spec/22/) protocol.
|
||||||
|
- `ChatMessage` has been moved from js-waku to web-chat example;
|
||||||
|
it is a type used for the [TOY-CHAT](https://rfc.vac.dev/spec/22/) protocol;
|
||||||
|
js-waku users should not build on top if this toy protocol and instead design message data structures appropriate to their use case.
|
||||||
|
|
||||||
## [0.10.0] - 2021-08-06
|
## [0.10.0] - 2021-08-06
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
version: v1beta1
|
||||||
|
|
||||||
|
plugins:
|
||||||
|
- name: ts_proto
|
||||||
|
out: ./src/proto
|
||||||
|
opt: grpc_js,esModuleInterop=true
|
|
@ -0,0 +1,5 @@
|
||||||
|
version: v1beta1
|
||||||
|
|
||||||
|
build:
|
||||||
|
roots:
|
||||||
|
- ./src/proto
|
|
@ -38,6 +38,8 @@
|
||||||
"test:spelling": "cspell \"{README.md,.github/*.md,src/**/*.{ts,tsx},public/**/*.html}\" -c ../../.cspell.json",
|
"test:spelling": "cspell \"{README.md,.github/*.md,src/**/*.{ts,tsx},public/**/*.html}\" -c ../../.cspell.json",
|
||||||
"fix:prettier": "prettier \"src/**/*.{ts,tsx}\" \"./*.json\" --write",
|
"fix:prettier": "prettier \"src/**/*.{ts,tsx}\" \"./*.json\" --write",
|
||||||
"fix:lint": "eslint src --ext .ts --ext .tsx --fix",
|
"fix:lint": "eslint src --ext .ts --ext .tsx --fix",
|
||||||
|
"proto": "run-s proto:*",
|
||||||
|
"proto:build": "buf generate",
|
||||||
"js-waku:build": "cd ../; npm run build",
|
"js-waku:build": "cd ../; npm run build",
|
||||||
"predeploy": "run-s js-waku:build build",
|
"predeploy": "run-s js-waku:build build",
|
||||||
"deploy": "gh-pages -d build"
|
"deploy": "gh-pages -d build"
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import { ChatMessage, WakuMessage } from 'js-waku';
|
import { WakuMessage } from 'js-waku';
|
||||||
|
import { ChatMessage } from './chat_message';
|
||||||
|
|
||||||
export class Message {
|
export class Message {
|
||||||
public chatMessage: ChatMessage;
|
public chatMessage: ChatMessage;
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
import { ChatMessage, WakuMessage } from 'js-waku';
|
import { WakuMessage } from 'js-waku';
|
||||||
import { ChatContentTopic } from './App';
|
import { ChatContentTopic } from './App';
|
||||||
import ChatList from './ChatList';
|
import ChatList from './ChatList';
|
||||||
import MessageInput from './MessageInput';
|
import MessageInput from './MessageInput';
|
||||||
import { useWaku } from './WakuContext';
|
import { useWaku } from './WakuContext';
|
||||||
import { TitleBar } from '@livechat/ui-kit';
|
import { TitleBar } from '@livechat/ui-kit';
|
||||||
import { Message } from './Message';
|
import { Message } from './Message';
|
||||||
|
import { ChatMessage } from './chat_message';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
messages: Message[];
|
messages: Message[];
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { Reader } from 'protobufjs/minimal';
|
import { Reader } from 'protobufjs/minimal';
|
||||||
|
|
||||||
import * as proto from '../../proto/chat/v2/chat_message';
|
import * as proto from './proto/chat_message';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ChatMessage is used by the various show case waku apps that demonstrates
|
* ChatMessage is used by the various show case waku apps that demonstrates
|
|
@ -1,7 +1,5 @@
|
||||||
syntax = "proto3";
|
syntax = "proto3";
|
||||||
|
|
||||||
package chat.v2;
|
|
||||||
|
|
||||||
message ChatMessage {
|
message ChatMessage {
|
||||||
uint64 timestamp = 1;
|
uint64 timestamp = 1;
|
||||||
string nick = 2;
|
string nick = 2;
|
|
@ -2,7 +2,7 @@
|
||||||
import Long from 'long';
|
import Long from 'long';
|
||||||
import _m0 from 'protobufjs/minimal';
|
import _m0 from 'protobufjs/minimal';
|
||||||
|
|
||||||
export const protobufPackage = 'chat.v2';
|
export const protobufPackage = '';
|
||||||
|
|
||||||
export interface ChatMessage {
|
export interface ChatMessage {
|
||||||
timestamp: number;
|
timestamp: number;
|
|
@ -8,8 +8,6 @@ export { WakuMessage } from './lib/waku_message';
|
||||||
|
|
||||||
export { generatePrivateKey, getPublicKey } from './lib/waku_message/version_1';
|
export { generatePrivateKey, getPublicKey } from './lib/waku_message/version_1';
|
||||||
|
|
||||||
export { ChatMessage } from './lib/chat_message';
|
|
||||||
|
|
||||||
export {
|
export {
|
||||||
WakuLightPush,
|
WakuLightPush,
|
||||||
LightPushCodec,
|
LightPushCodec,
|
||||||
|
|
|
@ -1,26 +0,0 @@
|
||||||
import { expect } from 'chai';
|
|
||||||
import fc from 'fast-check';
|
|
||||||
|
|
||||||
import { ChatMessage } from './index';
|
|
||||||
|
|
||||||
describe('Chat Message', function () {
|
|
||||||
it('Chat message round trip binary serialization', function () {
|
|
||||||
fc.assert(
|
|
||||||
fc.property(
|
|
||||||
fc.date({ min: new Date(0) }),
|
|
||||||
fc.string(),
|
|
||||||
fc.string(),
|
|
||||||
(timestamp, nick, message) => {
|
|
||||||
const msg = ChatMessage.fromUtf8String(timestamp, nick, message);
|
|
||||||
const buf = msg.encode();
|
|
||||||
const actual = ChatMessage.decode(buf);
|
|
||||||
|
|
||||||
// Date.toString does not include ms, as we loose this precision by design
|
|
||||||
expect(actual.timestamp.toString()).to.eq(timestamp.toString());
|
|
||||||
expect(actual.nick).to.eq(nick);
|
|
||||||
expect(actual.payloadAsUtf8).to.eq(message);
|
|
||||||
}
|
|
||||||
)
|
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -1,5 +1,3 @@
|
||||||
export { ChatMessage } from './chat/v2/chat_message';
|
|
||||||
|
|
||||||
export { WakuMessage } from './waku/v2/message';
|
export { WakuMessage } from './waku/v2/message';
|
||||||
|
|
||||||
export {
|
export {
|
||||||
|
|
Loading…
Reference in New Issue