@aptre/protobuf-es-lite 0.2.6 → 0.2.8
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/.ignore +1 -0
- package/README.md +25 -24
- package/bin/protoc-gen-es-lite +3 -3
- package/dist/binary-encoding.d.ts +420 -0
- package/dist/binary-encoding.js +437 -0
- package/dist/binary.d.ts +35 -2
- package/dist/binary.js +69 -66
- package/dist/codegen-info.d.ts +43 -0
- package/dist/codegen-info.js +72 -0
- package/dist/create-descriptor-set.d.ts +36 -0
- package/dist/create-descriptor-set.js +936 -0
- package/dist/descriptor-set.d.ts +672 -0
- package/dist/{editions.js → descriptor-set.js} +0 -11
- package/dist/enum.d.ts +35 -1
- package/dist/feature-set.d.ts +19 -0
- package/dist/feature-set.js +103 -0
- package/dist/field-wrapper.d.ts +7 -3
- package/dist/field-wrapper.js +30 -1
- package/dist/field.d.ts +8 -19
- package/dist/field.js +15 -117
- package/dist/google/index.d.ts +9 -0
- package/dist/google/index.js +41 -0
- package/dist/google/protobuf/any.pb.d.ts +139 -0
- package/dist/google/protobuf/any.pb.js +42 -0
- package/dist/google/protobuf/api.pb.d.ts +252 -0
- package/dist/google/protobuf/api.pb.js +70 -0
- package/dist/google/protobuf/compiler/plugin.pb.d.ts +240 -0
- package/dist/google/protobuf/compiler/plugin.pb.js +203 -0
- package/dist/google/protobuf/descriptor.pb.d.ts +2132 -0
- package/dist/google/protobuf/descriptor.pb.js +1080 -0
- package/dist/google/protobuf/duration.pb.d.ts +92 -0
- package/dist/google/protobuf/duration.pb.js +42 -0
- package/dist/google/protobuf/empty.pb.d.ts +18 -0
- package/dist/google/protobuf/empty.pb.js +39 -0
- package/dist/google/protobuf/source_context.pb.d.ts +21 -0
- package/dist/google/protobuf/source_context.pb.js +41 -0
- package/dist/google/protobuf/struct.pb.d.ts +121 -0
- package/dist/google/protobuf/struct.pb.js +83 -0
- package/dist/google/protobuf/timestamp.pb.d.ts +121 -0
- package/dist/google/protobuf/timestamp.pb.js +42 -0
- package/dist/google/protobuf/type.pb.d.ts +464 -0
- package/dist/google/protobuf/type.pb.js +338 -0
- package/dist/google/protobuf/wrappers.pb.d.ts +183 -0
- package/dist/google/protobuf/wrappers.pb.js +107 -0
- package/dist/index.d.ts +8 -3
- package/dist/index.js +38 -8
- package/dist/is-message.d.ts +10 -2
- package/dist/is-message.js +76 -3
- package/dist/json.d.ts +68 -1
- package/dist/json.js +60 -81
- package/dist/message.d.ts +30 -61
- package/dist/message.js +63 -18
- package/dist/names.d.ts +43 -0
- package/dist/names.js +276 -0
- package/dist/partial.js +19 -16
- package/dist/proto-base64.d.ts +18 -0
- package/dist/proto-base64.js +128 -0
- package/dist/proto-double.d.ts +5 -0
- package/dist/proto-double.js +29 -0
- package/dist/proto-int64.d.ts +95 -0
- package/dist/proto-int64.js +116 -0
- package/dist/protoc-gen-es-lite/protoc-gen-es-lite-plugin.d.ts +1 -0
- package/dist/{protoc-gen-es-lite-plugin.js → protoc-gen-es-lite/protoc-gen-es-lite-plugin.js} +2 -2
- package/dist/{typescript.d.ts → protoc-gen-es-lite/typescript.d.ts} +3 -2
- package/dist/{typescript.js → protoc-gen-es-lite/typescript.js} +48 -36
- package/dist/protoplugin/create-es-plugin.d.ts +83 -0
- package/dist/protoplugin/create-es-plugin.js +119 -0
- package/dist/protoplugin/ecmascript/file-preamble.d.ts +2 -0
- package/dist/protoplugin/ecmascript/file-preamble.js +74 -0
- package/dist/protoplugin/ecmascript/generated-file.d.ts +116 -0
- package/dist/protoplugin/ecmascript/generated-file.js +407 -0
- package/dist/protoplugin/ecmascript/import-path.d.ts +65 -0
- package/dist/protoplugin/ecmascript/import-path.js +156 -0
- package/dist/protoplugin/ecmascript/import-symbol.d.ts +39 -0
- package/dist/protoplugin/ecmascript/import-symbol.js +37 -0
- package/dist/protoplugin/ecmascript/index.d.ts +7 -0
- package/dist/protoplugin/ecmascript/index.js +20 -0
- package/dist/protoplugin/ecmascript/jsdoc.d.ts +14 -0
- package/dist/protoplugin/ecmascript/jsdoc.js +93 -0
- package/dist/protoplugin/ecmascript/opaque-printables.d.ts +27 -0
- package/dist/protoplugin/ecmascript/opaque-printables.js +15 -0
- package/dist/protoplugin/ecmascript/parameter.d.ts +13 -0
- package/dist/protoplugin/ecmascript/parameter.js +161 -0
- package/dist/protoplugin/ecmascript/reify-wkt.d.ts +100 -0
- package/dist/protoplugin/ecmascript/reify-wkt.js +170 -0
- package/dist/protoplugin/ecmascript/runtime-imports.d.ts +6 -0
- package/dist/protoplugin/ecmascript/runtime-imports.js +28 -0
- package/dist/protoplugin/ecmascript/schema.d.ts +43 -0
- package/dist/protoplugin/ecmascript/schema.js +73 -0
- package/dist/protoplugin/ecmascript/target.d.ts +4 -0
- package/dist/protoplugin/ecmascript/target.js +15 -0
- package/dist/protoplugin/ecmascript/transpile.d.ts +2 -0
- package/dist/protoplugin/ecmascript/transpile.js +149 -0
- package/dist/protoplugin/error.d.ts +6 -0
- package/dist/protoplugin/error.js +43 -0
- package/dist/protoplugin/index.d.ts +8 -0
- package/dist/protoplugin/index.js +20 -0
- package/dist/protoplugin/plugin.d.ts +18 -0
- package/dist/protoplugin/plugin.js +15 -0
- package/dist/protoplugin/run-node.d.ts +12 -0
- package/dist/protoplugin/run-node.js +83 -0
- package/dist/scalar.d.ts +53 -1
- package/dist/scalar.js +87 -22
- package/dist/service-type.d.ts +95 -0
- package/dist/service-type.js +53 -0
- package/dist/text-format.d.ts +4 -0
- package/dist/text-format.js +189 -0
- package/dist/type-registry.d.ts +43 -0
- package/dist/type-registry.js +15 -0
- package/dist/unknown.d.ts +1 -1
- package/dist/util.d.ts +2 -2
- package/dist/util.js +46 -44
- package/dist/varint.d.ts +70 -0
- package/dist/varint.js +324 -0
- package/example/example.pb.ts +87 -0
- package/example/example.proto +1 -0
- package/example/tsconfig.json +8 -2
- package/package.json +19 -12
- package/tsconfig.json +4 -4
- package/dist/editions.d.ts +0 -6
- package/dist/protoc-gen-es-lite-plugin.d.ts +0 -1
package/dist/binary.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.writeMapEntry = exports.writeMessage = exports.readMessage = exports.makeWriteOptions = exports.makeReadOptions = exports.readScalarLTString = exports.readScalar = exports.readMapEntry = exports.readField = void 0;
|
|
4
|
-
const protobuf_1 = require("@bufbuild/protobuf");
|
|
5
4
|
const field_js_1 = require("./field.js");
|
|
6
5
|
const is_message_js_1 = require("./is-message.js");
|
|
7
6
|
const unknown_js_1 = require("./unknown.js");
|
|
8
7
|
const field_wrapper_js_1 = require("./field-wrapper.js");
|
|
9
8
|
const scalar_js_1 = require("./scalar.js");
|
|
10
9
|
const assert_js_1 = require("./assert.js");
|
|
10
|
+
const binary_encoding_js_1 = require("./binary-encoding.js");
|
|
11
11
|
function readField(target, // eslint-disable-line @typescript-eslint/no-explicit-any -- `any` is the best choice for dynamic access
|
|
12
12
|
reader, field, wireType, options) {
|
|
13
13
|
let { repeated, localName } = field;
|
|
@@ -26,7 +26,7 @@ reader, field, wireType, options) {
|
|
|
26
26
|
switch (field.kind) {
|
|
27
27
|
case "scalar":
|
|
28
28
|
case "enum":
|
|
29
|
-
const scalarType = field.kind == "enum" ?
|
|
29
|
+
const scalarType = field.kind == "enum" ? scalar_js_1.ScalarType.INT32 : field.T;
|
|
30
30
|
let read = readScalar;
|
|
31
31
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison -- acceptable since it's covered by tests
|
|
32
32
|
if (field.kind == "scalar" && field.L > 0) {
|
|
@@ -37,9 +37,9 @@ reader, field, wireType, options) {
|
|
|
37
37
|
if (!Array.isArray(tgtArr)) {
|
|
38
38
|
tgtArr = target[localName] = [];
|
|
39
39
|
}
|
|
40
|
-
const isPacked = wireType ==
|
|
41
|
-
scalarType !=
|
|
42
|
-
scalarType !=
|
|
40
|
+
const isPacked = wireType == binary_encoding_js_1.WireType.LengthDelimited &&
|
|
41
|
+
scalarType != scalar_js_1.ScalarType.STRING &&
|
|
42
|
+
scalarType != scalar_js_1.ScalarType.BYTES;
|
|
43
43
|
if (isPacked) {
|
|
44
44
|
let e = reader.uint32() + reader.pos;
|
|
45
45
|
while (reader.pos < e) {
|
|
@@ -55,7 +55,8 @@ reader, field, wireType, options) {
|
|
|
55
55
|
}
|
|
56
56
|
break;
|
|
57
57
|
case "message":
|
|
58
|
-
const
|
|
58
|
+
const fieldT = field.T;
|
|
59
|
+
const messageType = fieldT instanceof Function ? fieldT() : fieldT;
|
|
59
60
|
if (repeated) {
|
|
60
61
|
var tgtArr = target[localName];
|
|
61
62
|
if (!Array.isArray(tgtArr)) {
|
|
@@ -105,28 +106,30 @@ function readMapEntry(field, reader, options) {
|
|
|
105
106
|
val = reader.int32();
|
|
106
107
|
break;
|
|
107
108
|
case "message":
|
|
108
|
-
|
|
109
|
+
const messageType = (0, field_js_1.resolveMessageType)(field.V.T);
|
|
110
|
+
val = readMessageField(reader, messageType.create(), messageType.fields, options, undefined);
|
|
109
111
|
break;
|
|
110
112
|
}
|
|
111
113
|
break;
|
|
112
114
|
}
|
|
113
115
|
}
|
|
114
116
|
if (key === undefined) {
|
|
115
|
-
key = (0, scalar_js_1.scalarZeroValue)(field.K,
|
|
117
|
+
key = (0, scalar_js_1.scalarZeroValue)(field.K, scalar_js_1.LongType.BIGINT);
|
|
116
118
|
}
|
|
117
119
|
if (typeof key != "string" && typeof key != "number") {
|
|
118
120
|
key = key.toString();
|
|
119
121
|
}
|
|
120
122
|
if (val === undefined) {
|
|
121
|
-
|
|
123
|
+
const fieldKind = field.V.kind;
|
|
124
|
+
switch (fieldKind) {
|
|
122
125
|
case "scalar":
|
|
123
|
-
val = (0, scalar_js_1.scalarZeroValue)(field.V.T,
|
|
126
|
+
val = (0, scalar_js_1.scalarZeroValue)(field.V.T, scalar_js_1.LongType.BIGINT);
|
|
124
127
|
break;
|
|
125
128
|
case "enum":
|
|
126
129
|
val = field.V.T.values[0].no;
|
|
127
130
|
break;
|
|
128
131
|
case "message":
|
|
129
|
-
val = field.V.T.create();
|
|
132
|
+
val = (0, field_js_1.resolveMessageType)(field.V.T).create();
|
|
130
133
|
break;
|
|
131
134
|
}
|
|
132
135
|
}
|
|
@@ -135,35 +138,35 @@ function readMapEntry(field, reader, options) {
|
|
|
135
138
|
exports.readMapEntry = readMapEntry;
|
|
136
139
|
function readScalar(reader, type) {
|
|
137
140
|
switch (type) {
|
|
138
|
-
case
|
|
141
|
+
case scalar_js_1.ScalarType.STRING:
|
|
139
142
|
return reader.string();
|
|
140
|
-
case
|
|
143
|
+
case scalar_js_1.ScalarType.BOOL:
|
|
141
144
|
return reader.bool();
|
|
142
|
-
case
|
|
145
|
+
case scalar_js_1.ScalarType.DOUBLE:
|
|
143
146
|
return reader.double();
|
|
144
|
-
case
|
|
147
|
+
case scalar_js_1.ScalarType.FLOAT:
|
|
145
148
|
return reader.float();
|
|
146
|
-
case
|
|
149
|
+
case scalar_js_1.ScalarType.INT32:
|
|
147
150
|
return reader.int32();
|
|
148
|
-
case
|
|
151
|
+
case scalar_js_1.ScalarType.INT64:
|
|
149
152
|
return reader.int64();
|
|
150
|
-
case
|
|
153
|
+
case scalar_js_1.ScalarType.UINT64:
|
|
151
154
|
return reader.uint64();
|
|
152
|
-
case
|
|
155
|
+
case scalar_js_1.ScalarType.FIXED64:
|
|
153
156
|
return reader.fixed64();
|
|
154
|
-
case
|
|
157
|
+
case scalar_js_1.ScalarType.BYTES:
|
|
155
158
|
return reader.bytes();
|
|
156
|
-
case
|
|
159
|
+
case scalar_js_1.ScalarType.FIXED32:
|
|
157
160
|
return reader.fixed32();
|
|
158
|
-
case
|
|
161
|
+
case scalar_js_1.ScalarType.SFIXED32:
|
|
159
162
|
return reader.sfixed32();
|
|
160
|
-
case
|
|
163
|
+
case scalar_js_1.ScalarType.SFIXED64:
|
|
161
164
|
return reader.sfixed64();
|
|
162
|
-
case
|
|
165
|
+
case scalar_js_1.ScalarType.SINT64:
|
|
163
166
|
return reader.sint64();
|
|
164
|
-
case
|
|
167
|
+
case scalar_js_1.ScalarType.UINT32:
|
|
165
168
|
return reader.uint32();
|
|
166
|
-
case
|
|
169
|
+
case scalar_js_1.ScalarType.SINT32:
|
|
167
170
|
return reader.sint32();
|
|
168
171
|
}
|
|
169
172
|
}
|
|
@@ -186,12 +189,12 @@ function readMessageField(reader, message, fields, options, field) {
|
|
|
186
189
|
// Default options for parsing binary data.
|
|
187
190
|
const readDefaults = {
|
|
188
191
|
readUnknownFields: true,
|
|
189
|
-
readerFactory: (bytes) => new
|
|
192
|
+
readerFactory: (bytes) => new binary_encoding_js_1.BinaryReader(bytes),
|
|
190
193
|
};
|
|
191
194
|
// Default options for serializing binary data.
|
|
192
195
|
const writeDefaults = {
|
|
193
196
|
writeUnknownFields: true,
|
|
194
|
-
writerFactory: () => new
|
|
197
|
+
writerFactory: () => new binary_encoding_js_1.BinaryWriter(),
|
|
195
198
|
};
|
|
196
199
|
function makeReadOptions(options) {
|
|
197
200
|
return options ? { ...readDefaults, ...options } : readDefaults;
|
|
@@ -203,13 +206,11 @@ function makeWriteOptions(options) {
|
|
|
203
206
|
exports.makeWriteOptions = makeWriteOptions;
|
|
204
207
|
function readMessage(message, fields, reader, lengthOrEndTagFieldNo, options, delimitedMessageEncoding) {
|
|
205
208
|
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
|
206
|
-
const end = delimitedMessageEncoding
|
|
207
|
-
? reader.len
|
|
208
|
-
: reader.pos + lengthOrEndTagFieldNo;
|
|
209
|
+
const end = delimitedMessageEncoding ? reader.len : reader.pos + lengthOrEndTagFieldNo;
|
|
209
210
|
let fieldNo, wireType;
|
|
210
211
|
while (reader.pos < end) {
|
|
211
212
|
[fieldNo, wireType] = reader.tag();
|
|
212
|
-
if (wireType ==
|
|
213
|
+
if (wireType == binary_encoding_js_1.WireType.EndGroup) {
|
|
213
214
|
break;
|
|
214
215
|
}
|
|
215
216
|
const field = fields.find(fieldNo);
|
|
@@ -223,7 +224,7 @@ function readMessage(message, fields, reader, lengthOrEndTagFieldNo, options, de
|
|
|
223
224
|
readField(message, reader, field, wireType, options);
|
|
224
225
|
}
|
|
225
226
|
if (delimitedMessageEncoding && // eslint-disable-line @typescript-eslint/strict-boolean-expressions
|
|
226
|
-
(wireType !=
|
|
227
|
+
(wireType != binary_encoding_js_1.WireType.EndGroup || fieldNo !== lengthOrEndTagFieldNo)) {
|
|
227
228
|
throw new Error(`invalid end group tag`);
|
|
228
229
|
}
|
|
229
230
|
}
|
|
@@ -239,8 +240,8 @@ function writeMessage(message, fields, writer, options) {
|
|
|
239
240
|
}
|
|
240
241
|
continue;
|
|
241
242
|
}
|
|
242
|
-
const value = field.oneof
|
|
243
|
-
|
|
243
|
+
const value = field.oneof ?
|
|
244
|
+
message[field.oneof.localName].value
|
|
244
245
|
: message[field.localName];
|
|
245
246
|
writeField(field, value, writer, options);
|
|
246
247
|
}
|
|
@@ -255,7 +256,7 @@ function writeField(field, value, writer, options) {
|
|
|
255
256
|
switch (field.kind) {
|
|
256
257
|
case "scalar":
|
|
257
258
|
case "enum":
|
|
258
|
-
let scalarType = field.kind == "enum" ?
|
|
259
|
+
let scalarType = field.kind == "enum" ? scalar_js_1.ScalarType.INT32 : field.T;
|
|
259
260
|
if (repeated) {
|
|
260
261
|
(0, assert_js_1.assert)(Array.isArray(value));
|
|
261
262
|
if (field.packed) {
|
|
@@ -301,17 +302,18 @@ function writeUnknownFields(message, writer) {
|
|
|
301
302
|
}
|
|
302
303
|
// Value must not be undefined
|
|
303
304
|
function writeMessageField(writer, options, field, value) {
|
|
304
|
-
const
|
|
305
|
+
const messageType = (0, field_js_1.resolveMessageType)(field.T);
|
|
306
|
+
const message = (0, field_wrapper_js_1.wrapField)(messageType.fieldWrapper, value);
|
|
305
307
|
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
|
306
308
|
if (field.delimited)
|
|
307
309
|
writer
|
|
308
|
-
.tag(field.no,
|
|
309
|
-
.raw(
|
|
310
|
-
.tag(field.no,
|
|
310
|
+
.tag(field.no, binary_encoding_js_1.WireType.StartGroup)
|
|
311
|
+
.raw(messageType.toBinary(message, options))
|
|
312
|
+
.tag(field.no, binary_encoding_js_1.WireType.EndGroup);
|
|
311
313
|
else
|
|
312
314
|
writer
|
|
313
|
-
.tag(field.no,
|
|
314
|
-
.bytes(
|
|
315
|
+
.tag(field.no, binary_encoding_js_1.WireType.LengthDelimited)
|
|
316
|
+
.bytes(messageType.toBinary(message, options));
|
|
315
317
|
}
|
|
316
318
|
function writeScalar(writer, type, fieldNo, value) {
|
|
317
319
|
(0, assert_js_1.assert)(value !== undefined);
|
|
@@ -322,7 +324,7 @@ function writePacked(writer, type, fieldNo, value) {
|
|
|
322
324
|
if (!value.length) {
|
|
323
325
|
return;
|
|
324
326
|
}
|
|
325
|
-
writer.tag(fieldNo,
|
|
327
|
+
writer.tag(fieldNo, binary_encoding_js_1.WireType.LengthDelimited).fork();
|
|
326
328
|
let [, method] = scalarTypeInfo(type);
|
|
327
329
|
for (let i = 0; i < value.length; i++) {
|
|
328
330
|
writer[method](value[i]);
|
|
@@ -341,43 +343,43 @@ function writePacked(writer, type, fieldNo, value) {
|
|
|
341
343
|
*/
|
|
342
344
|
// TODO replace call-sites writeScalar() and writePacked(), then remove
|
|
343
345
|
function scalarTypeInfo(type) {
|
|
344
|
-
let wireType =
|
|
346
|
+
let wireType = binary_encoding_js_1.WireType.Varint;
|
|
345
347
|
// eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check -- INT32, UINT32, SINT32 are covered by the defaults
|
|
346
348
|
switch (type) {
|
|
347
|
-
case
|
|
348
|
-
case
|
|
349
|
-
wireType =
|
|
349
|
+
case scalar_js_1.ScalarType.BYTES:
|
|
350
|
+
case scalar_js_1.ScalarType.STRING:
|
|
351
|
+
wireType = binary_encoding_js_1.WireType.LengthDelimited;
|
|
350
352
|
break;
|
|
351
|
-
case
|
|
352
|
-
case
|
|
353
|
-
case
|
|
354
|
-
wireType =
|
|
353
|
+
case scalar_js_1.ScalarType.DOUBLE:
|
|
354
|
+
case scalar_js_1.ScalarType.FIXED64:
|
|
355
|
+
case scalar_js_1.ScalarType.SFIXED64:
|
|
356
|
+
wireType = binary_encoding_js_1.WireType.Bit64;
|
|
355
357
|
break;
|
|
356
|
-
case
|
|
357
|
-
case
|
|
358
|
-
case
|
|
359
|
-
wireType =
|
|
358
|
+
case scalar_js_1.ScalarType.FIXED32:
|
|
359
|
+
case scalar_js_1.ScalarType.SFIXED32:
|
|
360
|
+
case scalar_js_1.ScalarType.FLOAT:
|
|
361
|
+
wireType = binary_encoding_js_1.WireType.Bit32;
|
|
360
362
|
break;
|
|
361
363
|
}
|
|
362
|
-
const method =
|
|
364
|
+
const method = scalar_js_1.ScalarType[type].toLowerCase();
|
|
363
365
|
return [wireType, method];
|
|
364
366
|
}
|
|
365
367
|
function writeMapEntry(writer, options, field, key, value) {
|
|
366
|
-
writer.tag(field.no,
|
|
368
|
+
writer.tag(field.no, binary_encoding_js_1.WireType.LengthDelimited);
|
|
367
369
|
writer.fork();
|
|
368
370
|
// javascript only allows number or string for object properties
|
|
369
371
|
// we convert from our representation to the protobuf type
|
|
370
372
|
let keyValue = key;
|
|
371
373
|
// eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check -- we deliberately handle just the special cases for map keys
|
|
372
374
|
switch (field.K) {
|
|
373
|
-
case
|
|
374
|
-
case
|
|
375
|
-
case
|
|
376
|
-
case
|
|
377
|
-
case
|
|
375
|
+
case scalar_js_1.ScalarType.INT32:
|
|
376
|
+
case scalar_js_1.ScalarType.FIXED32:
|
|
377
|
+
case scalar_js_1.ScalarType.UINT32:
|
|
378
|
+
case scalar_js_1.ScalarType.SFIXED32:
|
|
379
|
+
case scalar_js_1.ScalarType.SINT32:
|
|
378
380
|
keyValue = Number.parseInt(key);
|
|
379
381
|
break;
|
|
380
|
-
case
|
|
382
|
+
case scalar_js_1.ScalarType.BOOL:
|
|
381
383
|
(0, assert_js_1.assert)(key == "true" || key == "false");
|
|
382
384
|
keyValue = key == "true";
|
|
383
385
|
break;
|
|
@@ -390,13 +392,14 @@ function writeMapEntry(writer, options, field, key, value) {
|
|
|
390
392
|
writeScalar(writer, field.V.T, 2, value);
|
|
391
393
|
break;
|
|
392
394
|
case "enum":
|
|
393
|
-
writeScalar(writer,
|
|
395
|
+
writeScalar(writer, scalar_js_1.ScalarType.INT32, 2, value);
|
|
394
396
|
break;
|
|
395
397
|
case "message":
|
|
396
398
|
(0, assert_js_1.assert)(value !== undefined);
|
|
399
|
+
const messageType = (0, field_js_1.resolveMessageType)(field.V.T);
|
|
397
400
|
writer
|
|
398
|
-
.tag(2,
|
|
399
|
-
.bytes(
|
|
401
|
+
.tag(2, binary_encoding_js_1.WireType.LengthDelimited)
|
|
402
|
+
.bytes(messageType.toBinary(value, options));
|
|
400
403
|
break;
|
|
401
404
|
}
|
|
402
405
|
writer.join();
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { localName } from "./names.js";
|
|
2
|
+
import { getUnwrappedFieldType } from "./field-wrapper.js";
|
|
3
|
+
import { scalarZeroValue } from "./scalar.js";
|
|
4
|
+
type RuntimeSymbolInfo = {
|
|
5
|
+
typeOnly: boolean;
|
|
6
|
+
publicImportPath: string;
|
|
7
|
+
privateImportPath: string;
|
|
8
|
+
};
|
|
9
|
+
export declare const packageName = "@aptre/protobuf-es-lite";
|
|
10
|
+
export declare const codegenInfo: {
|
|
11
|
+
readonly packageName: "@aptre/protobuf-es-lite";
|
|
12
|
+
readonly localName: typeof localName;
|
|
13
|
+
readonly getUnwrappedFieldType: typeof getUnwrappedFieldType;
|
|
14
|
+
readonly scalarZeroValue: typeof scalarZeroValue;
|
|
15
|
+
readonly safeIdentifier: (name: string) => string;
|
|
16
|
+
readonly safeObjectProperty: (name: string) => string;
|
|
17
|
+
readonly symbols: {
|
|
18
|
+
readonly Message: RuntimeSymbolInfo;
|
|
19
|
+
readonly FieldList: RuntimeSymbolInfo;
|
|
20
|
+
readonly PartialFieldInfo: RuntimeSymbolInfo;
|
|
21
|
+
readonly MessageType: RuntimeSymbolInfo;
|
|
22
|
+
readonly Extension: RuntimeSymbolInfo;
|
|
23
|
+
readonly BinaryReadOptions: RuntimeSymbolInfo;
|
|
24
|
+
readonly BinaryWriteOptions: RuntimeSymbolInfo;
|
|
25
|
+
readonly JsonReadOptions: RuntimeSymbolInfo;
|
|
26
|
+
readonly JsonWriteOptions: RuntimeSymbolInfo;
|
|
27
|
+
readonly JsonValue: RuntimeSymbolInfo;
|
|
28
|
+
readonly JsonObject: RuntimeSymbolInfo;
|
|
29
|
+
readonly protoDouble: RuntimeSymbolInfo;
|
|
30
|
+
readonly protoInt64: RuntimeSymbolInfo;
|
|
31
|
+
readonly ScalarType: RuntimeSymbolInfo;
|
|
32
|
+
readonly LongType: RuntimeSymbolInfo;
|
|
33
|
+
readonly MethodKind: RuntimeSymbolInfo;
|
|
34
|
+
readonly MethodIdempotency: RuntimeSymbolInfo;
|
|
35
|
+
readonly IMessageTypeRegistry: RuntimeSymbolInfo;
|
|
36
|
+
readonly createEnumType: RuntimeSymbolInfo;
|
|
37
|
+
readonly createMessageType: RuntimeSymbolInfo;
|
|
38
|
+
};
|
|
39
|
+
readonly wktSourceFiles: readonly string[];
|
|
40
|
+
};
|
|
41
|
+
export type RuntimeSymbolName = keyof typeof codegenInfo.symbols;
|
|
42
|
+
export type CodegenInfo = typeof codegenInfo;
|
|
43
|
+
export {};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright 2024 Aperture Robotics, LLC.
|
|
3
|
+
// Copyright 2021-2024 Buf Technologies, Inc.
|
|
4
|
+
//
|
|
5
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
// you may not use this file except in compliance with the License.
|
|
7
|
+
// You may obtain a copy of the License at
|
|
8
|
+
//
|
|
9
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
//
|
|
11
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
// See the License for the specific language governing permissions and
|
|
15
|
+
// limitations under the License.
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.codegenInfo = exports.packageName = void 0;
|
|
18
|
+
const names_js_1 = require("./names.js");
|
|
19
|
+
const field_wrapper_js_1 = require("./field-wrapper.js");
|
|
20
|
+
const scalar_js_1 = require("./scalar.js");
|
|
21
|
+
exports.packageName = "@aptre/protobuf-es-lite";
|
|
22
|
+
const symbolInfo = (typeOnly, privateImportPath) => ({
|
|
23
|
+
typeOnly,
|
|
24
|
+
privateImportPath,
|
|
25
|
+
publicImportPath: exports.packageName,
|
|
26
|
+
});
|
|
27
|
+
const symbols = {
|
|
28
|
+
Message: symbolInfo(false, "./message.js"),
|
|
29
|
+
FieldList: symbolInfo(true, "./field-list.js"),
|
|
30
|
+
PartialFieldInfo: symbolInfo(true, "./field.js"),
|
|
31
|
+
MessageType: symbolInfo(true, "./message-type.js"),
|
|
32
|
+
Extension: symbolInfo(true, "./extension.js"),
|
|
33
|
+
BinaryReadOptions: symbolInfo(true, "./binary-format.js"),
|
|
34
|
+
BinaryWriteOptions: symbolInfo(true, "./binary-format.js"),
|
|
35
|
+
JsonReadOptions: symbolInfo(true, "./json-format.js"),
|
|
36
|
+
JsonWriteOptions: symbolInfo(true, "./json-format.js"),
|
|
37
|
+
JsonValue: symbolInfo(true, "./json-format.js"),
|
|
38
|
+
JsonObject: symbolInfo(true, "./json-format.js"),
|
|
39
|
+
protoDouble: symbolInfo(false, "./proto-double.js"),
|
|
40
|
+
protoInt64: symbolInfo(false, "./proto-int64.js"),
|
|
41
|
+
ScalarType: symbolInfo(false, "./scalar.js"),
|
|
42
|
+
LongType: symbolInfo(false, "./scalar.js"),
|
|
43
|
+
MethodKind: symbolInfo(false, "./service-type.js"),
|
|
44
|
+
MethodIdempotency: symbolInfo(false, "./service-type.js"),
|
|
45
|
+
IMessageTypeRegistry: symbolInfo(true, "./type-registry.js"),
|
|
46
|
+
createEnumType: symbolInfo(false, "./enum.js"),
|
|
47
|
+
createMessageType: symbolInfo(false, "./message.js"),
|
|
48
|
+
};
|
|
49
|
+
// prettier-ignore
|
|
50
|
+
exports.codegenInfo = {
|
|
51
|
+
packageName: exports.packageName,
|
|
52
|
+
localName: names_js_1.localName,
|
|
53
|
+
getUnwrappedFieldType: field_wrapper_js_1.getUnwrappedFieldType,
|
|
54
|
+
scalarZeroValue: scalar_js_1.scalarZeroValue,
|
|
55
|
+
safeIdentifier: names_js_1.safeIdentifier,
|
|
56
|
+
safeObjectProperty: names_js_1.safeObjectProperty,
|
|
57
|
+
symbols,
|
|
58
|
+
wktSourceFiles: [
|
|
59
|
+
"google/protobuf/compiler/plugin.proto",
|
|
60
|
+
"google/protobuf/any.proto",
|
|
61
|
+
"google/protobuf/api.proto",
|
|
62
|
+
"google/protobuf/descriptor.proto",
|
|
63
|
+
"google/protobuf/duration.proto",
|
|
64
|
+
"google/protobuf/empty.proto",
|
|
65
|
+
"google/protobuf/field_mask.proto",
|
|
66
|
+
"google/protobuf/source_context.proto",
|
|
67
|
+
"google/protobuf/struct.proto",
|
|
68
|
+
"google/protobuf/timestamp.proto",
|
|
69
|
+
"google/protobuf/type.proto",
|
|
70
|
+
"google/protobuf/wrappers.proto",
|
|
71
|
+
],
|
|
72
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { BinaryReadOptions, BinaryWriteOptions } from "./binary.js";
|
|
2
|
+
import { DescriptorSet } from "./descriptor-set.js";
|
|
3
|
+
import { FeatureSetDefaults, FileDescriptorProto, FileDescriptorSet } from "./google/protobuf/descriptor.pb.js";
|
|
4
|
+
/**
|
|
5
|
+
* Create a DescriptorSet, a convenient interface for working with a set of
|
|
6
|
+
* google.protobuf.FileDescriptorProto.
|
|
7
|
+
*
|
|
8
|
+
* Note that files must be given in topological order, so each file appears
|
|
9
|
+
* before any file that imports it. Protocol buffer compilers always produce
|
|
10
|
+
* files in topological order.
|
|
11
|
+
*/
|
|
12
|
+
export declare function createDescriptorSet(input: FileDescriptorProto[] | FileDescriptorSet | Uint8Array, options?: CreateDescriptorSetOptions): DescriptorSet;
|
|
13
|
+
/**
|
|
14
|
+
* Options to createDescriptorSet()
|
|
15
|
+
*/
|
|
16
|
+
interface CreateDescriptorSetOptions {
|
|
17
|
+
/**
|
|
18
|
+
* Editions support language-specific features with extensions to
|
|
19
|
+
* google.protobuf.FeatureSet. They can define defaults, and specify on
|
|
20
|
+
* which targets the features can be set.
|
|
21
|
+
*
|
|
22
|
+
* To create a DescriptorSet that provides your language-specific features,
|
|
23
|
+
* you have to provide a google.protobuf.FeatureSetDefaults message in this
|
|
24
|
+
* option. It can also specify the minimum and maximum supported edition.
|
|
25
|
+
*
|
|
26
|
+
* The defaults can be generated with `protoc` - see the flag
|
|
27
|
+
* `--experimental_edition_defaults_out`.
|
|
28
|
+
*/
|
|
29
|
+
featureSetDefaults?: FeatureSetDefaults;
|
|
30
|
+
/**
|
|
31
|
+
* Internally, data is serialized when features are resolved. The
|
|
32
|
+
* serialization options given here will be used for feature resolution.
|
|
33
|
+
*/
|
|
34
|
+
serializationOptions?: Partial<BinaryReadOptions & BinaryWriteOptions>;
|
|
35
|
+
}
|
|
36
|
+
export {};
|