@dcl/protocol 1.0.0-28974105118.commit-a598406 → 1.0.0-28980486989.commit-1e80e43
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 +188 -0
- package/out-js/decentraland/kernel/apis/restricted_actions.gen.d.ts +19 -0
- package/out-js/decentraland/kernel/apis/restricted_actions.gen.js +54 -1
- package/out-js/decentraland/kernel/apis/restricted_actions.gen.js.map +1 -1
- package/out-js/decentraland/kernel/comms/rfc4/comms.gen.d.ts +21 -0
- package/out-js/decentraland/kernel/comms/rfc4/comms.gen.js +124 -4
- package/out-js/decentraland/kernel/comms/rfc4/comms.gen.js.map +1 -1
- package/out-js/decentraland/sdk/components/avatar_shape.gen.d.ts +8 -0
- package/out-js/decentraland/sdk/components/avatar_shape.gen.js +35 -1
- package/out-js/decentraland/sdk/components/avatar_shape.gen.js.map +1 -1
- package/out-ts/decentraland/kernel/apis/restricted_actions.gen.ts +56 -0
- package/out-ts/decentraland/kernel/comms/rfc4/comms.gen.ts +166 -2
- package/out-ts/decentraland/sdk/components/avatar_shape.gen.ts +34 -0
- package/package.json +9 -6
- package/proto/decentraland/common/options.proto +51 -0
- package/proto/decentraland/common/quantization_example.proto +164 -0
- package/proto/decentraland/kernel/apis/restricted_actions.proto +5 -0
- package/proto/decentraland/kernel/comms/rfc4/comms.proto +11 -0
- package/proto/decentraland/pulse/pulse_client.proto +79 -0
- package/proto/decentraland/pulse/pulse_server.proto +142 -0
- package/proto/decentraland/pulse/pulse_shared.proto +57 -0
- package/proto/decentraland/sdk/components/avatar_shape.proto +5 -0
- package/proto/decentraland/sdk/components/light_source.proto +1 -1
- package/proto/decentraland/sdk/components/virtual_camera.proto +2 -0
- package/protoc-gen-bitwise/generator_csharp.js +248 -0
- package/protoc-gen-bitwise/options.js +139 -0
- package/protoc-gen-bitwise/plugin.js +87 -0
- package/protoc-gen-bitwise/runtime/cs/BitReader.cs +112 -0
- package/protoc-gen-bitwise/runtime/cs/BitWriter.cs +117 -0
- package/protoc-gen-bitwise/runtime/cs/Quantize.cs +70 -0
- package/protoc-gen-bitwise/wire.js +239 -0
- package/proto/buf.yaml +0 -47
- package/proto/google/LICENSE +0 -27
- package/proto/google/README.md +0 -1
- package/proto/google/api/annotations.json +0 -83
- package/proto/google/api/annotations.proto +0 -11
- package/proto/google/api/http.json +0 -86
- package/proto/google/api/http.proto +0 -31
- package/proto/google/protobuf/api.json +0 -118
- package/proto/google/protobuf/api.proto +0 -34
- package/proto/google/protobuf/descriptor.json +0 -739
- package/proto/google/protobuf/descriptor.proto +0 -286
- package/proto/google/protobuf/source_context.json +0 -20
- package/proto/google/protobuf/source_context.proto +0 -7
- package/proto/google/protobuf/type.json +0 -202
- package/proto/google/protobuf/type.proto +0 -89
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
// Decentraland.Networking.Bitwise — BitWriter
|
|
2
|
+
// Copy this file into your Unity project alongside generated *.Bitwise.cs files.
|
|
3
|
+
|
|
4
|
+
using System;
|
|
5
|
+
|
|
6
|
+
namespace Decentraland.Networking.Bitwise
|
|
7
|
+
{
|
|
8
|
+
/// <summary>
|
|
9
|
+
/// Writes bits into a pre-allocated byte buffer, MSB first within each byte
|
|
10
|
+
/// (big-endian bit order). This matches the layout expected by
|
|
11
|
+
/// <see cref="BitReader"/> so that encode → decode is always a round-trip no-op.
|
|
12
|
+
/// </summary>
|
|
13
|
+
public sealed class BitWriter
|
|
14
|
+
{
|
|
15
|
+
private readonly byte[] _buffer;
|
|
16
|
+
private int _bitPos;
|
|
17
|
+
|
|
18
|
+
/// <param name="buffer">Destination buffer (must be large enough for all writes).</param>
|
|
19
|
+
public BitWriter(byte[] buffer)
|
|
20
|
+
{
|
|
21
|
+
_buffer = buffer ?? throw new ArgumentNullException(nameof(buffer));
|
|
22
|
+
_bitPos = 0;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/// <summary>Current write position in bits.</summary>
|
|
26
|
+
public int BitPosition => _bitPos;
|
|
27
|
+
|
|
28
|
+
/// <summary>Number of bytes written (rounded up to the nearest byte).</summary>
|
|
29
|
+
public int ByteLength => (_bitPos + 7) / 8;
|
|
30
|
+
|
|
31
|
+
/// <summary>Returns a copy of the written bytes (trimmed to <see cref="ByteLength"/>).</summary>
|
|
32
|
+
public byte[] ToArray()
|
|
33
|
+
{
|
|
34
|
+
var result = new byte[ByteLength];
|
|
35
|
+
Array.Copy(_buffer, result, ByteLength);
|
|
36
|
+
return result;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// -----------------------------------------------------------------
|
|
40
|
+
// Core primitive
|
|
41
|
+
// -----------------------------------------------------------------
|
|
42
|
+
|
|
43
|
+
/// <summary>
|
|
44
|
+
/// Writes the <paramref name="bits"/> least-significant bits of
|
|
45
|
+
/// <paramref name="value"/>, MSB first.
|
|
46
|
+
/// </summary>
|
|
47
|
+
public void WriteBits(uint value, int bits)
|
|
48
|
+
{
|
|
49
|
+
for (int i = bits - 1; i >= 0; i--)
|
|
50
|
+
{
|
|
51
|
+
int byteIdx = _bitPos / 8;
|
|
52
|
+
int bitIdx = 7 - (_bitPos % 8);
|
|
53
|
+
|
|
54
|
+
if ((value >> i & 1u) == 1u)
|
|
55
|
+
_buffer[byteIdx] |= (byte)(1 << bitIdx);
|
|
56
|
+
else
|
|
57
|
+
_buffer[byteIdx] &= (byte)~(1 << bitIdx);
|
|
58
|
+
|
|
59
|
+
_bitPos++;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// -----------------------------------------------------------------
|
|
64
|
+
// Quantized float
|
|
65
|
+
// -----------------------------------------------------------------
|
|
66
|
+
|
|
67
|
+
/// <summary>
|
|
68
|
+
/// Quantizes <paramref name="value"/> into <paramref name="bits"/> bits
|
|
69
|
+
/// using the range [<paramref name="min"/>, <paramref name="max"/>] and
|
|
70
|
+
/// writes it to the buffer.
|
|
71
|
+
///
|
|
72
|
+
/// Uses <c>Math.Round</c> (banker's rounding → ties-to-even) to guarantee
|
|
73
|
+
/// that encode → decode is a round-trip no-op.
|
|
74
|
+
/// </summary>
|
|
75
|
+
public void WriteQuantizedFloat(float value, float min, float max, int bits)
|
|
76
|
+
{
|
|
77
|
+
uint maxQ = (1u << bits) - 1;
|
|
78
|
+
float clamped = Math.Clamp(value, min, max);
|
|
79
|
+
float normalized = (clamped - min) / (max - min);
|
|
80
|
+
uint quantized = (uint)Math.Round(normalized * maxQ);
|
|
81
|
+
WriteBits(quantized, bits);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// -----------------------------------------------------------------
|
|
85
|
+
// Standard IEEE 754 helpers (used for un-annotated float/double fields)
|
|
86
|
+
// -----------------------------------------------------------------
|
|
87
|
+
|
|
88
|
+
/// <summary>Writes a 32-bit IEEE 754 float (4 bytes).</summary>
|
|
89
|
+
public void WriteFloat(float value)
|
|
90
|
+
{
|
|
91
|
+
byte[] bytes = BitConverter.GetBytes(value);
|
|
92
|
+
// GetBytes is little-endian on all platforms; write MSB first.
|
|
93
|
+
uint bits = (uint)bytes[0]
|
|
94
|
+
| ((uint)bytes[1] << 8)
|
|
95
|
+
| ((uint)bytes[2] << 16)
|
|
96
|
+
| ((uint)bytes[3] << 24);
|
|
97
|
+
WriteBits(bits, 32);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/// <summary>Writes a 64-bit IEEE 754 double (8 bytes).</summary>
|
|
101
|
+
public void WriteDouble(double value)
|
|
102
|
+
{
|
|
103
|
+
byte[] bytes = BitConverter.GetBytes(value);
|
|
104
|
+
uint lo = (uint)bytes[0]
|
|
105
|
+
| ((uint)bytes[1] << 8)
|
|
106
|
+
| ((uint)bytes[2] << 16)
|
|
107
|
+
| ((uint)bytes[3] << 24);
|
|
108
|
+
uint hi = (uint)bytes[4]
|
|
109
|
+
| ((uint)bytes[5] << 8)
|
|
110
|
+
| ((uint)bytes[6] << 16)
|
|
111
|
+
| ((uint)bytes[7] << 24);
|
|
112
|
+
// Write high 32 bits first so the bit stream is big-endian at word level too.
|
|
113
|
+
WriteBits(hi, 32);
|
|
114
|
+
WriteBits(lo, 32);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
// Decentraland.Networking.Bitwise — Quantize
|
|
2
|
+
// Copy this file into your project alongside generated *.Bitwise.cs files.
|
|
3
|
+
// ReSharper disable once RedundantUsingDirective
|
|
4
|
+
|
|
5
|
+
using System;
|
|
6
|
+
|
|
7
|
+
namespace Decentraland.Networking.Bitwise
|
|
8
|
+
// ReSharper disable once ArrangeNamespaceBody
|
|
9
|
+
{
|
|
10
|
+
/// <summary>
|
|
11
|
+
/// Static helpers for quantizing float values to/from unsigned integers.
|
|
12
|
+
/// Intended for use with protobuf uint32 fields: the integer is transmitted
|
|
13
|
+
/// as a protobuf varint, while the float accessor lives in a generated partial class.
|
|
14
|
+
/// </summary>
|
|
15
|
+
public static class Quantize
|
|
16
|
+
{
|
|
17
|
+
/// <summary>
|
|
18
|
+
/// Encodes <paramref name="value" /> to a quantized <see cref="uint" />.
|
|
19
|
+
/// Values outside [<paramref name="min" />, <paramref name="max" />] are clamped.
|
|
20
|
+
/// </summary>
|
|
21
|
+
public static uint Encode(float value, float min, float max, int bits)
|
|
22
|
+
{
|
|
23
|
+
var steps = (1u << bits) - 1;
|
|
24
|
+
var t = Math.Clamp((value - min) / (max - min), 0f, 1f);
|
|
25
|
+
return (uint)MathF.Round(t * steps);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/// <summary>Decodes a quantized <see cref="uint" /> back to a float.</summary>
|
|
29
|
+
public static float Decode(uint encoded, float min, float max, int bits)
|
|
30
|
+
{
|
|
31
|
+
var steps = (1u << bits) - 1;
|
|
32
|
+
return (float)encoded / steps * (max - min) + min;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/// <summary>
|
|
36
|
+
/// Encodes <paramref name="value" /> with a power-law curve into an
|
|
37
|
+
/// (<paramref name="bits" /> - 1)-bit linear unorm magnitude plus a sign bit. The magnitude is
|
|
38
|
+
/// <c>(|value| / max)^(1/pow)</c>, so the inverse <see cref="DecodePower" /> reconstructs
|
|
39
|
+
/// <c>sign * max * u^pow</c>. Zero is representable exactly; <paramref name="pow" /> > 1
|
|
40
|
+
/// concentrates resolution near zero. Magnitudes outside [0, <paramref name="max" />] are
|
|
41
|
+
/// clamped.
|
|
42
|
+
/// <para>
|
|
43
|
+
/// The encoded layout puts the magnitude in the high bits and the sign in the LSB
|
|
44
|
+
/// (<c>(magnitude << 1) | sign</c>). This keeps the varint cost a function of
|
|
45
|
+
/// magnitude rather than direction — a small <c>|value|</c> of either sign stays in a
|
|
46
|
+
/// single varint byte. Zero canonicalizes to <c>0</c> (a zero magnitude never sets the
|
|
47
|
+
/// sign bit), so proto3 still omits a stopped field entirely.
|
|
48
|
+
/// </para>
|
|
49
|
+
/// </summary>
|
|
50
|
+
public static uint EncodePower(float value, float max, float pow, int bits)
|
|
51
|
+
{
|
|
52
|
+
var magnitudeSteps = (1u << (bits - 1)) - 1;
|
|
53
|
+
var t = Math.Clamp(MathF.Abs(value) / max, 0f, 1f);
|
|
54
|
+
var u = MathF.Pow(t, 1f / pow);
|
|
55
|
+
var magnitude = (uint)MathF.Round(u * magnitudeSteps);
|
|
56
|
+
var sign = value < 0f && magnitude != 0u ? 1u : 0u;
|
|
57
|
+
return (magnitude << 1) | sign;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/// <summary>Decodes a power-law quantized <see cref="uint" /> back to a float (inverse of
|
|
61
|
+
/// <see cref="EncodePower" />).</summary>
|
|
62
|
+
public static float DecodePower(uint encoded, float max, float pow, int bits)
|
|
63
|
+
{
|
|
64
|
+
var magnitudeSteps = (1u << (bits - 1)) - 1;
|
|
65
|
+
var u = (float)(encoded >> 1) / magnitudeSteps;
|
|
66
|
+
var magnitude = max * MathF.Pow(u, pow);
|
|
67
|
+
return (encoded & 1u) != 0 ? -magnitude : magnitude;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Self-contained protobuf wire-format codec for protoc-gen-bitwise.
|
|
5
|
+
*
|
|
6
|
+
* The plugin only needs a tiny slice of the descriptor/plugin schemas, so
|
|
7
|
+
* rather than pull in a protobuf runtime (which would force every consumer —
|
|
8
|
+
* including the sibling Pulse checkout that runs this file directly off disk —
|
|
9
|
+
* to `npm install` the protocol repo) we decode the handful of fields we care
|
|
10
|
+
* about by walking the wire format directly. This mirrors the original Python
|
|
11
|
+
* plugin, which already hand-parsed FieldOptions for the same reason.
|
|
12
|
+
*
|
|
13
|
+
* Decoded subset:
|
|
14
|
+
* CodeGeneratorRequest { file_to_generate = 1; proto_file = 15; }
|
|
15
|
+
* FileDescriptorProto { name = 1; package = 2; message_type = 4; }
|
|
16
|
+
* DescriptorProto { name = 1; field = 2; }
|
|
17
|
+
* FieldDescriptorProto { name = 1; label = 4; type = 5; options = 8 (raw bytes); }
|
|
18
|
+
*
|
|
19
|
+
* Encoded subset:
|
|
20
|
+
* CodeGeneratorResponse { error = 1; supported_features = 2; file = 15; }
|
|
21
|
+
* CodeGeneratorResponse.File { name = 1; content = 15; }
|
|
22
|
+
*
|
|
23
|
+
* Wire types: 0 = varint, 1 = 64-bit, 2 = length-delimited, 5 = 32-bit.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
// ---------------------------------------------------------------------------
|
|
27
|
+
// Low-level readers
|
|
28
|
+
// ---------------------------------------------------------------------------
|
|
29
|
+
|
|
30
|
+
/** Decode a protobuf varint at `pos`. Returns [value, newPos]. */
|
|
31
|
+
function readVarint(buf, pos) {
|
|
32
|
+
let result = 0
|
|
33
|
+
let shift = 0
|
|
34
|
+
let byte
|
|
35
|
+
do {
|
|
36
|
+
byte = buf[pos++]
|
|
37
|
+
// Multiplication (not <<) keeps values correct past 32 bits.
|
|
38
|
+
result += (byte & 0x7f) * Math.pow(2, shift)
|
|
39
|
+
shift += 7
|
|
40
|
+
} while (byte & 0x80)
|
|
41
|
+
return [result, pos]
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** Advance `pos` past a field of the given wire type. Returns newPos. */
|
|
45
|
+
function skipField(buf, pos, wireType) {
|
|
46
|
+
switch (wireType) {
|
|
47
|
+
case 0: // varint
|
|
48
|
+
return readVarint(buf, pos)[1]
|
|
49
|
+
case 1: // 64-bit
|
|
50
|
+
return pos + 8
|
|
51
|
+
case 2: {
|
|
52
|
+
// length-delimited
|
|
53
|
+
const [length, next] = readVarint(buf, pos)
|
|
54
|
+
return next + length
|
|
55
|
+
}
|
|
56
|
+
case 5: // 32-bit
|
|
57
|
+
return pos + 4
|
|
58
|
+
default:
|
|
59
|
+
// Groups (3/4) are deprecated and never appear in descriptors.
|
|
60
|
+
return pos
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// ---------------------------------------------------------------------------
|
|
65
|
+
// Request decoding
|
|
66
|
+
// ---------------------------------------------------------------------------
|
|
67
|
+
|
|
68
|
+
function decodeFieldDescriptor(buf) {
|
|
69
|
+
const field = { name: '', label: 0, type: 0, optionsRaw: null }
|
|
70
|
+
let pos = 0
|
|
71
|
+
while (pos < buf.length) {
|
|
72
|
+
let tag
|
|
73
|
+
;[tag, pos] = readVarint(buf, pos)
|
|
74
|
+
const fieldNum = tag >>> 3
|
|
75
|
+
const wireType = tag & 0x7
|
|
76
|
+
if (fieldNum === 1 && wireType === 2) {
|
|
77
|
+
let len
|
|
78
|
+
;[len, pos] = readVarint(buf, pos)
|
|
79
|
+
field.name = buf.toString('utf8', pos, pos + len)
|
|
80
|
+
pos += len
|
|
81
|
+
} else if (fieldNum === 4 && wireType === 0) {
|
|
82
|
+
;[field.label, pos] = readVarint(buf, pos)
|
|
83
|
+
} else if (fieldNum === 5 && wireType === 0) {
|
|
84
|
+
;[field.type, pos] = readVarint(buf, pos)
|
|
85
|
+
} else if (fieldNum === 8 && wireType === 2) {
|
|
86
|
+
let len
|
|
87
|
+
;[len, pos] = readVarint(buf, pos)
|
|
88
|
+
// Keep the raw FieldOptions bytes so custom extensions survive (the
|
|
89
|
+
// descriptor schema doesn't know about ext 50001/50002).
|
|
90
|
+
field.optionsRaw = buf.subarray(pos, pos + len)
|
|
91
|
+
pos += len
|
|
92
|
+
} else {
|
|
93
|
+
pos = skipField(buf, pos, wireType)
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return field
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function decodeDescriptor(buf) {
|
|
100
|
+
const message = { name: '', field: [] }
|
|
101
|
+
let pos = 0
|
|
102
|
+
while (pos < buf.length) {
|
|
103
|
+
let tag
|
|
104
|
+
;[tag, pos] = readVarint(buf, pos)
|
|
105
|
+
const fieldNum = tag >>> 3
|
|
106
|
+
const wireType = tag & 0x7
|
|
107
|
+
if (fieldNum === 1 && wireType === 2) {
|
|
108
|
+
let len
|
|
109
|
+
;[len, pos] = readVarint(buf, pos)
|
|
110
|
+
message.name = buf.toString('utf8', pos, pos + len)
|
|
111
|
+
pos += len
|
|
112
|
+
} else if (fieldNum === 2 && wireType === 2) {
|
|
113
|
+
let len
|
|
114
|
+
;[len, pos] = readVarint(buf, pos)
|
|
115
|
+
message.field.push(decodeFieldDescriptor(buf.subarray(pos, pos + len)))
|
|
116
|
+
pos += len
|
|
117
|
+
} else {
|
|
118
|
+
// nested_type / enum_type / etc. are intentionally ignored — the
|
|
119
|
+
// generator only walks top-level messages, matching the Python plugin.
|
|
120
|
+
pos = skipField(buf, pos, wireType)
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return message
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function decodeFileDescriptor(buf) {
|
|
127
|
+
const file = { name: '', package: '', messageType: [] }
|
|
128
|
+
let pos = 0
|
|
129
|
+
while (pos < buf.length) {
|
|
130
|
+
let tag
|
|
131
|
+
;[tag, pos] = readVarint(buf, pos)
|
|
132
|
+
const fieldNum = tag >>> 3
|
|
133
|
+
const wireType = tag & 0x7
|
|
134
|
+
if (fieldNum === 1 && wireType === 2) {
|
|
135
|
+
let len
|
|
136
|
+
;[len, pos] = readVarint(buf, pos)
|
|
137
|
+
file.name = buf.toString('utf8', pos, pos + len)
|
|
138
|
+
pos += len
|
|
139
|
+
} else if (fieldNum === 2 && wireType === 2) {
|
|
140
|
+
let len
|
|
141
|
+
;[len, pos] = readVarint(buf, pos)
|
|
142
|
+
file.package = buf.toString('utf8', pos, pos + len)
|
|
143
|
+
pos += len
|
|
144
|
+
} else if (fieldNum === 4 && wireType === 2) {
|
|
145
|
+
let len
|
|
146
|
+
;[len, pos] = readVarint(buf, pos)
|
|
147
|
+
file.messageType.push(decodeDescriptor(buf.subarray(pos, pos + len)))
|
|
148
|
+
pos += len
|
|
149
|
+
} else {
|
|
150
|
+
pos = skipField(buf, pos, wireType)
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
return file
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/** Decode a serialized CodeGeneratorRequest. */
|
|
157
|
+
function decodeRequest(buf) {
|
|
158
|
+
const request = { fileToGenerate: [], protoFile: [] }
|
|
159
|
+
let pos = 0
|
|
160
|
+
while (pos < buf.length) {
|
|
161
|
+
let tag
|
|
162
|
+
;[tag, pos] = readVarint(buf, pos)
|
|
163
|
+
const fieldNum = tag >>> 3
|
|
164
|
+
const wireType = tag & 0x7
|
|
165
|
+
if (fieldNum === 1 && wireType === 2) {
|
|
166
|
+
let len
|
|
167
|
+
;[len, pos] = readVarint(buf, pos)
|
|
168
|
+
request.fileToGenerate.push(buf.toString('utf8', pos, pos + len))
|
|
169
|
+
pos += len
|
|
170
|
+
} else if (fieldNum === 15 && wireType === 2) {
|
|
171
|
+
let len
|
|
172
|
+
;[len, pos] = readVarint(buf, pos)
|
|
173
|
+
request.protoFile.push(decodeFileDescriptor(buf.subarray(pos, pos + len)))
|
|
174
|
+
pos += len
|
|
175
|
+
} else {
|
|
176
|
+
pos = skipField(buf, pos, wireType)
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
return request
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
// ---------------------------------------------------------------------------
|
|
183
|
+
// Response encoding
|
|
184
|
+
// ---------------------------------------------------------------------------
|
|
185
|
+
|
|
186
|
+
/** Encode an unsigned integer as a protobuf varint Buffer. */
|
|
187
|
+
function encodeVarint(value) {
|
|
188
|
+
const bytes = []
|
|
189
|
+
let v = value
|
|
190
|
+
while (v > 0x7f) {
|
|
191
|
+
bytes.push((v & 0x7f) | 0x80)
|
|
192
|
+
v = Math.floor(v / 128)
|
|
193
|
+
}
|
|
194
|
+
bytes.push(v & 0x7f)
|
|
195
|
+
return Buffer.from(bytes)
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
function encodeTag(fieldNum, wireType) {
|
|
199
|
+
return encodeVarint((fieldNum << 3) | wireType)
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/** Encode a length-delimited (string/bytes) field: tag + length + payload. */
|
|
203
|
+
function encodeLengthDelimited(fieldNum, payload) {
|
|
204
|
+
const buf = Buffer.isBuffer(payload) ? payload : Buffer.from(payload, 'utf8')
|
|
205
|
+
return Buffer.concat([encodeTag(fieldNum, 2), encodeVarint(buf.length), buf])
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
function encodeFile(file) {
|
|
209
|
+
return Buffer.concat([
|
|
210
|
+
encodeLengthDelimited(1, file.name), // name = 1
|
|
211
|
+
encodeLengthDelimited(15, file.content), // content = 15
|
|
212
|
+
])
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* Encode a CodeGeneratorResponse.
|
|
217
|
+
* @param {{error?: string|null, supportedFeatures?: number, files?: Array<{name:string,content:string}>}} response
|
|
218
|
+
*/
|
|
219
|
+
function encodeResponse(response) {
|
|
220
|
+
const parts = []
|
|
221
|
+
if (response.error != null) {
|
|
222
|
+
parts.push(encodeLengthDelimited(1, response.error)) // error = 1
|
|
223
|
+
}
|
|
224
|
+
if (response.supportedFeatures != null) {
|
|
225
|
+
parts.push(encodeTag(2, 0)) // supported_features = 2 (varint)
|
|
226
|
+
parts.push(encodeVarint(response.supportedFeatures))
|
|
227
|
+
}
|
|
228
|
+
for (const file of response.files || []) {
|
|
229
|
+
parts.push(encodeLengthDelimited(15, encodeFile(file))) // file = 15
|
|
230
|
+
}
|
|
231
|
+
return Buffer.concat(parts)
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
module.exports = {
|
|
235
|
+
readVarint,
|
|
236
|
+
skipField,
|
|
237
|
+
decodeRequest,
|
|
238
|
+
encodeResponse,
|
|
239
|
+
}
|
package/proto/buf.yaml
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
version: v1
|
|
2
|
-
breaking:
|
|
3
|
-
use:
|
|
4
|
-
- WIRE_JSON
|
|
5
|
-
ignore:
|
|
6
|
-
- google
|
|
7
|
-
lint:
|
|
8
|
-
use:
|
|
9
|
-
- DIRECTORY_SAME_PACKAGE
|
|
10
|
-
- PACKAGE_DEFINED
|
|
11
|
-
- PACKAGE_DIRECTORY_MATCH
|
|
12
|
-
- PACKAGE_SAME_DIRECTORY
|
|
13
|
-
- ENUM_PASCAL_CASE
|
|
14
|
-
- ENUM_VALUE_UPPER_SNAKE_CASE
|
|
15
|
-
- FIELD_LOWER_SNAKE_CASE
|
|
16
|
-
- MESSAGE_PASCAL_CASE
|
|
17
|
-
- ONEOF_LOWER_SNAKE_CASE
|
|
18
|
-
- PACKAGE_LOWER_SNAKE_CASE
|
|
19
|
-
- RPC_PASCAL_CASE
|
|
20
|
-
- SERVICE_PASCAL_CASE
|
|
21
|
-
- PACKAGE_SAME_CSHARP_NAMESPACE
|
|
22
|
-
- PACKAGE_SAME_GO_PACKAGE
|
|
23
|
-
- PACKAGE_SAME_JAVA_MULTIPLE_FILES
|
|
24
|
-
- PACKAGE_SAME_JAVA_PACKAGE
|
|
25
|
-
- PACKAGE_SAME_PHP_NAMESPACE
|
|
26
|
-
- PACKAGE_SAME_RUBY_PACKAGE
|
|
27
|
-
- PACKAGE_SAME_SWIFT_PREFIX
|
|
28
|
-
- ENUM_FIRST_VALUE_ZERO
|
|
29
|
-
- ENUM_NO_ALLOW_ALIAS
|
|
30
|
-
- IMPORT_NO_WEAK
|
|
31
|
-
- IMPORT_NO_PUBLIC
|
|
32
|
-
- IMPORT_USED
|
|
33
|
-
- FILE_LOWER_SNAKE_CASE
|
|
34
|
-
# Ignored:the default value is used
|
|
35
|
-
# - ENUM_ZERO_VALUE_SUFFIX
|
|
36
|
-
# Ignored: if a prefix is needed in the target language, implement a preprocessor
|
|
37
|
-
# - ENUM_VALUE_PREFIX
|
|
38
|
-
# Not wished
|
|
39
|
-
# - PACKAGE_VERSION_SUFFIX
|
|
40
|
-
# TODO: See if this needs to be added
|
|
41
|
-
# - RPC_REQUEST_RESPONSE_UNIQUE
|
|
42
|
-
# - RPC_REQUEST_STANDARD_NAME
|
|
43
|
-
# - RPC_RESPONSE_STANDARD_NAME
|
|
44
|
-
# - SERVICE_SUFFIX
|
|
45
|
-
ignore:
|
|
46
|
-
- google
|
|
47
|
-
- decentraland/renderer/engine_interface.proto
|
package/proto/google/LICENSE
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
Copyright 2014, Google Inc. All rights reserved.
|
|
2
|
-
|
|
3
|
-
Redistribution and use in source and binary forms, with or without
|
|
4
|
-
modification, are permitted provided that the following conditions are
|
|
5
|
-
met:
|
|
6
|
-
|
|
7
|
-
* Redistributions of source code must retain the above copyright
|
|
8
|
-
notice, this list of conditions and the following disclaimer.
|
|
9
|
-
* Redistributions in binary form must reproduce the above
|
|
10
|
-
copyright notice, this list of conditions and the following disclaimer
|
|
11
|
-
in the documentation and/or other materials provided with the
|
|
12
|
-
distribution.
|
|
13
|
-
* Neither the name of Google Inc. nor the names of its
|
|
14
|
-
contributors may be used to endorse or promote products derived from
|
|
15
|
-
this software without specific prior written permission.
|
|
16
|
-
|
|
17
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
18
|
-
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
19
|
-
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
20
|
-
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
21
|
-
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
22
|
-
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
23
|
-
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
24
|
-
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
25
|
-
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
26
|
-
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
27
|
-
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
package/proto/google/README.md
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
This folder contains stripped and pre-parsed definitions of common Google types. These files are not used by protobuf.js directly but are here so you can use or include them where required.
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"nested": {
|
|
3
|
-
"google": {
|
|
4
|
-
"nested": {
|
|
5
|
-
"api": {
|
|
6
|
-
"nested": {
|
|
7
|
-
"http": {
|
|
8
|
-
"type": "HttpRule",
|
|
9
|
-
"id": 72295728,
|
|
10
|
-
"extend": "google.protobuf.MethodOptions"
|
|
11
|
-
},
|
|
12
|
-
"HttpRule": {
|
|
13
|
-
"oneofs": {
|
|
14
|
-
"pattern": {
|
|
15
|
-
"oneof": [
|
|
16
|
-
"get",
|
|
17
|
-
"put",
|
|
18
|
-
"post",
|
|
19
|
-
"delete",
|
|
20
|
-
"patch",
|
|
21
|
-
"custom"
|
|
22
|
-
]
|
|
23
|
-
}
|
|
24
|
-
},
|
|
25
|
-
"fields": {
|
|
26
|
-
"get": {
|
|
27
|
-
"type": "string",
|
|
28
|
-
"id": 2
|
|
29
|
-
},
|
|
30
|
-
"put": {
|
|
31
|
-
"type": "string",
|
|
32
|
-
"id": 3
|
|
33
|
-
},
|
|
34
|
-
"post": {
|
|
35
|
-
"type": "string",
|
|
36
|
-
"id": 4
|
|
37
|
-
},
|
|
38
|
-
"delete": {
|
|
39
|
-
"type": "string",
|
|
40
|
-
"id": 5
|
|
41
|
-
},
|
|
42
|
-
"patch": {
|
|
43
|
-
"type": "string",
|
|
44
|
-
"id": 6
|
|
45
|
-
},
|
|
46
|
-
"custom": {
|
|
47
|
-
"type": "CustomHttpPattern",
|
|
48
|
-
"id": 8
|
|
49
|
-
},
|
|
50
|
-
"selector": {
|
|
51
|
-
"type": "string",
|
|
52
|
-
"id": 1
|
|
53
|
-
},
|
|
54
|
-
"body": {
|
|
55
|
-
"type": "string",
|
|
56
|
-
"id": 7
|
|
57
|
-
},
|
|
58
|
-
"additionalBindings": {
|
|
59
|
-
"rule": "repeated",
|
|
60
|
-
"type": "HttpRule",
|
|
61
|
-
"id": 11
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
},
|
|
67
|
-
"protobuf": {
|
|
68
|
-
"nested": {
|
|
69
|
-
"MethodOptions": {
|
|
70
|
-
"fields": {},
|
|
71
|
-
"extensions": [
|
|
72
|
-
[
|
|
73
|
-
1000,
|
|
74
|
-
536870911
|
|
75
|
-
]
|
|
76
|
-
]
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"nested": {
|
|
3
|
-
"google": {
|
|
4
|
-
"nested": {
|
|
5
|
-
"api": {
|
|
6
|
-
"nested": {
|
|
7
|
-
"Http": {
|
|
8
|
-
"fields": {
|
|
9
|
-
"rules": {
|
|
10
|
-
"rule": "repeated",
|
|
11
|
-
"type": "HttpRule",
|
|
12
|
-
"id": 1
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
},
|
|
16
|
-
"HttpRule": {
|
|
17
|
-
"oneofs": {
|
|
18
|
-
"pattern": {
|
|
19
|
-
"oneof": [
|
|
20
|
-
"get",
|
|
21
|
-
"put",
|
|
22
|
-
"post",
|
|
23
|
-
"delete",
|
|
24
|
-
"patch",
|
|
25
|
-
"custom"
|
|
26
|
-
]
|
|
27
|
-
}
|
|
28
|
-
},
|
|
29
|
-
"fields": {
|
|
30
|
-
"get": {
|
|
31
|
-
"type": "string",
|
|
32
|
-
"id": 2
|
|
33
|
-
},
|
|
34
|
-
"put": {
|
|
35
|
-
"type": "string",
|
|
36
|
-
"id": 3
|
|
37
|
-
},
|
|
38
|
-
"post": {
|
|
39
|
-
"type": "string",
|
|
40
|
-
"id": 4
|
|
41
|
-
},
|
|
42
|
-
"delete": {
|
|
43
|
-
"type": "string",
|
|
44
|
-
"id": 5
|
|
45
|
-
},
|
|
46
|
-
"patch": {
|
|
47
|
-
"type": "string",
|
|
48
|
-
"id": 6
|
|
49
|
-
},
|
|
50
|
-
"custom": {
|
|
51
|
-
"type": "CustomHttpPattern",
|
|
52
|
-
"id": 8
|
|
53
|
-
},
|
|
54
|
-
"selector": {
|
|
55
|
-
"type": "string",
|
|
56
|
-
"id": 1
|
|
57
|
-
},
|
|
58
|
-
"body": {
|
|
59
|
-
"type": "string",
|
|
60
|
-
"id": 7
|
|
61
|
-
},
|
|
62
|
-
"additionalBindings": {
|
|
63
|
-
"rule": "repeated",
|
|
64
|
-
"type": "HttpRule",
|
|
65
|
-
"id": 11
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
},
|
|
69
|
-
"CustomHttpPattern": {
|
|
70
|
-
"fields": {
|
|
71
|
-
"kind": {
|
|
72
|
-
"type": "string",
|
|
73
|
-
"id": 1
|
|
74
|
-
},
|
|
75
|
-
"path": {
|
|
76
|
-
"type": "string",
|
|
77
|
-
"id": 2
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}
|