@bufbuild/protobuf 0.0.6 → 0.0.9
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 +34 -4
- package/dist/cjs/binary-encoding.js +2 -2
- package/dist/cjs/codegen-info.js +60 -0
- package/dist/cjs/create-descriptor-set.js +952 -0
- package/dist/cjs/create-registry-from-desc.js +376 -0
- package/dist/cjs/create-registry.js +75 -0
- package/dist/cjs/descriptor-set.js +0 -458
- package/dist/cjs/google/protobuf/any_pb.js +4 -2
- package/dist/cjs/google/protobuf/duration_pb.js +1 -1
- package/dist/cjs/google/protobuf/struct_pb.js +2 -2
- package/dist/cjs/google/protobuf/type_pb.js +1 -1
- package/dist/cjs/index.js +17 -7
- package/dist/cjs/{descriptor-registry.js → legacy-descriptor-registry.js} +35 -69
- package/dist/cjs/legacy-descriptor-set.js +453 -0
- package/dist/cjs/legacy-type-registry.js +104 -0
- package/dist/cjs/message.js +2 -1
- package/dist/cjs/private/binary-format-common.js +4 -3
- package/dist/cjs/private/binary-format-proto2.js +3 -6
- package/dist/cjs/private/binary-format-proto3.js +2 -5
- package/dist/cjs/private/enum.js +22 -31
- package/dist/cjs/private/field-wrapper.js +30 -1
- package/dist/cjs/private/field.js +1 -1
- package/dist/cjs/private/json-format-common.js +6 -5
- package/dist/cjs/private/message-type.js +2 -1
- package/dist/cjs/private/names.js +168 -29
- package/dist/cjs/proto-int64.js +1 -1
- package/dist/cjs/proto2.js +7 -9
- package/dist/cjs/proto3.js +10 -13
- package/dist/cjs/type-registry.js +0 -87
- package/dist/esm/binary-encoding.js +2 -2
- package/dist/esm/codegen-info.js +57 -0
- package/dist/esm/create-descriptor-set.js +947 -0
- package/dist/esm/create-registry-from-desc.js +371 -0
- package/dist/esm/create-registry.js +71 -0
- package/dist/esm/descriptor-set.js +1 -456
- package/dist/esm/google/protobuf/any_pb.js +4 -2
- package/dist/esm/google/protobuf/duration_pb.js +1 -1
- package/dist/esm/google/protobuf/struct_pb.js +2 -2
- package/dist/esm/google/protobuf/type_pb.js +1 -1
- package/dist/esm/index.js +9 -3
- package/dist/esm/{descriptor-registry.js → legacy-descriptor-registry.js} +33 -67
- package/dist/esm/legacy-descriptor-set.js +449 -0
- package/dist/esm/legacy-type-registry.js +100 -0
- package/dist/esm/message.js +2 -1
- package/dist/esm/private/binary-format-common.js +4 -3
- package/dist/esm/private/binary-format-proto2.js +3 -6
- package/dist/esm/private/binary-format-proto3.js +2 -5
- package/dist/esm/private/enum.js +22 -31
- package/dist/esm/private/field-wrapper.js +28 -0
- package/dist/esm/private/field.js +2 -2
- package/dist/esm/private/json-format-common.js +6 -5
- package/dist/esm/private/message-type.js +2 -1
- package/dist/esm/private/names.js +163 -24
- package/dist/esm/proto-int64.js +1 -1
- package/dist/esm/proto2.js +8 -10
- package/dist/esm/proto3.js +11 -14
- package/dist/esm/type-registry.js +1 -85
- package/dist/types/codegen-info.d.ts +19 -0
- package/dist/types/create-descriptor-set.d.ts +16 -0
- package/dist/types/create-registry-from-desc.d.ts +49 -0
- package/dist/types/create-registry.d.ts +8 -0
- package/dist/types/descriptor-set.d.ts +554 -108
- package/dist/types/enum.d.ts +9 -5
- package/dist/types/index.d.ts +9 -3
- package/dist/types/{descriptor-registry.d.ts → legacy-descriptor-registry.d.ts} +8 -6
- package/dist/types/legacy-descriptor-set.d.ts +152 -0
- package/dist/types/legacy-type-registry.d.ts +44 -0
- package/dist/types/private/enum.d.ts +4 -8
- package/dist/types/private/field-wrapper.d.ts +7 -0
- package/dist/types/private/message-type.d.ts +1 -4
- package/dist/types/private/names.d.ts +26 -8
- package/dist/types/private/proto-runtime.d.ts +2 -2
- package/dist/types/private/util.d.ts +1 -6
- package/dist/types/type-registry.d.ts +0 -38
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -1,9 +1,39 @@
|
|
|
1
1
|
# @bufbuild/protobuf
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
This package provides the runtime library for the code generator plugin
|
|
4
|
+
[`protoc-gen-es`](https://github.com/bufbuild/packages/protoc-gen-es).
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
## Protocol Buffers for ECMAScript
|
|
7
|
+
|
|
8
|
+
A complete implementation of [Protocol Buffers](https://developers.google.com/protocol-buffers)
|
|
9
|
+
in TypeScript, suitable for web browsers and Node.js.
|
|
7
10
|
Learn more at [github.com/bufbuild/protobuf-es](https://github.com/bufbuild/protobuf-es).
|
|
8
11
|
|
|
9
|
-
|
|
12
|
+
|
|
13
|
+
It is a complete implementation of [Protocol Buffers](https://developers.google.com/protocol-buffers)
|
|
14
|
+
in TypeScript, suitable for web browsers and Node.js.
|
|
15
|
+
|
|
16
|
+
For example, the following definition:
|
|
17
|
+
|
|
18
|
+
```protobuf
|
|
19
|
+
message Person {
|
|
20
|
+
string name = 1;
|
|
21
|
+
int32 id = 2; // Unique ID number for this person.
|
|
22
|
+
string email = 3;
|
|
23
|
+
}
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Is compiled to an ECMAScript class that can be used like this:
|
|
27
|
+
|
|
28
|
+
```typescript
|
|
29
|
+
let pete = new Person({
|
|
30
|
+
name: "pete",
|
|
31
|
+
id: 123
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
let bytes = pete.toBinary();
|
|
35
|
+
pete = Person.fromBinary(bytes);
|
|
36
|
+
pete = Person.fromJsonString('{"name": "pete", "id": 123}');
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Learn more at [github.com/bufbuild/protobuf-es](https://github.com/bufbuild/protobuf-es).
|
|
@@ -67,7 +67,7 @@ class BinaryWriter {
|
|
|
67
67
|
* Previous fork states.
|
|
68
68
|
*/
|
|
69
69
|
this.stack = [];
|
|
70
|
-
this.textEncoder = textEncoder
|
|
70
|
+
this.textEncoder = textEncoder !== null && textEncoder !== void 0 ? textEncoder : new TextEncoder();
|
|
71
71
|
this.chunks = [];
|
|
72
72
|
this.buf = [];
|
|
73
73
|
}
|
|
@@ -283,7 +283,7 @@ class BinaryReader {
|
|
|
283
283
|
this.len = buf.length;
|
|
284
284
|
this.pos = 0;
|
|
285
285
|
this.view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
286
|
-
this.textDecoder = textDecoder
|
|
286
|
+
this.textDecoder = textDecoder !== null && textDecoder !== void 0 ? textDecoder : new TextDecoder();
|
|
287
287
|
}
|
|
288
288
|
/**
|
|
289
289
|
* Reads a tag - field number and wire type.
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright 2021-2022 Buf Technologies, Inc.
|
|
3
|
+
//
|
|
4
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
// you may not use this file except in compliance with the License.
|
|
6
|
+
// You may obtain a copy of the License at
|
|
7
|
+
//
|
|
8
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
//
|
|
10
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
// See the License for the specific language governing permissions and
|
|
14
|
+
// limitations under the License.
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.codegenInfo = void 0;
|
|
17
|
+
const names_js_1 = require("./private/names.js");
|
|
18
|
+
const field_wrapper_js_1 = require("./private/field-wrapper.js");
|
|
19
|
+
const scalars_js_1 = require("./private/scalars.js");
|
|
20
|
+
const packageName = "@bufbuild/protobuf";
|
|
21
|
+
exports.codegenInfo = {
|
|
22
|
+
packageName,
|
|
23
|
+
localName: names_js_1.localName,
|
|
24
|
+
getUnwrappedFieldType: field_wrapper_js_1.getUnwrappedFieldType,
|
|
25
|
+
scalarDefaultValue: scalars_js_1.scalarDefaultValue,
|
|
26
|
+
// prettier-ignore
|
|
27
|
+
symbols: {
|
|
28
|
+
proto2: { typeOnly: false, privateImportPath: "./proto2.js", publicImportPath: packageName },
|
|
29
|
+
proto3: { typeOnly: false, privateImportPath: "./proto3.js", publicImportPath: packageName },
|
|
30
|
+
Message: { typeOnly: false, privateImportPath: "./message.js", publicImportPath: packageName },
|
|
31
|
+
PartialMessage: { typeOnly: true, privateImportPath: "./message.js", publicImportPath: packageName },
|
|
32
|
+
PlainMessage: { typeOnly: true, privateImportPath: "./message.js", publicImportPath: packageName },
|
|
33
|
+
FieldList: { typeOnly: true, privateImportPath: "./field-list.js", publicImportPath: packageName },
|
|
34
|
+
MessageType: { typeOnly: true, privateImportPath: "./message-type.js", publicImportPath: packageName },
|
|
35
|
+
BinaryReadOptions: { typeOnly: true, privateImportPath: "./binary-format.js", publicImportPath: packageName },
|
|
36
|
+
BinaryWriteOptions: { typeOnly: true, privateImportPath: "./binary-format.js", publicImportPath: packageName },
|
|
37
|
+
JsonReadOptions: { typeOnly: true, privateImportPath: "./json-format.js", publicImportPath: packageName },
|
|
38
|
+
JsonWriteOptions: { typeOnly: true, privateImportPath: "./json-format.js", publicImportPath: packageName },
|
|
39
|
+
JsonValue: { typeOnly: true, privateImportPath: "./json-format.js", publicImportPath: packageName },
|
|
40
|
+
JsonObject: { typeOnly: true, privateImportPath: "./json-format.js", publicImportPath: packageName },
|
|
41
|
+
protoInt64: { typeOnly: false, privateImportPath: "./proto-int64.js", publicImportPath: packageName },
|
|
42
|
+
ScalarType: { typeOnly: false, privateImportPath: "./field.js", publicImportPath: packageName },
|
|
43
|
+
MethodKind: { typeOnly: false, privateImportPath: "./service-type.js", publicImportPath: packageName },
|
|
44
|
+
MethodIdempotency: { typeOnly: false, privateImportPath: "./service-type.js", publicImportPath: packageName },
|
|
45
|
+
},
|
|
46
|
+
wktSourceFiles: [
|
|
47
|
+
"google/protobuf/compiler/plugin.proto",
|
|
48
|
+
"google/protobuf/any.proto",
|
|
49
|
+
"google/protobuf/api.proto",
|
|
50
|
+
"google/protobuf/descriptor.proto",
|
|
51
|
+
"google/protobuf/duration.proto",
|
|
52
|
+
"google/protobuf/empty.proto",
|
|
53
|
+
"google/protobuf/field_mask.proto",
|
|
54
|
+
"google/protobuf/source_context.proto",
|
|
55
|
+
"google/protobuf/struct.proto",
|
|
56
|
+
"google/protobuf/timestamp.proto",
|
|
57
|
+
"google/protobuf/type.proto",
|
|
58
|
+
"google/protobuf/wrappers.proto",
|
|
59
|
+
],
|
|
60
|
+
};
|