diff --git a/packages/loot-core/src/server/sync/README.md b/packages/loot-core/src/server/sync/README.md index 0077e83d12c311e9a838fa74c0f9313bc8d1a17c..5df92100ca6b153eeb8ad4e1d88fcf864376f31e 100644 --- a/packages/loot-core/src/server/sync/README.md +++ b/packages/loot-core/src/server/sync/README.md @@ -1,17 +1,29 @@ +# protobuf + +We use [protobuf](https://developers.google.com/protocol-buffers/) to encode messages as binary data to send across the network. + ## Generating protobuf -We use protobuf to encode messages as binary data to send across the network. +The protobuf is generated by using the [protoc](https://github.com/protocolbuffers/protobuf) compiler. + +This can be installed by downloading one of the [pre-built binaries](https://github.com/protocolbuffers/protobuf/releases/) and placing it in your `$PATH`. The version used to build the current protobuf is [v3.20.1](https://github.com/protocolbuffers/protobuf/releases/tag/v3.20.1). + +Once installed, the protobuf can be generated by running the below commands. -To generate the protobuf: I forget, will document this soon. +```bash +cd packages/loot-core/src/server/sync + +protoc sync.proto --js_out=import_style=commonjs,binary:proto +``` However there is one very important thing to remember! The default output includes this near the top: ``` -var global = Function('return this')(); +var global = (function() { return this || window || global || self || Function('return this')(); }).call(null); ``` This will not work with our CSP directives. You must manually modify this to this: ``` var global = globalThis; -``` \ No newline at end of file +``` diff --git a/packages/loot-core/src/server/sync/proto/sync_pb.js b/packages/loot-core/src/server/sync/proto/sync_pb.js index f8100d43612c83a645688ab2b9169dbf10532ded..65bdc528b99874e44a3fccc27d77aac7d033ed7d 100644 --- a/packages/loot-core/src/server/sync/proto/sync_pb.js +++ b/packages/loot-core/src/server/sync/proto/sync_pb.js @@ -2,11 +2,14 @@ /** * @fileoverview * @enhanceable + * @suppress {missingRequire} reports error on implicit type usages. * @suppress {messageConventions} JS Compiler reports an error if a variable or * field starts with 'MSG_' and isn't a translatable message. * @public */ // GENERATED CODE -- DO NOT EDIT! +/* eslint-disable */ +// @ts-nocheck var jspb = require('google-protobuf'); var goog = jspb;