1
0
Fork 0
mirror of https://github.com/anyproto/anytype-heart.git synced 2025-06-10 01:51:07 +09:00
This commit is contained in:
Sergey Cherepanov 2019-10-29 14:51:04 +03:00
parent 32a9e125d2
commit 342afa6e6a
No known key found for this signature in database
GPG key ID: 085319C64294F576
10 changed files with 3627 additions and 1273 deletions

View file

@ -56,12 +56,15 @@ build-android:
setup-protoc:
rm -rf $(GOPATH)/src/github.com/gogo/protobuf
mkdir -p $(GOPATH)/src/github.com/gogo
cd $(GOPATH)/src/github.com/gogo
git clone https://github.com/anytypeio/protobuf
cd protobuf
go install github.com/gogo/protobuf/protoc-gen-gogofaster
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin
cd $(GOPATH)/src/github.com/gogo; git clone https://github.com/anytypeio/protobuf
cd $(GOPATH)/src/github.com/gogo/protobuf; go install github.com/gogo/protobuf/protoc-gen-gogofaster
export PATH=$(PATH):$(GOROOT)/bin:$(GOPATH)/bin
# protos: # libprotoc 3.9.1
# cd pb/protos; protoc -I/usr/local/include -I. --gogo_out=../ *.proto;
# cd pb/protos/service; env PACKAGE_PATH=github.com/anytypeio/go-anytype-middleware/pb protoc -I/usr/local/include -I. -I=. -I=.. --gogo_out=plugins=gomobile:../../../lib service.proto
protos:
cd pb/protos; protoc --gogofaster_out=plugins=gomobile:.. *.proto
cd pb/protos/service; env PACKAGE_PATH=github.com/anytypeio/go-anytype-middleware/pb protoc -I=.. -I=. --gogofaster_out=plugins=gomobile:../../../lib service.proto
$(eval P_STRUCT := Mgoogle/protobuf/struct.proto=github.com/golang/protobuf/ptypes/struct)
cd pb/protos; protoc --gogofaster_out=$(P_STRUCT):.. *.proto
cd pb/protos/service; PACKAGE_PATH=github.com/anytypeio/go-anytype-middleware/pb protoc -I=.. -I=. --gogofast_out=plugins=gomobile:../../../lib service.proto

View file

@ -17,7 +17,15 @@ func NewMiddleware() *Middleware {
}
}
type MiddlewareState struct {
// client-state: blocks range, text range, focus, screen position, etc
// history list
// request list
// computed state
}
type Middleware struct {
state MiddlewareState
rootPath string
pin string
mnemonic string

2
go.mod
View file

@ -5,7 +5,7 @@ go 1.12
require (
github.com/anytypeio/go-anytype-library v0.0.0-20191019100520-f545fa654778
github.com/gogo/protobuf v1.3.1
github.com/golang/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.3.2
github.com/ipfs/go-log v0.0.1
github.com/otiai10/opengraph v1.1.0
github.com/stretchr/testify v1.3.0

View file

@ -24,31 +24,31 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
func init() { proto.RegisterFile("service.proto", fileDescriptor_a0b84a42fa06f626) }
var fileDescriptor_a0b84a42fa06f626 = []byte{
// 383 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x93, 0xcb, 0x4e, 0xc2, 0x40,
0x14, 0x86, 0x21, 0x26, 0x12, 0x87, 0xcb, 0x62, 0x36, 0x6a, 0x81, 0xf1, 0x0d, 0x58, 0xe8, 0xd6,
0x8d, 0x25, 0x06, 0x0d, 0xc4, 0x0b, 0x44, 0x4d, 0xdc, 0xb5, 0xe5, 0x48, 0x26, 0x4c, 0x67, 0x6a,
0x3b, 0x60, 0x78, 0x0b, 0x17, 0x3e, 0x94, 0x4b, 0x96, 0x2e, 0x0d, 0xbc, 0x88, 0x91, 0x99, 0xe9,
0x85, 0xb6, 0xbb, 0xe9, 0xff, 0x9d, 0xf3, 0xb5, 0x27, 0xa7, 0x83, 0x9a, 0x11, 0x84, 0x4b, 0xea,
0x41, 0x2f, 0x08, 0x85, 0x14, 0xb8, 0xe6, 0xf0, 0x95, 0x5c, 0x05, 0x60, 0x35, 0x1d, 0xcf, 0x13,
0x0b, 0x2e, 0x55, 0x6e, 0xa1, 0x37, 0xca, 0xc0, 0x9c, 0x7d, 0x1a, 0x79, 0xfa, 0x5c, 0x77, 0x99,
0xf0, 0xe6, 0xea, 0xe1, 0xfc, 0xab, 0x86, 0x5a, 0x7d,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7, 0x18, 0xee, 0x99, 0x9e, 0x82, 0x69, 0x81, 0x49, 0xa5, 0x25, 0x26, 0x03,
0x13, 0xd3, 0x88, 0xf2, 0xf9, 0x43, 0x08, 0x4b, 0x0a, 0x1f, 0x29, 0x53, 0x2a, 0xcd, 0x9b, 0x32,
0x50, 0x99, 0xec, 0xee, 0xf7, 0x86, 0x54, 0xd7, 0x1b, 0x52, 0xfd, 0xdd, 0x90, 0xea, 0xe7, 0x96,
0x54, 0xd6, 0x5b, 0x52, 0xf9, 0xd9, 0x92, 0xca, 0xeb, 0x01, 0xa3, 0xae, 0x7b, 0xb8, 0xbb, 0xbc,
0x17, 0x7f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x75, 0xdc, 0x35, 0xdf, 0x0a, 0x04, 0x00, 0x00,
// 369 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x93, 0x4b, 0x4e, 0xc3, 0x30,
0x10, 0x86, 0x55, 0x21, 0x51, 0xe1, 0x3e, 0x24, 0xbc, 0x01, 0xd2, 0x36, 0xdc, 0xa0, 0x0b, 0xd8,
0xb2, 0x21, 0x15, 0x2a, 0xa8, 0x15, 0x8f, 0x56, 0x80, 0xc4, 0x2e, 0x71, 0x87, 0xca, 0xaa, 0x63,
0x87, 0xd8, 0x2d, 0xea, 0x3d, 0x38, 0x14, 0x4b, 0x8e, 0x80, 0x7a, 0x12, 0x44, 0x6d, 0xe7, 0x9d,
0x9d, 0xf3, 0x7f, 0x33, 0x5f, 0x32, 0x9a, 0x18, 0x75, 0x24, 0xc4, 0x1b, 0x4a, 0x60, 0x18, 0xc5,
0x42, 0x09, 0xdc, 0xf4, 0xf9, 0x56, 0x6d, 0x23, 0x70, 0x3a, 0x3e, 0x21, 0x62, 0xcd, 0x95, 0xce,
0x1d, 0xf4, 0x4e, 0x19, 0xd8, 0x73, 0x48, 0x25, 0x31, 0xe7, 0x56, 0xc0, 0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8, 0xb5, 0x0f, 0xcd, 0xce, 0x7a, 0xf9, 0xd2, 0xfc, 0xc6, 0xfa, 0xd5,
0xb0, 0x60, 0x7a, 0x8e, 0x16, 0x15, 0x26, 0x9d, 0xd6, 0x98, 0x2c, 0x4c, 0x4d, 0x53, 0xca, 0x57,
0x8f, 0x31, 0x6c, 0x28, 0x7c, 0x66, 0x4c, 0x99, 0xb4, 0x6c, 0xca, 0x41, 0x6d, 0xf2, 0x8e, 0xbf,
0x77, 0x6e, 0xe3, 0x67, 0xe7, 0x36, 0x7e, 0x77, 0x6e, 0xe3, 0xed, 0x80, 0xd1, 0x20, 0x38, 0xdc,
0x5f, 0xd8, 0xcb, 0xbf, 0x00, 0x00, 0x00, 0xff, 0xff, 0x1b, 0x82, 0x8a, 0xe6, 0xfe, 0x03, 0x00,
0x00,
}
// This is a compile-time assertion to ensure that this generated file

File diff suppressed because it is too large Load diff

1277
pb/edit.pb.go Normal file

File diff suppressed because it is too large Load diff

View file

@ -2,6 +2,9 @@ syntax="proto3";
package anytype;
option go_package = "pb";
import "struct.proto";
// commands
//
message BlockOpenRequest {
@ -10,6 +13,7 @@ message BlockOpenRequest {
message BlockOpenResponse {
Error error = 1;
BlockHeader blockHeader = 2;
message Error {
Code code = 1;
@ -80,23 +84,23 @@ message BlockCreate {
Block block = 1;
}
message BlockTextChange {
message BlockContentTextChange {
oneof change {
string text = 1;
BlockText.Style style = 2;
BlockText.Marks marks = 3;
BlockContentText.Style style = 2;
BlockContentText.Marks marks = 3;
bool toggleable = 4;
BlockText.MarkerType markerType = 5;
BlockContentText.MarkerType markerType = 5;
bool checkable = 6;
bool checked = 7;
}
}
message BlockPageChange {
message BlockContentPageChange {
oneof change {
BlockPage.Style style = 1;
BlockContentPage.Style style = 1;
BlockConnectionsList structure = 2;
BlocksList blocks = 3;
}
@ -113,9 +117,9 @@ message BlockHeaderChange {
}
}
message BlockDashboardChange {
message BlockContentDashboardChange {
oneof change {
BlockDashboard.Style style = 1;
BlockContentDashboard.Style style = 1;
BlockConnectionsList structure = 2;
BlockHeadersList headers = 3;
}
@ -124,10 +128,10 @@ message BlockDashboardChange {
message BlockAtomicChange {
string id = 1;
oneof change {
BlockTextChange text = 2;
BlockContentTextChange text = 2;
BlockHeaderChange blockHeader = 3;
BlockPageChange page = 4;
BlockDashboardChange dashboard = 5;
BlockContentPageChange page = 4;
BlockContentDashboardChange dashboard = 5;
}
}
@ -142,22 +146,20 @@ message Block {
BlockHeader header = 1;
oneof content {
BlockDashboard dashboard = 11;
BlockPage page = 12;
BlockDataview dataview = 13;
BlockContentDashboard dashboard = 11;
BlockContentPage page = 12;
BlockContentDataview dataview = 13;
BlockText text = 14;
BlockMedia media = 15;
BlockContentText text = 14;
BlockContentMedia media = 15;
}
}
message BlockHeader {
string id = 1;
BlockType type = 2;
string name = 3;
string icon = 4;
BlockPermissions permissions = 5;
Struct fields = 3;
BlockPermissions permissions = 4;
}
message BlockPermissions {
@ -199,7 +201,7 @@ message BlocksList {
repeated Block blocks = 1;
}
message BlockPage {
message BlockContentPage {
enum Style {
EMPTY = 0;
TASK = 1;
@ -213,7 +215,7 @@ message BlockPage {
BlocksList blocks = 3;
}
message BlockDashboard {
message BlockContentDashboard {
enum Style {
MAIN_SCREEN = 0;
// ...
@ -224,11 +226,11 @@ message BlockDashboard {
BlockHeadersList headers = 3;
}
message BlockDataview {
message BlockContentDataview {
// ...
}
message BlockText {
message BlockContentText {
enum Style {
p = 0;
h1 = 1;
@ -249,21 +251,18 @@ message BlockText {
}
message Mark {
message Range {
int32 from = 1;
int32 to = 2;
}
enum Type {
S = 0;
KBD = 1;
I = 2;
B = 3;
A = 4;
STRIKETHROUGH = 0;
KEYBOARD = 1;
ITALIC = 2;
BOLD = 3;
LINK = 4;
}
Range range = 1;
Type type = 2;
string param = 3; // link, color, etc
}
string text = 1;
@ -277,17 +276,74 @@ message BlockText {
bool checked = 7;
}
message BlockMedia {
message BlockContentMedia {
string link = 1;
BlockMediaMeta meta = 2;
}
message BlockMediaMeta {
message Range {
int32 from = 1;
int32 to = 2;
}
/*
message Scheme {
oneof scheme {
PageScheme pageScheme = 1;
DataviewScheme dataviewScheme = 2;
}
}
message DataviewScheme {
// ...
}
message PageScheme {
BlockHeader header = 1;
BlockConnectionsList structure = 2;
BlockHeadersList headers = 3;
}
message BlockContentPreview {
oneof preview {
bool noPreview = 1;
ImagePreview imagePreview = 2;
VideoPreview videoPreview = 3;
FilePreview filePreview = 4;
TextPreview textPreview = 5;
EmptyPagePreview emptyPagePreview = 6;
TaskPagePreview taskPagePreview = 7;
}
}
message ImagePreview {
string name = 1;
string dateAdded = 2;
int32 size = 3;
string description = 4;
int32 height = 2;
int32 width = 3;
}
message VideoPreview {
string name = 1;
int32 height = 2;
int32 width = 3;
}
message FilePreview {
string name = 1;
string icon = 2;
}
message TextPreview {
int32 symblos = 1;
BlockContentText.Style style = 2;
}
message EmptyPagePreview {
string name = 1;
string icon = 2;
}
message TaskPagePreview {
string header = 1;
string assignee = 2;
// ...
}
*/

30
pb/protos/edit.proto Normal file
View file

@ -0,0 +1,30 @@
syntax="proto3";
package anytype;
option go_package = "pb";
import "block.proto";
import "account.proto";
message UserBlockTextRange {
Account account = 1;
string blockId = 2;
Range range = 3;
}
message UserBlockJoin {
Account account = 1;
}
message UserBlockLeft {
Account account = 1;
}
message UserBlockSelectRange {
Account account = 1;
repeated string blockIdsArray = 2;
}
message UserBlockFocus {
Account account = 1;
string blockId = 2;
}

50
pb/protos/struct.proto Normal file
View file

@ -0,0 +1,50 @@
syntax="proto3";
package anytype;
option go_package = "pb";
message Struct {
// Unordered map of dynamically typed values.
map<string, Value> fields = 1;
}
// `Value` represents a dynamically typed value which can be either
// null, a number, a string, a boolean, a recursive struct value, or a
// list of values. A producer of value is expected to set one of that
// variants, absence of any variant indicates an error.
//
// The JSON representation for `Value` is JSON value.
message Value {
// The kind of value.
oneof kind {
// Represents a null value.
NullValue null_value = 1;
// Represents a double value.
double number_value = 2;
// Represents a string value.
string string_value = 3;
// Represents a boolean value.
bool bool_value = 4;
// Represents a structured value.
Struct struct_value = 5;
// Represents a repeated `Value`.
ListValue list_value = 6;
}
}
// `NullValue` is a singleton enumeration to represent the null value for the
// `Value` type union.
//
// The JSON representation for `NullValue` is JSON `null`.
enum NullValue {
// Null value.
NULL_VALUE = 0;
}
// `ListValue` is a wrapper around a repeated field of values.
//
// The JSON representation for `ListValue` is JSON array.
message ListValue {
// Repeated field of dynamically typed values.
repeated Value values = 1;
}

1230
pb/struct.pb.go Normal file

File diff suppressed because it is too large Load diff