@bufbuild/protobuf 1.3.3 → 1.4.0
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/dist/cjs/codegen-info.d.ts +1 -1
- package/dist/cjs/codegen-info.js +1 -0
- package/dist/cjs/create-descriptor-set.js +10 -4
- package/dist/cjs/create-registry-from-desc.js +7 -7
- package/dist/cjs/descriptor-set.d.ts +21 -1
- package/dist/cjs/field.d.ts +52 -1
- package/dist/cjs/field.js +29 -1
- package/dist/cjs/google/protobuf/any_pb.d.ts +2 -1
- package/dist/cjs/google/protobuf/any_pb.js +2 -1
- package/dist/cjs/google/protobuf/compiler/plugin_pb.d.ts +18 -1
- package/dist/cjs/google/protobuf/compiler/plugin_pb.js +19 -0
- package/dist/cjs/google/protobuf/descriptor_pb.d.ts +250 -16
- package/dist/cjs/google/protobuf/descriptor_pb.js +241 -7
- package/dist/cjs/google/protobuf/duration_pb.js +1 -1
- package/dist/cjs/google/protobuf/struct_pb.js +1 -1
- package/dist/cjs/google/protobuf/type_pb.js +1 -1
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/index.js +2 -1
- package/dist/cjs/json-format.d.ts +3 -1
- package/dist/cjs/private/binary-format-common.d.ts +4 -4
- package/dist/cjs/private/binary-format-common.js +18 -6
- package/dist/cjs/private/json-format-common.d.ts +1 -1
- package/dist/cjs/private/json-format-common.js +11 -7
- package/dist/cjs/private/scalars.d.ts +2 -2
- package/dist/cjs/private/scalars.js +6 -5
- package/dist/cjs/proto2.js +6 -2
- package/dist/cjs/proto3.js +6 -3
- package/dist/cjs/to-plain-message.d.ts +5 -2
- package/dist/cjs/to-plain-message.js +7 -1
- package/dist/esm/codegen-info.d.ts +1 -1
- package/dist/esm/codegen-info.js +1 -0
- package/dist/esm/create-descriptor-set.js +13 -7
- package/dist/esm/create-registry-from-desc.js +7 -7
- package/dist/esm/descriptor-set.d.ts +21 -1
- package/dist/esm/field.d.ts +52 -1
- package/dist/esm/field.js +28 -0
- package/dist/esm/google/protobuf/any_pb.d.ts +2 -1
- package/dist/esm/google/protobuf/any_pb.js +2 -1
- package/dist/esm/google/protobuf/compiler/plugin_pb.d.ts +18 -1
- package/dist/esm/google/protobuf/compiler/plugin_pb.js +19 -0
- package/dist/esm/google/protobuf/descriptor_pb.d.ts +250 -16
- package/dist/esm/google/protobuf/descriptor_pb.js +238 -6
- package/dist/esm/google/protobuf/duration_pb.js +1 -1
- package/dist/esm/google/protobuf/struct_pb.js +1 -1
- package/dist/esm/google/protobuf/type_pb.js +1 -1
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/json-format.d.ts +3 -1
- package/dist/esm/json-format.js +1 -1
- package/dist/esm/private/binary-format-common.d.ts +4 -4
- package/dist/esm/private/binary-format-common.js +17 -6
- package/dist/esm/private/json-format-common.d.ts +1 -1
- package/dist/esm/private/json-format-common.js +12 -8
- package/dist/esm/private/scalars.d.ts +2 -2
- package/dist/esm/private/scalars.js +7 -6
- package/dist/esm/proto2.js +6 -2
- package/dist/esm/proto3.js +7 -4
- package/dist/esm/to-plain-message.d.ts +5 -2
- package/dist/esm/to-plain-message.js +7 -1
- package/package.json +8 -1
package/dist/esm/proto2.js
CHANGED
|
@@ -18,6 +18,7 @@ import { InternalFieldList } from "./private/field-list.js";
|
|
|
18
18
|
import { InternalOneofInfo } from "./private/field.js";
|
|
19
19
|
import { localFieldName, fieldJsonName } from "./private/names.js";
|
|
20
20
|
import { makeJsonFormatProto2 } from "./private/json-format-proto2.js";
|
|
21
|
+
import { LongType } from "./field.js";
|
|
21
22
|
/**
|
|
22
23
|
* Provides functionality for messages defined with the proto2 syntax.
|
|
23
24
|
*/
|
|
@@ -53,7 +54,7 @@ export const proto2 = makeProtoRuntime("proto2", makeJsonFormatProto2(), makeBin
|
|
|
53
54
|
} }));
|
|
54
55
|
/* eslint-disable @typescript-eslint/no-explicit-any,@typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-argument */
|
|
55
56
|
function normalizeFieldInfosProto2(fieldInfos) {
|
|
56
|
-
var _a, _b, _c;
|
|
57
|
+
var _a, _b, _c, _d;
|
|
57
58
|
const r = [];
|
|
58
59
|
let o;
|
|
59
60
|
for (const field of typeof fieldInfos == "function"
|
|
@@ -63,8 +64,11 @@ function normalizeFieldInfosProto2(fieldInfos) {
|
|
|
63
64
|
f.localName = localFieldName(field.name, field.oneof !== undefined);
|
|
64
65
|
f.jsonName = (_a = field.jsonName) !== null && _a !== void 0 ? _a : fieldJsonName(field.name);
|
|
65
66
|
f.repeated = (_b = field.repeated) !== null && _b !== void 0 ? _b : false;
|
|
67
|
+
if (field.kind == "scalar") {
|
|
68
|
+
f.L = (_c = field.L) !== null && _c !== void 0 ? _c : LongType.BIGINT;
|
|
69
|
+
}
|
|
66
70
|
// In contrast to proto3, repeated fields are unpacked except when explicitly specified.
|
|
67
|
-
f.packed = (
|
|
71
|
+
f.packed = (_d = field.packed) !== null && _d !== void 0 ? _d : false;
|
|
68
72
|
// We do not surface options at this time
|
|
69
73
|
// f.options = field.options ?? emptyReadonlyObject;
|
|
70
74
|
if (field.oneof !== undefined) {
|
package/dist/esm/proto3.js
CHANGED
|
@@ -17,7 +17,7 @@ import { makeJsonFormatProto3 } from "./private/json-format-proto3.js";
|
|
|
17
17
|
import { makeUtilCommon } from "./private/util-common.js";
|
|
18
18
|
import { InternalFieldList } from "./private/field-list.js";
|
|
19
19
|
import { scalarDefaultValue } from "./private/scalars.js";
|
|
20
|
-
import { ScalarType } from "./field.js";
|
|
20
|
+
import { LongType, ScalarType } from "./field.js";
|
|
21
21
|
import { InternalOneofInfo } from "./private/field.js";
|
|
22
22
|
import { localFieldName, fieldJsonName } from "./private/names.js";
|
|
23
23
|
/**
|
|
@@ -47,7 +47,7 @@ export const proto3 = makeProtoRuntime("proto3", makeJsonFormatProto3(), makeBin
|
|
|
47
47
|
t[name] = {};
|
|
48
48
|
break;
|
|
49
49
|
case "scalar":
|
|
50
|
-
t[name] = scalarDefaultValue(member.T); // eslint-disable-line @typescript-eslint/no-unsafe-assignment
|
|
50
|
+
t[name] = scalarDefaultValue(member.T, member.L); // eslint-disable-line @typescript-eslint/no-unsafe-assignment
|
|
51
51
|
break;
|
|
52
52
|
case "message":
|
|
53
53
|
// message fields are always optional in proto3
|
|
@@ -57,7 +57,7 @@ export const proto3 = makeProtoRuntime("proto3", makeJsonFormatProto3(), makeBin
|
|
|
57
57
|
} }));
|
|
58
58
|
/* eslint-disable @typescript-eslint/no-explicit-any,@typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-argument */
|
|
59
59
|
function normalizeFieldInfosProto3(fieldInfos) {
|
|
60
|
-
var _a, _b, _c;
|
|
60
|
+
var _a, _b, _c, _d;
|
|
61
61
|
const r = [];
|
|
62
62
|
let o;
|
|
63
63
|
for (const field of typeof fieldInfos == "function"
|
|
@@ -67,13 +67,16 @@ function normalizeFieldInfosProto3(fieldInfos) {
|
|
|
67
67
|
f.localName = localFieldName(field.name, field.oneof !== undefined);
|
|
68
68
|
f.jsonName = (_a = field.jsonName) !== null && _a !== void 0 ? _a : fieldJsonName(field.name);
|
|
69
69
|
f.repeated = (_b = field.repeated) !== null && _b !== void 0 ? _b : false;
|
|
70
|
+
if (field.kind == "scalar") {
|
|
71
|
+
f.L = (_c = field.L) !== null && _c !== void 0 ? _c : LongType.BIGINT;
|
|
72
|
+
}
|
|
70
73
|
// From the proto3 language guide:
|
|
71
74
|
// > In proto3, repeated fields of scalar numeric types are packed by default.
|
|
72
75
|
// This information is incomplete - according to the conformance tests, BOOL
|
|
73
76
|
// and ENUM are packed by default as well. This means only STRING and BYTES
|
|
74
77
|
// are not packed by default, which makes sense because they are length-delimited.
|
|
75
78
|
f.packed =
|
|
76
|
-
(
|
|
79
|
+
(_d = field.packed) !== null && _d !== void 0 ? _d : (field.kind == "enum" ||
|
|
77
80
|
(field.kind == "scalar" &&
|
|
78
81
|
field.T != ScalarType.BYTES &&
|
|
79
82
|
field.T != ScalarType.STRING));
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { Message } from "./message.js";
|
|
2
2
|
import type { PlainMessage } from "./message.js";
|
|
3
3
|
/**
|
|
4
|
-
* toPlainMessage returns a new object by
|
|
4
|
+
* toPlainMessage returns a new object by stripping
|
|
5
5
|
* all methods from a message, leaving only fields and
|
|
6
6
|
* oneof groups. It is recursive, meaning it applies this
|
|
7
7
|
* same logic to all nested message fields as well.
|
|
8
|
+
*
|
|
9
|
+
* If the argument is already a plain message, it is
|
|
10
|
+
* returned as-is.
|
|
8
11
|
*/
|
|
9
|
-
export declare function toPlainMessage<T extends Message<T>>(message: T): PlainMessage<T>;
|
|
12
|
+
export declare function toPlainMessage<T extends Message<T>>(message: T | PlainMessage<T>): PlainMessage<T>;
|
|
@@ -14,12 +14,18 @@
|
|
|
14
14
|
/* eslint-disable @typescript-eslint/no-explicit-any,@typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-return,@typescript-eslint/no-unsafe-argument,no-case-declarations */
|
|
15
15
|
import { Message } from "./message.js";
|
|
16
16
|
/**
|
|
17
|
-
* toPlainMessage returns a new object by
|
|
17
|
+
* toPlainMessage returns a new object by stripping
|
|
18
18
|
* all methods from a message, leaving only fields and
|
|
19
19
|
* oneof groups. It is recursive, meaning it applies this
|
|
20
20
|
* same logic to all nested message fields as well.
|
|
21
|
+
*
|
|
22
|
+
* If the argument is already a plain message, it is
|
|
23
|
+
* returned as-is.
|
|
21
24
|
*/
|
|
22
25
|
export function toPlainMessage(message) {
|
|
26
|
+
if (!(message instanceof Message)) {
|
|
27
|
+
return message;
|
|
28
|
+
}
|
|
23
29
|
const type = message.getType();
|
|
24
30
|
const target = {};
|
|
25
31
|
for (const member of type.fields.byMember()) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bufbuild/protobuf",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"license": "(Apache-2.0 AND BSD-3-Clause)",
|
|
5
5
|
"description": "A complete implementation of Protocol Buffers in TypeScript, suitable for web browsers and Node.js.",
|
|
6
6
|
"repository": {
|
|
@@ -14,6 +14,10 @@
|
|
|
14
14
|
"build:cjs": "../../node_modules/typescript/bin/tsc --project tsconfig.json --module commonjs --outDir ./dist/cjs --declaration --declarationDir ./dist/cjs && echo >./dist/cjs/package.json '{\"type\":\"commonjs\"}'",
|
|
15
15
|
"build:esm": "../../node_modules/typescript/bin/tsc --project tsconfig.json --module ES2015 --verbatimModuleSyntax --outDir ./dist/esm --declaration --declarationDir ./dist/esm",
|
|
16
16
|
"build:proxy": "node ../../scripts/gen-esm-proxy.mjs .",
|
|
17
|
+
"prebootstrap": "rm -rf .tmp && mkdir -p .tmp/google/protobuf && cp -rp src/google/protobuf/* .tmp/google/protobuf",
|
|
18
|
+
"bootstrap": "protoc --es_out=src --es_opt=bootstrap_wkt=true,ts_nocheck=false,target=ts --proto_path $(upstream-include wkt) $(upstream-files wkt)",
|
|
19
|
+
"postbootstrap": "license-header src/google/protobuf",
|
|
20
|
+
"bootstrap-diff": "diff >/dev/null -r .tmp/google/protobuf src/google/protobuf && cp -rp .tmp/google/protobuf/* src/google/protobuf",
|
|
17
21
|
"attw": "attw --pack"
|
|
18
22
|
},
|
|
19
23
|
"type": "module",
|
|
@@ -26,6 +30,9 @@
|
|
|
26
30
|
"import": "./dist/proxy/index.js"
|
|
27
31
|
}
|
|
28
32
|
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"upstream-protobuf": "*"
|
|
35
|
+
},
|
|
29
36
|
"files": [
|
|
30
37
|
"dist/**"
|
|
31
38
|
]
|