@bufbuild/protobuf 0.0.7 → 0.0.10

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.
Files changed (55) hide show
  1. package/README.md +34 -4
  2. package/dist/cjs/codegen-info.js +60 -0
  3. package/dist/cjs/create-descriptor-set.js +952 -0
  4. package/dist/cjs/create-registry-from-desc.js +380 -0
  5. package/dist/cjs/create-registry.js +75 -0
  6. package/dist/cjs/descriptor-set.js +0 -436
  7. package/dist/cjs/google/protobuf/struct_pb.js +1 -1
  8. package/dist/cjs/google/protobuf/type_pb.js +1 -1
  9. package/dist/cjs/index.js +17 -7
  10. package/dist/cjs/{descriptor-registry.js → legacy-descriptor-registry.js} +18 -10
  11. package/dist/cjs/legacy-descriptor-set.js +453 -0
  12. package/dist/cjs/legacy-type-registry.js +104 -0
  13. package/dist/cjs/private/enum.js +22 -31
  14. package/dist/cjs/private/field-wrapper.js +30 -1
  15. package/dist/cjs/private/field.js +1 -1
  16. package/dist/cjs/private/names.js +168 -29
  17. package/dist/cjs/proto2.js +2 -2
  18. package/dist/cjs/proto3.js +2 -2
  19. package/dist/cjs/type-registry.js +0 -87
  20. package/dist/esm/codegen-info.js +57 -0
  21. package/dist/esm/create-descriptor-set.js +947 -0
  22. package/dist/esm/create-registry-from-desc.js +375 -0
  23. package/dist/esm/create-registry.js +71 -0
  24. package/dist/esm/descriptor-set.js +1 -434
  25. package/dist/esm/google/protobuf/struct_pb.js +1 -1
  26. package/dist/esm/google/protobuf/type_pb.js +1 -1
  27. package/dist/esm/index.js +9 -3
  28. package/dist/esm/{descriptor-registry.js → legacy-descriptor-registry.js} +16 -8
  29. package/dist/esm/legacy-descriptor-set.js +449 -0
  30. package/dist/esm/legacy-type-registry.js +100 -0
  31. package/dist/esm/private/enum.js +22 -31
  32. package/dist/esm/private/field-wrapper.js +28 -0
  33. package/dist/esm/private/field.js +2 -2
  34. package/dist/esm/private/names.js +163 -24
  35. package/dist/esm/proto2.js +3 -3
  36. package/dist/esm/proto3.js +3 -3
  37. package/dist/esm/type-registry.js +1 -85
  38. package/dist/types/codegen-info.d.ts +19 -0
  39. package/dist/types/create-descriptor-set.d.ts +16 -0
  40. package/dist/types/create-registry-from-desc.d.ts +49 -0
  41. package/dist/types/create-registry.d.ts +8 -0
  42. package/dist/types/descriptor-set.d.ts +554 -108
  43. package/dist/types/enum.d.ts +9 -5
  44. package/dist/types/index.d.ts +9 -3
  45. package/dist/types/{descriptor-registry.d.ts → legacy-descriptor-registry.d.ts} +8 -6
  46. package/dist/types/legacy-descriptor-set.d.ts +152 -0
  47. package/dist/types/legacy-type-registry.d.ts +44 -0
  48. package/dist/types/private/enum.d.ts +4 -8
  49. package/dist/types/private/field-wrapper.d.ts +7 -0
  50. package/dist/types/private/message-type.d.ts +1 -4
  51. package/dist/types/private/names.d.ts +26 -8
  52. package/dist/types/private/proto-runtime.d.ts +2 -2
  53. package/dist/types/private/util.d.ts +1 -6
  54. package/dist/types/type-registry.d.ts +0 -38
  55. package/package.json +3 -2
package/README.md CHANGED
@@ -1,9 +1,39 @@
1
1
  # @bufbuild/protobuf
2
2
 
3
- [![npm](https://img.shields.io/npm/v/@bufbuild/protobuf?style=flat-square)](https://www.npmjs.com/package/@bufbuild/protobuf)
3
+ This package provides the runtime library for the code generator plugin
4
+ [protoc-gen-es](https://www.npmjs.com/package/@bufbuild/protoc-gen-es).
4
5
 
5
- A complete implementation of protocol buffers in TypeScript,
6
- suitable for web browsers and Node.js.
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
- This is the runtime library for the code generator plugin [`protoc-gen-es`](../protoc-gen-es).
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).
@@ -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
+ };