@aptre/protobuf-es-lite 0.2.7 → 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 +23 -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 +64 -65
- 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 +74 -3
- package/dist/json.d.ts +68 -1
- package/dist/json.js +57 -81
- package/dist/message.d.ts +30 -61
- package/dist/message.js +61 -20
- package/dist/names.d.ts +43 -0
- package/dist/names.js +276 -0
- package/dist/partial.js +14 -15
- 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} +46 -34
- 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,7 +106,7 @@ function readMapEntry(field, reader, options) {
|
|
|
105
106
|
val = reader.int32();
|
|
106
107
|
break;
|
|
107
108
|
case "message":
|
|
108
|
-
const messageType =
|
|
109
|
+
const messageType = (0, field_js_1.resolveMessageType)(field.V.T);
|
|
109
110
|
val = readMessageField(reader, messageType.create(), messageType.fields, options, undefined);
|
|
110
111
|
break;
|
|
111
112
|
}
|
|
@@ -113,22 +114,22 @@ function readMapEntry(field, reader, options) {
|
|
|
113
114
|
}
|
|
114
115
|
}
|
|
115
116
|
if (key === undefined) {
|
|
116
|
-
key = (0, scalar_js_1.scalarZeroValue)(field.K,
|
|
117
|
+
key = (0, scalar_js_1.scalarZeroValue)(field.K, scalar_js_1.LongType.BIGINT);
|
|
117
118
|
}
|
|
118
119
|
if (typeof key != "string" && typeof key != "number") {
|
|
119
120
|
key = key.toString();
|
|
120
121
|
}
|
|
121
122
|
if (val === undefined) {
|
|
122
|
-
|
|
123
|
+
const fieldKind = field.V.kind;
|
|
124
|
+
switch (fieldKind) {
|
|
123
125
|
case "scalar":
|
|
124
|
-
val = (0, scalar_js_1.scalarZeroValue)(field.V.T,
|
|
126
|
+
val = (0, scalar_js_1.scalarZeroValue)(field.V.T, scalar_js_1.LongType.BIGINT);
|
|
125
127
|
break;
|
|
126
128
|
case "enum":
|
|
127
129
|
val = field.V.T.values[0].no;
|
|
128
130
|
break;
|
|
129
131
|
case "message":
|
|
130
|
-
|
|
131
|
-
val = messageType.create();
|
|
132
|
+
val = (0, field_js_1.resolveMessageType)(field.V.T).create();
|
|
132
133
|
break;
|
|
133
134
|
}
|
|
134
135
|
}
|
|
@@ -137,35 +138,35 @@ function readMapEntry(field, reader, options) {
|
|
|
137
138
|
exports.readMapEntry = readMapEntry;
|
|
138
139
|
function readScalar(reader, type) {
|
|
139
140
|
switch (type) {
|
|
140
|
-
case
|
|
141
|
+
case scalar_js_1.ScalarType.STRING:
|
|
141
142
|
return reader.string();
|
|
142
|
-
case
|
|
143
|
+
case scalar_js_1.ScalarType.BOOL:
|
|
143
144
|
return reader.bool();
|
|
144
|
-
case
|
|
145
|
+
case scalar_js_1.ScalarType.DOUBLE:
|
|
145
146
|
return reader.double();
|
|
146
|
-
case
|
|
147
|
+
case scalar_js_1.ScalarType.FLOAT:
|
|
147
148
|
return reader.float();
|
|
148
|
-
case
|
|
149
|
+
case scalar_js_1.ScalarType.INT32:
|
|
149
150
|
return reader.int32();
|
|
150
|
-
case
|
|
151
|
+
case scalar_js_1.ScalarType.INT64:
|
|
151
152
|
return reader.int64();
|
|
152
|
-
case
|
|
153
|
+
case scalar_js_1.ScalarType.UINT64:
|
|
153
154
|
return reader.uint64();
|
|
154
|
-
case
|
|
155
|
+
case scalar_js_1.ScalarType.FIXED64:
|
|
155
156
|
return reader.fixed64();
|
|
156
|
-
case
|
|
157
|
+
case scalar_js_1.ScalarType.BYTES:
|
|
157
158
|
return reader.bytes();
|
|
158
|
-
case
|
|
159
|
+
case scalar_js_1.ScalarType.FIXED32:
|
|
159
160
|
return reader.fixed32();
|
|
160
|
-
case
|
|
161
|
+
case scalar_js_1.ScalarType.SFIXED32:
|
|
161
162
|
return reader.sfixed32();
|
|
162
|
-
case
|
|
163
|
+
case scalar_js_1.ScalarType.SFIXED64:
|
|
163
164
|
return reader.sfixed64();
|
|
164
|
-
case
|
|
165
|
+
case scalar_js_1.ScalarType.SINT64:
|
|
165
166
|
return reader.sint64();
|
|
166
|
-
case
|
|
167
|
+
case scalar_js_1.ScalarType.UINT32:
|
|
167
168
|
return reader.uint32();
|
|
168
|
-
case
|
|
169
|
+
case scalar_js_1.ScalarType.SINT32:
|
|
169
170
|
return reader.sint32();
|
|
170
171
|
}
|
|
171
172
|
}
|
|
@@ -188,12 +189,12 @@ function readMessageField(reader, message, fields, options, field) {
|
|
|
188
189
|
// Default options for parsing binary data.
|
|
189
190
|
const readDefaults = {
|
|
190
191
|
readUnknownFields: true,
|
|
191
|
-
readerFactory: (bytes) => new
|
|
192
|
+
readerFactory: (bytes) => new binary_encoding_js_1.BinaryReader(bytes),
|
|
192
193
|
};
|
|
193
194
|
// Default options for serializing binary data.
|
|
194
195
|
const writeDefaults = {
|
|
195
196
|
writeUnknownFields: true,
|
|
196
|
-
writerFactory: () => new
|
|
197
|
+
writerFactory: () => new binary_encoding_js_1.BinaryWriter(),
|
|
197
198
|
};
|
|
198
199
|
function makeReadOptions(options) {
|
|
199
200
|
return options ? { ...readDefaults, ...options } : readDefaults;
|
|
@@ -205,13 +206,11 @@ function makeWriteOptions(options) {
|
|
|
205
206
|
exports.makeWriteOptions = makeWriteOptions;
|
|
206
207
|
function readMessage(message, fields, reader, lengthOrEndTagFieldNo, options, delimitedMessageEncoding) {
|
|
207
208
|
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
|
208
|
-
const end = delimitedMessageEncoding
|
|
209
|
-
? reader.len
|
|
210
|
-
: reader.pos + lengthOrEndTagFieldNo;
|
|
209
|
+
const end = delimitedMessageEncoding ? reader.len : reader.pos + lengthOrEndTagFieldNo;
|
|
211
210
|
let fieldNo, wireType;
|
|
212
211
|
while (reader.pos < end) {
|
|
213
212
|
[fieldNo, wireType] = reader.tag();
|
|
214
|
-
if (wireType ==
|
|
213
|
+
if (wireType == binary_encoding_js_1.WireType.EndGroup) {
|
|
215
214
|
break;
|
|
216
215
|
}
|
|
217
216
|
const field = fields.find(fieldNo);
|
|
@@ -225,7 +224,7 @@ function readMessage(message, fields, reader, lengthOrEndTagFieldNo, options, de
|
|
|
225
224
|
readField(message, reader, field, wireType, options);
|
|
226
225
|
}
|
|
227
226
|
if (delimitedMessageEncoding && // eslint-disable-line @typescript-eslint/strict-boolean-expressions
|
|
228
|
-
(wireType !=
|
|
227
|
+
(wireType != binary_encoding_js_1.WireType.EndGroup || fieldNo !== lengthOrEndTagFieldNo)) {
|
|
229
228
|
throw new Error(`invalid end group tag`);
|
|
230
229
|
}
|
|
231
230
|
}
|
|
@@ -241,8 +240,8 @@ function writeMessage(message, fields, writer, options) {
|
|
|
241
240
|
}
|
|
242
241
|
continue;
|
|
243
242
|
}
|
|
244
|
-
const value = field.oneof
|
|
245
|
-
|
|
243
|
+
const value = field.oneof ?
|
|
244
|
+
message[field.oneof.localName].value
|
|
246
245
|
: message[field.localName];
|
|
247
246
|
writeField(field, value, writer, options);
|
|
248
247
|
}
|
|
@@ -257,7 +256,7 @@ function writeField(field, value, writer, options) {
|
|
|
257
256
|
switch (field.kind) {
|
|
258
257
|
case "scalar":
|
|
259
258
|
case "enum":
|
|
260
|
-
let scalarType = field.kind == "enum" ?
|
|
259
|
+
let scalarType = field.kind == "enum" ? scalar_js_1.ScalarType.INT32 : field.T;
|
|
261
260
|
if (repeated) {
|
|
262
261
|
(0, assert_js_1.assert)(Array.isArray(value));
|
|
263
262
|
if (field.packed) {
|
|
@@ -303,17 +302,17 @@ function writeUnknownFields(message, writer) {
|
|
|
303
302
|
}
|
|
304
303
|
// Value must not be undefined
|
|
305
304
|
function writeMessageField(writer, options, field, value) {
|
|
306
|
-
const messageType =
|
|
305
|
+
const messageType = (0, field_js_1.resolveMessageType)(field.T);
|
|
307
306
|
const message = (0, field_wrapper_js_1.wrapField)(messageType.fieldWrapper, value);
|
|
308
307
|
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
|
309
308
|
if (field.delimited)
|
|
310
309
|
writer
|
|
311
|
-
.tag(field.no,
|
|
310
|
+
.tag(field.no, binary_encoding_js_1.WireType.StartGroup)
|
|
312
311
|
.raw(messageType.toBinary(message, options))
|
|
313
|
-
.tag(field.no,
|
|
312
|
+
.tag(field.no, binary_encoding_js_1.WireType.EndGroup);
|
|
314
313
|
else
|
|
315
314
|
writer
|
|
316
|
-
.tag(field.no,
|
|
315
|
+
.tag(field.no, binary_encoding_js_1.WireType.LengthDelimited)
|
|
317
316
|
.bytes(messageType.toBinary(message, options));
|
|
318
317
|
}
|
|
319
318
|
function writeScalar(writer, type, fieldNo, value) {
|
|
@@ -325,7 +324,7 @@ function writePacked(writer, type, fieldNo, value) {
|
|
|
325
324
|
if (!value.length) {
|
|
326
325
|
return;
|
|
327
326
|
}
|
|
328
|
-
writer.tag(fieldNo,
|
|
327
|
+
writer.tag(fieldNo, binary_encoding_js_1.WireType.LengthDelimited).fork();
|
|
329
328
|
let [, method] = scalarTypeInfo(type);
|
|
330
329
|
for (let i = 0; i < value.length; i++) {
|
|
331
330
|
writer[method](value[i]);
|
|
@@ -344,43 +343,43 @@ function writePacked(writer, type, fieldNo, value) {
|
|
|
344
343
|
*/
|
|
345
344
|
// TODO replace call-sites writeScalar() and writePacked(), then remove
|
|
346
345
|
function scalarTypeInfo(type) {
|
|
347
|
-
let wireType =
|
|
346
|
+
let wireType = binary_encoding_js_1.WireType.Varint;
|
|
348
347
|
// eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check -- INT32, UINT32, SINT32 are covered by the defaults
|
|
349
348
|
switch (type) {
|
|
350
|
-
case
|
|
351
|
-
case
|
|
352
|
-
wireType =
|
|
349
|
+
case scalar_js_1.ScalarType.BYTES:
|
|
350
|
+
case scalar_js_1.ScalarType.STRING:
|
|
351
|
+
wireType = binary_encoding_js_1.WireType.LengthDelimited;
|
|
353
352
|
break;
|
|
354
|
-
case
|
|
355
|
-
case
|
|
356
|
-
case
|
|
357
|
-
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;
|
|
358
357
|
break;
|
|
359
|
-
case
|
|
360
|
-
case
|
|
361
|
-
case
|
|
362
|
-
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;
|
|
363
362
|
break;
|
|
364
363
|
}
|
|
365
|
-
const method =
|
|
364
|
+
const method = scalar_js_1.ScalarType[type].toLowerCase();
|
|
366
365
|
return [wireType, method];
|
|
367
366
|
}
|
|
368
367
|
function writeMapEntry(writer, options, field, key, value) {
|
|
369
|
-
writer.tag(field.no,
|
|
368
|
+
writer.tag(field.no, binary_encoding_js_1.WireType.LengthDelimited);
|
|
370
369
|
writer.fork();
|
|
371
370
|
// javascript only allows number or string for object properties
|
|
372
371
|
// we convert from our representation to the protobuf type
|
|
373
372
|
let keyValue = key;
|
|
374
373
|
// eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check -- we deliberately handle just the special cases for map keys
|
|
375
374
|
switch (field.K) {
|
|
376
|
-
case
|
|
377
|
-
case
|
|
378
|
-
case
|
|
379
|
-
case
|
|
380
|
-
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:
|
|
381
380
|
keyValue = Number.parseInt(key);
|
|
382
381
|
break;
|
|
383
|
-
case
|
|
382
|
+
case scalar_js_1.ScalarType.BOOL:
|
|
384
383
|
(0, assert_js_1.assert)(key == "true" || key == "false");
|
|
385
384
|
keyValue = key == "true";
|
|
386
385
|
break;
|
|
@@ -393,13 +392,13 @@ function writeMapEntry(writer, options, field, key, value) {
|
|
|
393
392
|
writeScalar(writer, field.V.T, 2, value);
|
|
394
393
|
break;
|
|
395
394
|
case "enum":
|
|
396
|
-
writeScalar(writer,
|
|
395
|
+
writeScalar(writer, scalar_js_1.ScalarType.INT32, 2, value);
|
|
397
396
|
break;
|
|
398
397
|
case "message":
|
|
399
398
|
(0, assert_js_1.assert)(value !== undefined);
|
|
400
|
-
const messageType =
|
|
399
|
+
const messageType = (0, field_js_1.resolveMessageType)(field.V.T);
|
|
401
400
|
writer
|
|
402
|
-
.tag(2,
|
|
401
|
+
.tag(2, binary_encoding_js_1.WireType.LengthDelimited)
|
|
403
402
|
.bytes(messageType.toBinary(value, options));
|
|
404
403
|
break;
|
|
405
404
|
}
|
|
@@ -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 {};
|