@dxos/codec-protobuf 2.33.9-dev.e605934d → 2.33.9-dev.eb69ac10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +39 -0
- package/dist/{index.js → browser.js} +3983 -197
- package/dist/src/buffer-patch.d.ts +1 -0
- package/dist/src/buffer-patch.d.ts.map +1 -1
- package/dist/src/buffer-patch.js +15 -0
- package/dist/src/buffer-patch.js.map +1 -0
- package/dist/src/codec.js +53 -0
- package/dist/src/codec.js.map +1 -0
- package/dist/src/common.js +6 -0
- package/dist/src/common.js.map +1 -0
- package/dist/src/encoding.js +35 -0
- package/dist/src/encoding.js.map +1 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +31 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/interface.js +14 -0
- package/dist/src/interface.js.map +1 -0
- package/dist/src/mapping.d.ts +3 -0
- package/dist/src/mapping.d.ts.map +1 -1
- package/dist/src/mapping.js +72 -0
- package/dist/src/mapping.js.map +1 -0
- package/dist/src/precompiled-mapping/codegen.js +86 -0
- package/dist/src/precompiled-mapping/codegen.js.map +1 -0
- package/dist/src/precompiled-mapping/create-message-mapper.js +132 -0
- package/dist/src/precompiled-mapping/create-message-mapper.js.map +1 -0
- package/dist/src/sanitizer.js +53 -0
- package/dist/src/sanitizer.js.map +1 -0
- package/dist/src/schema.js +86 -0
- package/dist/src/schema.js.map +1 -0
- package/dist/src/service.d.ts +2 -2
- package/dist/src/service.d.ts.map +1 -1
- package/dist/src/service.js +113 -0
- package/dist/src/service.js.map +1 -0
- package/dist/src/stream.d.ts +31 -0
- package/dist/src/stream.d.ts.map +1 -1
- package/dist/src/stream.js +186 -0
- package/dist/src/stream.js.map +1 -0
- package/dist/src/stream.test.js +66 -0
- package/dist/src/stream.test.js.map +1 -0
- package/dist/src/substitutions/any.js +30 -0
- package/dist/src/substitutions/any.js.map +1 -0
- package/dist/src/substitutions/index.js +22 -0
- package/dist/src/substitutions/index.js.map +1 -0
- package/dist/src/substitutions/timestamp.js +19 -0
- package/dist/src/substitutions/timestamp.js.map +1 -0
- package/dist/test/codec.test.js +67 -0
- package/dist/test/codec.test.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +10 -7
- package/src/encoding.ts +9 -0
- package/src/index.ts +2 -0
- package/src/mapping.ts +60 -0
- package/src/precompiled-mapping/create-message-mapper.ts +41 -3
- package/src/service.ts +11 -18
- package/src/stream.test.ts +3 -1
- package/src/stream.ts +72 -1
package/README.md
CHANGED
|
@@ -1,5 +1,44 @@
|
|
|
1
1
|
# codec-protobuf
|
|
2
2
|
|
|
3
|
+
There's an associated @dxos/protobuf-compiler package that does codegen based on protobuf schema.
|
|
4
|
+
|
|
5
|
+
## Handling of scalar fields with default values
|
|
6
|
+
|
|
7
|
+
Based on:
|
|
8
|
+
- https://github.com/protocolbuffers/protobuf/blob/main/docs/field_presence.md
|
|
9
|
+
- https://github.com/protocolbuffers/protobuf/blob/main/docs/implementing_proto3_presence.md
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
In protobuf scalar fields (numbers, booleans, strings, bytes, enums) may have an implicit default value:
|
|
13
|
+
|
|
14
|
+
- 0 for number types
|
|
15
|
+
- false for booleans
|
|
16
|
+
- '' (empty string) for strings
|
|
17
|
+
- [] for bytes
|
|
18
|
+
- First enum value for enums
|
|
19
|
+
|
|
20
|
+
### Non-optional fields
|
|
21
|
+
|
|
22
|
+
Example:
|
|
23
|
+
|
|
24
|
+
```protobuf
|
|
25
|
+
int32 number = 1;
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
If the field is set to it's default value (0 in this example) it MAY be missing in the wire encoding (Go implementation) or present with the value set to 0 (JS implementation).
|
|
29
|
+
|
|
30
|
+
When decoding, the missing fields MUST be treated as having the default implicit value (0 in this case).
|
|
31
|
+
|
|
32
|
+
### Optional fields
|
|
33
|
+
|
|
34
|
+
```protobuf
|
|
35
|
+
optional int32 number = 1;
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
If the field is set to it's default value (0 in this example) it MUST be present in the wire encoding with the value set to 0.
|
|
39
|
+
|
|
40
|
+
When decoding, the missing fields it MUST be set as undefined. If the field is present in the wire format, it must be set to its numeric value.
|
|
41
|
+
|
|
3
42
|
## Toolchain
|
|
4
43
|
|
|
5
44
|
This package must NOT use `toolchain` to avoid cyclic dependencies.
|