`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:
Franck Royer 2021-08-06 17:20:30 +10:00
parent 0c3995a810
commit ad9d629daa
No known key found for this signature in database
GPG Key ID: A82ED75A8DFC50A4
12 changed files with 22 additions and 36 deletions

View File

@ -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;
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.
- `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

View File

@ -0,0 +1,6 @@
version: v1beta1
plugins:
- name: ts_proto
out: ./src/proto
opt: grpc_js,esModuleInterop=true

View File

@ -0,0 +1,5 @@
version: v1beta1
build:
roots:
- ./src/proto

View File

@ -38,6 +38,8 @@
"test:spelling": "cspell \"{README.md,.github/*.md,src/**/*.{ts,tsx},public/**/*.html}\" -c ../../.cspell.json",
"fix:prettier": "prettier \"src/**/*.{ts,tsx}\" \"./*.json\" --write",
"fix:lint": "eslint src --ext .ts --ext .tsx --fix",
"proto": "run-s proto:*",
"proto:build": "buf generate",
"js-waku:build": "cd ../; npm run build",
"predeploy": "run-s js-waku:build build",
"deploy": "gh-pages -d build"

View File

@ -1,4 +1,5 @@
import { ChatMessage, WakuMessage } from 'js-waku';
import { WakuMessage } from 'js-waku';
import { ChatMessage } from './chat_message';
export class Message {
public chatMessage: ChatMessage;

View File

@ -1,10 +1,11 @@
import { ChatMessage, WakuMessage } from 'js-waku';
import { WakuMessage } from 'js-waku';
import { ChatContentTopic } from './App';
import ChatList from './ChatList';
import MessageInput from './MessageInput';
import { useWaku } from './WakuContext';
import { TitleBar } from '@livechat/ui-kit';
import { Message } from './Message';
import { ChatMessage } from './chat_message';
interface Props {
messages: Message[];

View File

@ -1,6 +1,6 @@
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

View File

@ -1,7 +1,5 @@
syntax = "proto3";
package chat.v2;
message ChatMessage {
uint64 timestamp = 1;
string nick = 2;

View File

@ -2,7 +2,7 @@
import Long from 'long';
import _m0 from 'protobufjs/minimal';
export const protobufPackage = 'chat.v2';
export const protobufPackage = '';
export interface ChatMessage {
timestamp: number;

View File

@ -8,8 +8,6 @@ export { WakuMessage } from './lib/waku_message';
export { generatePrivateKey, getPublicKey } from './lib/waku_message/version_1';
export { ChatMessage } from './lib/chat_message';
export {
WakuLightPush,
LightPushCodec,

View File

@ -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);
}
)
);
});
});

View File

@ -1,5 +1,3 @@
export { ChatMessage } from './chat/v2/chat_message';
export { WakuMessage } from './waku/v2/message';
export {