1
0
Fork 0
mirror of https://github.com/anyproto/anytype-heart.git synced 2025-06-09 09:35:00 +09:00
Shared library for Anytype clients https://anytype.io
Find a file
2019-09-18 14:52:55 +03:00
build/ts build/ts added to repo 2019-09-18 13:35:44 +03:00
docs signup/login: refactoring 2019-09-18 14:50:36 +03:00
repeater repo: redesign; protocol messages added 2019-09-12 17:54:58 +03:00
scheduleWriter repo: redesign; protocol messages added 2019-09-12 17:54:58 +03:00
ts Pipe paths: predefined -> args 2019-09-18 01:21:37 +03:00
.gitignore build/ts added to repo 2019-09-18 13:35:44 +03:00
package.json build -> gitignore; protocol changes 2019-09-16 18:48:48 +03:00
protocol.proto op/entity removed from proto 2019-09-18 14:52:55 +03:00
README.md build -> gitignore; protocol changes 2019-09-16 18:48:48 +03:00

Run example

Preconditions

  1. Install ts-node: sudo npm i -g ts-node to run .ts files in one step.
  2. Install js packages: npm i.
  3. Generate static ts/go modules from the .protocol files.

Then, simply run

  1. npm run start@go
  2. npm run start@ts

TS <- Proto generation

pbjs -t static-module -w commonjs -o build/ts/event.js event.proto
pbts -o build/ts/event.d.ts build/ts/event.js

Additionally, TypeScript definitions of static modules are compatible with their reflection-based counterparts (i.e. as exported by JSON modules), as long as the following conditions are met:

  1. Instead of using new SomeMessage(...), always use SomeMessage.create(...) because reflection objects do not provide a constructor.
  2. Types, services and enums must start with an uppercase letter to become available as properties of the reflected types as well (i.e. to be able to use MyMessage.MyEnum instead of root.lookup("MyMessage.MyEnum")).

GO <- Proto generation

protoc -I protocol/ protocol/event.proto --go_out=plugins=grpc:protocol/build/go