@songtonyli/dsh-cli 0.1.55 → 0.1.56
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 +1 -1
- package/bin/dsh.mjs +1 -1
- package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv1/symbols.js +17 -1
- package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv2/embed.js +1 -1
- package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv2/file.js +1 -1
- package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv2/symbols.js +60 -41
- package/node_modules/@bufbuild/protobuf/dist/commonjs/create.js +2 -1
- package/node_modules/@bufbuild/protobuf/dist/commonjs/from-binary.js +9 -6
- package/node_modules/@bufbuild/protobuf/dist/commonjs/from-json.js +30 -12
- package/node_modules/@bufbuild/protobuf/dist/commonjs/reflect/message.js +3 -2
- package/node_modules/@bufbuild/protobuf/dist/commonjs/reflect/reflect-check.js +3 -4
- package/node_modules/@bufbuild/protobuf/dist/commonjs/reflect/reflect.js +2 -2
- package/node_modules/@bufbuild/protobuf/dist/commonjs/reflect/unsafe.js +31 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/registry.js +53 -5
- package/node_modules/@bufbuild/protobuf/dist/commonjs/to-json.js +27 -5
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wire/binary-encoding.js +5 -3
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/any.js +1 -1
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/duration.js +1 -1
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/{gen/google → google}/protobuf/any_pb.js +2 -2
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/{gen/google → google}/protobuf/api_pb.js +2 -2
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/google/protobuf/c_sharp_features_pb.js +33 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/{gen/google → google}/protobuf/compiler/plugin_pb.js +3 -3
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/{gen/google → google}/protobuf/cpp_features_pb.js +34 -6
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/google/protobuf/cpp_file_options_pb.js +33 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/google/protobuf/cpp_options_pb.js +22 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/{gen/google → google}/protobuf/descriptor_pb.js +49 -6
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/{gen/google → google}/protobuf/duration_pb.js +2 -2
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/{gen/google → google}/protobuf/empty_pb.js +2 -2
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/{gen/google → google}/protobuf/field_mask_pb.js +2 -2
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/{gen/google → google}/protobuf/go_features_pb.js +4 -4
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/{gen/google → google}/protobuf/java_features_pb.js +4 -4
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/google/protobuf/json_enumvalue_options_pb.js +33 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/google/protobuf/json_options_pb.js +22 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/{gen/google → google}/protobuf/source_context_pb.js +2 -2
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/{gen/google → google}/protobuf/struct_pb.js +11 -6
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/{gen/google → google}/protobuf/timestamp_pb.js +2 -2
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/{gen/google → google}/protobuf/type_pb.js +3 -3
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/{gen/google → google}/protobuf/wrappers_pb.js +2 -2
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/index.js +15 -15
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/timestamp.js +1 -1
- package/node_modules/@bufbuild/protobuf/dist/esm/codegenv1/symbols.js +18 -2
- package/node_modules/@bufbuild/protobuf/dist/esm/codegenv2/embed.js +1 -1
- package/node_modules/@bufbuild/protobuf/dist/esm/codegenv2/file.js +1 -1
- package/node_modules/@bufbuild/protobuf/dist/esm/codegenv2/symbols.js +60 -41
- package/node_modules/@bufbuild/protobuf/dist/esm/create.js +2 -1
- package/node_modules/@bufbuild/protobuf/dist/esm/from-binary.js +10 -7
- package/node_modules/@bufbuild/protobuf/dist/esm/from-json.js +31 -13
- package/node_modules/@bufbuild/protobuf/dist/esm/reflect/message.js +3 -2
- package/node_modules/@bufbuild/protobuf/dist/esm/reflect/reflect-check.js +4 -5
- package/node_modules/@bufbuild/protobuf/dist/esm/reflect/reflect.js +3 -3
- package/node_modules/@bufbuild/protobuf/dist/esm/reflect/unsafe.js +29 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/registry.js +53 -5
- package/node_modules/@bufbuild/protobuf/dist/esm/to-json.js +28 -6
- package/node_modules/@bufbuild/protobuf/dist/esm/wire/binary-encoding.js +5 -3
- package/node_modules/@bufbuild/protobuf/dist/esm/wkt/any.js +1 -1
- package/node_modules/@bufbuild/protobuf/dist/esm/wkt/duration.js +1 -1
- package/node_modules/@bufbuild/protobuf/dist/esm/wkt/{gen/google → google}/protobuf/any_pb.js +2 -2
- package/node_modules/@bufbuild/protobuf/dist/esm/wkt/{gen/google → google}/protobuf/api_pb.js +2 -2
- package/node_modules/@bufbuild/protobuf/dist/esm/wkt/google/protobuf/c_sharp_features_pb.js +30 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/wkt/{gen/google → google}/protobuf/compiler/plugin_pb.js +3 -3
- package/node_modules/@bufbuild/protobuf/dist/esm/wkt/{gen/google → google}/protobuf/cpp_features_pb.js +33 -5
- package/node_modules/@bufbuild/protobuf/dist/esm/wkt/google/protobuf/cpp_file_options_pb.js +30 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/wkt/google/protobuf/cpp_options_pb.js +19 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/wkt/{gen/google → google}/protobuf/descriptor_pb.js +47 -4
- package/node_modules/@bufbuild/protobuf/dist/esm/wkt/{gen/google → google}/protobuf/duration_pb.js +2 -2
- package/node_modules/@bufbuild/protobuf/dist/esm/wkt/{gen/google → google}/protobuf/empty_pb.js +2 -2
- package/node_modules/@bufbuild/protobuf/dist/esm/wkt/{gen/google → google}/protobuf/field_mask_pb.js +2 -2
- package/node_modules/@bufbuild/protobuf/dist/esm/wkt/{gen/google → google}/protobuf/go_features_pb.js +4 -4
- package/node_modules/@bufbuild/protobuf/dist/esm/wkt/{gen/google → google}/protobuf/java_features_pb.js +4 -4
- package/node_modules/@bufbuild/protobuf/dist/esm/wkt/google/protobuf/json_enumvalue_options_pb.js +30 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/wkt/google/protobuf/json_options_pb.js +19 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/wkt/{gen/google → google}/protobuf/source_context_pb.js +2 -2
- package/node_modules/@bufbuild/protobuf/dist/esm/wkt/{gen/google → google}/protobuf/struct_pb.js +11 -6
- package/node_modules/@bufbuild/protobuf/dist/esm/wkt/{gen/google → google}/protobuf/timestamp_pb.js +2 -2
- package/node_modules/@bufbuild/protobuf/dist/esm/wkt/{gen/google → google}/protobuf/type_pb.js +3 -3
- package/node_modules/@bufbuild/protobuf/dist/esm/wkt/{gen/google → google}/protobuf/wrappers_pb.js +2 -2
- package/node_modules/@bufbuild/protobuf/dist/esm/wkt/index.js +15 -15
- package/node_modules/@bufbuild/protobuf/dist/esm/wkt/timestamp.js +1 -1
- package/node_modules/@bufbuild/protobuf/package.json +236 -13
- package/node_modules/@deepseek-ai/dsh-client-ui-primitives/package.json +1 -1
- package/node_modules/@deepseek-ai/dsh-client-ui-sidebar/lib/client.js +1 -1
- package/node_modules/@deepseek-ai/dsh-tui-app/README.i18n.yaml +8 -8
- package/node_modules/@deepseek-ai/dsh-tui-app/README.md +15 -4
- package/node_modules/@deepseek-ai/dsh-tui-app/README.zh.md +15 -4
- package/node_modules/@deepseek-ai/dsh-tui-app/lib/index.js +691 -42
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -26,7 +26,7 @@ workspace and no build step. Native packages that ship one build per platform
|
|
|
26
26
|
ripgrep, the PTY backend's addons, sharp, koffi, and the Landlock launcher — are
|
|
27
27
|
ordinary optional dependencies, so npm resolves the right one for your machine.
|
|
28
28
|
|
|
29
|
-
Requires Node `^22.19.0 || >=24.0.0`. Version 0.1.
|
|
29
|
+
Requires Node `^22.19.0 || >=24.0.0`. Version 0.1.56; `dsh --version`
|
|
30
30
|
also reports the harness build the package was assembled from.
|
|
31
31
|
|
|
32
32
|
## License
|
package/bin/dsh.mjs
CHANGED
|
@@ -18,7 +18,7 @@ const argv = process.argv.slice(2)
|
|
|
18
18
|
// version this package publishes. Reporting only one of the two would make an
|
|
19
19
|
// ordinary `npm install @songtonyli/dsh-cli@x` look like it installed something else.
|
|
20
20
|
if (argv.length === 1 && (argv[0] === '--version' || argv[0] === '-V')) {
|
|
21
|
-
console.log('@songtonyli/dsh-cli 0.1.
|
|
21
|
+
console.log('@songtonyli/dsh-cli 0.1.56 (deepseek-harness 0.2.0-rc.2)')
|
|
22
22
|
process.exit(0)
|
|
23
23
|
}
|
|
24
24
|
|
|
@@ -22,7 +22,23 @@ exports.packageName = symbols_js_1.packageName;
|
|
|
22
22
|
/**
|
|
23
23
|
* @private
|
|
24
24
|
*/
|
|
25
|
-
exports.wktPublicImportPaths =
|
|
25
|
+
exports.wktPublicImportPaths = {
|
|
26
|
+
"google/protobuf/compiler/plugin.proto": exports.packageName + "/wkt",
|
|
27
|
+
"google/protobuf/any.proto": exports.packageName + "/wkt",
|
|
28
|
+
"google/protobuf/api.proto": exports.packageName + "/wkt",
|
|
29
|
+
"google/protobuf/cpp_features.proto": exports.packageName + "/wkt",
|
|
30
|
+
"google/protobuf/descriptor.proto": exports.packageName + "/wkt",
|
|
31
|
+
"google/protobuf/duration.proto": exports.packageName + "/wkt",
|
|
32
|
+
"google/protobuf/empty.proto": exports.packageName + "/wkt",
|
|
33
|
+
"google/protobuf/field_mask.proto": exports.packageName + "/wkt",
|
|
34
|
+
"google/protobuf/go_features.proto": exports.packageName + "/wkt",
|
|
35
|
+
"google/protobuf/java_features.proto": exports.packageName + "/wkt",
|
|
36
|
+
"google/protobuf/source_context.proto": exports.packageName + "/wkt",
|
|
37
|
+
"google/protobuf/struct.proto": exports.packageName + "/wkt",
|
|
38
|
+
"google/protobuf/timestamp.proto": exports.packageName + "/wkt",
|
|
39
|
+
"google/protobuf/type.proto": exports.packageName + "/wkt",
|
|
40
|
+
"google/protobuf/wrappers.proto": exports.packageName + "/wkt",
|
|
41
|
+
};
|
|
26
42
|
/**
|
|
27
43
|
* @private
|
|
28
44
|
*/
|
|
@@ -21,7 +21,7 @@ const fields_js_1 = require("../fields.js");
|
|
|
21
21
|
const base64_encoding_js_1 = require("../wire/base64-encoding.js");
|
|
22
22
|
const to_binary_js_1 = require("../to-binary.js");
|
|
23
23
|
const clone_js_1 = require("../clone.js");
|
|
24
|
-
const descriptor_pb_js_1 = require("../wkt/
|
|
24
|
+
const descriptor_pb_js_1 = require("../wkt/google/protobuf/descriptor_pb.js");
|
|
25
25
|
/**
|
|
26
26
|
* Create necessary information to embed a file descriptor in
|
|
27
27
|
* generated code.
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
16
|
exports.fileDesc = fileDesc;
|
|
17
17
|
const base64_encoding_js_1 = require("../wire/base64-encoding.js");
|
|
18
|
-
const descriptor_pb_js_1 = require("../wkt/
|
|
18
|
+
const descriptor_pb_js_1 = require("../wkt/google/protobuf/descriptor_pb.js");
|
|
19
19
|
const registry_js_1 = require("../registry.js");
|
|
20
20
|
const restore_json_names_js_1 = require("./restore-json-names.js");
|
|
21
21
|
const from_binary_js_1 = require("../from-binary.js");
|
|
@@ -18,57 +18,76 @@ exports.symbols = exports.wktPublicImportPaths = exports.packageName = void 0;
|
|
|
18
18
|
* @private
|
|
19
19
|
*/
|
|
20
20
|
exports.packageName = "@bufbuild/protobuf";
|
|
21
|
+
const legacyWktBarrel = exports.packageName + "/wkt";
|
|
21
22
|
/**
|
|
22
23
|
* @private
|
|
24
|
+
*
|
|
25
|
+
* A map from Protobuf file path to import path for the well-known types.
|
|
26
|
+
*
|
|
27
|
+
* All well-known files are exported as subpaths from @bufbuild/protobuf/wkt,
|
|
28
|
+
* but have been historically exported from a barrel. For backwards-compatibility,
|
|
29
|
+
* the existing barrel exports are maintained.
|
|
30
|
+
*
|
|
31
|
+
* For convenience, generated code continues to import from the barrel for
|
|
32
|
+
* commonly used WKT, and only generates the full subpath import for files
|
|
33
|
+
* that are rarely used.
|
|
34
|
+
*
|
|
35
|
+
* All well-known files must be listed here. New files should import from the
|
|
36
|
+
* full subpath.
|
|
23
37
|
*/
|
|
24
38
|
exports.wktPublicImportPaths = {
|
|
25
|
-
"google/protobuf/compiler/plugin.proto":
|
|
26
|
-
"google/protobuf/any.proto":
|
|
27
|
-
"google/protobuf/api.proto": exports.packageName + "/wkt",
|
|
28
|
-
"google/protobuf/
|
|
29
|
-
"google/protobuf/
|
|
30
|
-
"google/protobuf/
|
|
31
|
-
"google/protobuf/
|
|
32
|
-
"google/protobuf/
|
|
33
|
-
"google/protobuf/
|
|
34
|
-
"google/protobuf/
|
|
35
|
-
"google/protobuf/
|
|
36
|
-
"google/protobuf/
|
|
37
|
-
"google/protobuf/
|
|
38
|
-
"google/protobuf/
|
|
39
|
-
"google/protobuf/
|
|
39
|
+
"google/protobuf/compiler/plugin.proto": legacyWktBarrel,
|
|
40
|
+
"google/protobuf/any.proto": legacyWktBarrel,
|
|
41
|
+
"google/protobuf/api.proto": exports.packageName + "/wkt/google/protobuf/api_pb.js",
|
|
42
|
+
"google/protobuf/c_sharp_features.proto": exports.packageName + "/wkt/google/protobuf/c_sharp_features_pb.js",
|
|
43
|
+
"google/protobuf/cpp_features.proto": exports.packageName + "/wkt/google/protobuf/cpp_features_pb.js",
|
|
44
|
+
"google/protobuf/cpp_file_options.proto": exports.packageName + "/wkt/google/protobuf/cpp_file_options_pb.js",
|
|
45
|
+
"google/protobuf/cpp_options.proto": exports.packageName + "/wkt/google/protobuf/cpp_options_pb.js",
|
|
46
|
+
"google/protobuf/descriptor.proto": legacyWktBarrel,
|
|
47
|
+
"google/protobuf/duration.proto": legacyWktBarrel,
|
|
48
|
+
"google/protobuf/empty.proto": legacyWktBarrel,
|
|
49
|
+
"google/protobuf/field_mask.proto": legacyWktBarrel,
|
|
50
|
+
"google/protobuf/go_features.proto": exports.packageName + "/wkt/google/protobuf/go_features_pb.js",
|
|
51
|
+
"google/protobuf/java_features.proto": exports.packageName + "/wkt/google/protobuf/java_features_pb.js",
|
|
52
|
+
"google/protobuf/json_enumvalue_options.proto": exports.packageName + "/wkt/google/protobuf/json_enumvalue_options_pb.js",
|
|
53
|
+
"google/protobuf/json_options.proto": exports.packageName + "/wkt/google/protobuf/json_options_pb.js",
|
|
54
|
+
"google/protobuf/source_context.proto": exports.packageName + "/wkt/google/protobuf/source_context_pb.js",
|
|
55
|
+
"google/protobuf/struct.proto": legacyWktBarrel,
|
|
56
|
+
"google/protobuf/timestamp.proto": legacyWktBarrel,
|
|
57
|
+
"google/protobuf/type.proto": exports.packageName + "/wkt/google/protobuf/type_pb.js",
|
|
58
|
+
"google/protobuf/wrappers.proto": legacyWktBarrel,
|
|
40
59
|
};
|
|
41
60
|
/**
|
|
42
61
|
* @private
|
|
43
62
|
*/
|
|
44
63
|
// biome-ignore format: want this to read well
|
|
45
64
|
exports.symbols = {
|
|
46
|
-
isMessage: { typeOnly: false, bootstrapWktFrom: "
|
|
47
|
-
Message: { typeOnly: true, bootstrapWktFrom: "
|
|
48
|
-
create: { typeOnly: false, bootstrapWktFrom: "
|
|
49
|
-
fromJson: { typeOnly: false, bootstrapWktFrom: "
|
|
50
|
-
fromJsonString: { typeOnly: false, bootstrapWktFrom: "
|
|
51
|
-
fromBinary: { typeOnly: false, bootstrapWktFrom: "
|
|
52
|
-
toBinary: { typeOnly: false, bootstrapWktFrom: "
|
|
53
|
-
toJson: { typeOnly: false, bootstrapWktFrom: "
|
|
54
|
-
toJsonString: { typeOnly: false, bootstrapWktFrom: "
|
|
55
|
-
protoInt64: { typeOnly: false, bootstrapWktFrom: "
|
|
56
|
-
JsonValue: { typeOnly: true, bootstrapWktFrom: "
|
|
57
|
-
JsonObject: { typeOnly: true, bootstrapWktFrom: "
|
|
58
|
-
UnknownEnum: { typeOnly: true, bootstrapWktFrom: "
|
|
65
|
+
isMessage: { typeOnly: false, bootstrapWktFrom: "../is-message.js", from: exports.packageName },
|
|
66
|
+
Message: { typeOnly: true, bootstrapWktFrom: "../types.js", from: exports.packageName },
|
|
67
|
+
create: { typeOnly: false, bootstrapWktFrom: "../create.js", from: exports.packageName },
|
|
68
|
+
fromJson: { typeOnly: false, bootstrapWktFrom: "../from-json.js", from: exports.packageName },
|
|
69
|
+
fromJsonString: { typeOnly: false, bootstrapWktFrom: "../from-json.js", from: exports.packageName },
|
|
70
|
+
fromBinary: { typeOnly: false, bootstrapWktFrom: "../from-binary.js", from: exports.packageName },
|
|
71
|
+
toBinary: { typeOnly: false, bootstrapWktFrom: "../to-binary.js", from: exports.packageName },
|
|
72
|
+
toJson: { typeOnly: false, bootstrapWktFrom: "../to-json.js", from: exports.packageName },
|
|
73
|
+
toJsonString: { typeOnly: false, bootstrapWktFrom: "../to-json.js", from: exports.packageName },
|
|
74
|
+
protoInt64: { typeOnly: false, bootstrapWktFrom: "../proto-int64.js", from: exports.packageName },
|
|
75
|
+
JsonValue: { typeOnly: true, bootstrapWktFrom: "../json-value.js", from: exports.packageName },
|
|
76
|
+
JsonObject: { typeOnly: true, bootstrapWktFrom: "../json-value.js", from: exports.packageName },
|
|
77
|
+
UnknownEnum: { typeOnly: true, bootstrapWktFrom: "../types.js", from: exports.packageName },
|
|
59
78
|
codegen: {
|
|
60
|
-
boot: { typeOnly: false, bootstrapWktFrom: "
|
|
61
|
-
fileDesc: { typeOnly: false, bootstrapWktFrom: "
|
|
62
|
-
enumDesc: { typeOnly: false, bootstrapWktFrom: "
|
|
63
|
-
extDesc: { typeOnly: false, bootstrapWktFrom: "
|
|
64
|
-
messageDesc: { typeOnly: false, bootstrapWktFrom: "
|
|
65
|
-
serviceDesc: { typeOnly: false, bootstrapWktFrom: "
|
|
66
|
-
tsEnum: { typeOnly: false, bootstrapWktFrom: "
|
|
67
|
-
objEnum: { typeOnly: false, bootstrapWktFrom: "
|
|
68
|
-
GenFile: { typeOnly: true, bootstrapWktFrom: "
|
|
69
|
-
GenEnum: { typeOnly: true, bootstrapWktFrom: "
|
|
70
|
-
GenExtension: { typeOnly: true, bootstrapWktFrom: "
|
|
71
|
-
GenMessage: { typeOnly: true, bootstrapWktFrom: "
|
|
72
|
-
GenService: { typeOnly: true, bootstrapWktFrom: "
|
|
79
|
+
boot: { typeOnly: false, bootstrapWktFrom: "../codegenv2/boot.js", from: exports.packageName + "/codegenv2" },
|
|
80
|
+
fileDesc: { typeOnly: false, bootstrapWktFrom: "../codegenv2/file.js", from: exports.packageName + "/codegenv2" },
|
|
81
|
+
enumDesc: { typeOnly: false, bootstrapWktFrom: "../codegenv2/enum.js", from: exports.packageName + "/codegenv2" },
|
|
82
|
+
extDesc: { typeOnly: false, bootstrapWktFrom: "../codegenv2/extension.js", from: exports.packageName + "/codegenv2" },
|
|
83
|
+
messageDesc: { typeOnly: false, bootstrapWktFrom: "../codegenv2/message.js", from: exports.packageName + "/codegenv2" },
|
|
84
|
+
serviceDesc: { typeOnly: false, bootstrapWktFrom: "../codegenv2/service.js", from: exports.packageName + "/codegenv2" },
|
|
85
|
+
tsEnum: { typeOnly: false, bootstrapWktFrom: "../codegenv2/enum.js", from: exports.packageName + "/codegenv2" },
|
|
86
|
+
objEnum: { typeOnly: false, bootstrapWktFrom: "../codegenv2/enum.js", from: exports.packageName + "/codegenv2" },
|
|
87
|
+
GenFile: { typeOnly: true, bootstrapWktFrom: "../codegenv2/types.js", from: exports.packageName + "/codegenv2" },
|
|
88
|
+
GenEnum: { typeOnly: true, bootstrapWktFrom: "../codegenv2/types.js", from: exports.packageName + "/codegenv2" },
|
|
89
|
+
GenExtension: { typeOnly: true, bootstrapWktFrom: "../codegenv2/types.js", from: exports.packageName + "/codegenv2" },
|
|
90
|
+
GenMessage: { typeOnly: true, bootstrapWktFrom: "../codegenv2/types.js", from: exports.packageName + "/codegenv2" },
|
|
91
|
+
GenService: { typeOnly: true, bootstrapWktFrom: "../codegenv2/types.js", from: exports.packageName + "/codegenv2" },
|
|
73
92
|
},
|
|
74
93
|
};
|
|
@@ -18,6 +18,7 @@ const is_message_js_1 = require("./is-message.js");
|
|
|
18
18
|
const descriptors_js_1 = require("./descriptors.js");
|
|
19
19
|
const scalar_js_1 = require("./reflect/scalar.js");
|
|
20
20
|
const guard_js_1 = require("./reflect/guard.js");
|
|
21
|
+
const unsafe_js_1 = require("./reflect/unsafe.js");
|
|
21
22
|
const wrappers_js_1 = require("./wkt/wrappers.js");
|
|
22
23
|
// bootstrap-inject google.protobuf.Edition.EDITION_PROTO3: const $name = $number;
|
|
23
24
|
const EDITION_PROTO3 = 999;
|
|
@@ -102,7 +103,7 @@ function compileCreate(desc) {
|
|
|
102
103
|
const converted = {};
|
|
103
104
|
const keys = Object.keys(initValue);
|
|
104
105
|
for (let k = 0; k < keys.length; k++) {
|
|
105
|
-
converted
|
|
106
|
+
(0, unsafe_js_1.setOwn)(converted, keys[k], property.convert(initValue[keys[k]]));
|
|
106
107
|
}
|
|
107
108
|
message[name] = converted;
|
|
108
109
|
}
|
|
@@ -318,8 +318,10 @@ function compileMapFieldReader(field) {
|
|
|
318
318
|
case "message": {
|
|
319
319
|
const { toMessage, toLocal } = (0, message_js_1.localMessageMapper)(field);
|
|
320
320
|
const readChild = compiledReader(field.message).read;
|
|
321
|
-
|
|
322
|
-
|
|
321
|
+
// A repeated value field within one entry merges into the previous
|
|
322
|
+
// value, like any other singular message field.
|
|
323
|
+
readValue = (reader, ctx, existing) => {
|
|
324
|
+
const child = toMessage(existing);
|
|
323
325
|
readChild(child, reader, ctx, reader.uint32());
|
|
324
326
|
return toLocal(child);
|
|
325
327
|
};
|
|
@@ -344,7 +346,7 @@ function compileMapFieldReader(field) {
|
|
|
344
346
|
key = readKey(reader);
|
|
345
347
|
break;
|
|
346
348
|
case 2:
|
|
347
|
-
val = readValue(reader, ctx);
|
|
349
|
+
val = readValue(reader, ctx, val);
|
|
348
350
|
break;
|
|
349
351
|
}
|
|
350
352
|
}
|
|
@@ -354,9 +356,10 @@ function compileMapFieldReader(field) {
|
|
|
354
356
|
if (val === undefined) {
|
|
355
357
|
val = valueDefault();
|
|
356
358
|
}
|
|
357
|
-
//
|
|
358
|
-
//
|
|
359
|
-
|
|
359
|
+
// Map keys may be booleans, numbers, or bigints. Object keys are strings, so
|
|
360
|
+
// they are converted implicitly. setOwn() is needed because a key can be
|
|
361
|
+
// "__proto__".
|
|
362
|
+
(0, unsafe_js_1.setOwn)(record, key, val);
|
|
360
363
|
};
|
|
361
364
|
}
|
|
362
365
|
/**
|
|
@@ -119,9 +119,14 @@ function enumFromJson(descEnum, json) {
|
|
|
119
119
|
}
|
|
120
120
|
/**
|
|
121
121
|
* Is the given value a JSON enum value?
|
|
122
|
+
*
|
|
123
|
+
* For an enum value with a custom JSON name set with the option
|
|
124
|
+
* `(pb.enumvalue.json).string`, this function only returns true for the
|
|
125
|
+
* custom name, while fromJson() and enumFromJson() also accept the Protobuf
|
|
126
|
+
* name.
|
|
122
127
|
*/
|
|
123
128
|
function isEnumJson(descEnum, value) {
|
|
124
|
-
return
|
|
129
|
+
return descEnum.values.some((v) => v.jsonName === value);
|
|
125
130
|
}
|
|
126
131
|
const compiledReaders = new WeakMap();
|
|
127
132
|
/**
|
|
@@ -551,9 +556,10 @@ function compileMapFieldReader(field) {
|
|
|
551
556
|
throw new error_js_1.FieldError(field, `map entry ${(0, reflect_check_js_1.formatVal)(key)}: ${(0, reflect_check_js_1.reasonSingular)(field, value, check)}`);
|
|
552
557
|
}
|
|
553
558
|
}
|
|
554
|
-
//
|
|
555
|
-
//
|
|
556
|
-
|
|
559
|
+
// Map keys may be booleans, numbers, or bigints. Object keys are strings, so
|
|
560
|
+
// they are converted implicitly. setOwn() is needed because a key can be
|
|
561
|
+
// "__proto__".
|
|
562
|
+
(0, unsafe_js_1.setOwn)(record, key, toLocalValue(value));
|
|
557
563
|
}
|
|
558
564
|
};
|
|
559
565
|
}
|
|
@@ -566,7 +572,16 @@ const tokenIgnoredUnknownEnum = Symbol();
|
|
|
566
572
|
*/
|
|
567
573
|
function compileEnumConverter(desc) {
|
|
568
574
|
const zero = desc.values[0].number;
|
|
569
|
-
|
|
575
|
+
// Protobuf compilers reject a custom JSON name that equals the Protobuf name
|
|
576
|
+
// of another value. As a fallback, the Protobuf name takes precedence, so we
|
|
577
|
+
// add Protobuf names last.
|
|
578
|
+
const numbers = new Map();
|
|
579
|
+
for (const value of desc.values) {
|
|
580
|
+
numbers.set(value.jsonName, value.number);
|
|
581
|
+
}
|
|
582
|
+
for (const value of desc.values) {
|
|
583
|
+
numbers.set(value.name, value.number);
|
|
584
|
+
}
|
|
570
585
|
return (json, ignoreUnknownFields) => {
|
|
571
586
|
if (json === null) {
|
|
572
587
|
return zero;
|
|
@@ -578,9 +593,9 @@ function compileEnumConverter(desc) {
|
|
|
578
593
|
}
|
|
579
594
|
break;
|
|
580
595
|
case "string": {
|
|
581
|
-
const
|
|
582
|
-
if (
|
|
583
|
-
return
|
|
596
|
+
const number = numbers.get(json);
|
|
597
|
+
if (number !== undefined) {
|
|
598
|
+
return number;
|
|
584
599
|
}
|
|
585
600
|
if (ignoreUnknownFields) {
|
|
586
601
|
return tokenIgnoredUnknownEnum;
|
|
@@ -910,9 +925,12 @@ function anyFromJson(any, json, ctx) {
|
|
|
910
925
|
compiledReader(desc)(message, json.value, ctx);
|
|
911
926
|
}
|
|
912
927
|
else {
|
|
913
|
-
const copy =
|
|
914
|
-
|
|
915
|
-
|
|
928
|
+
const copy = {};
|
|
929
|
+
for (const key of Object.keys(json)) {
|
|
930
|
+
if (key !== "@type") {
|
|
931
|
+
(0, unsafe_js_1.setOwn)(copy, key, json[key]);
|
|
932
|
+
}
|
|
933
|
+
}
|
|
916
934
|
compiledReader(desc)(message, copy, ctx);
|
|
917
935
|
}
|
|
918
936
|
(0, index_js_1.anyPack)(desc, message, any);
|
|
@@ -987,7 +1005,7 @@ function structFromJson(struct, json, ctx) {
|
|
|
987
1005
|
const key = keys[i];
|
|
988
1006
|
const parsedValue = (0, create_js_1.create)(index_js_1.ValueSchema);
|
|
989
1007
|
valueFromJson(parsedValue, json[key], ctx);
|
|
990
|
-
struct.fields
|
|
1008
|
+
(0, unsafe_js_1.setOwn)(struct.fields, key, parsedValue);
|
|
991
1009
|
}
|
|
992
1010
|
}
|
|
993
1011
|
function valueFromJson(value, json, ctx) {
|
|
@@ -18,6 +18,7 @@ exports.wktStructToReflect = wktStructToReflect;
|
|
|
18
18
|
exports.wktStructToLocal = wktStructToLocal;
|
|
19
19
|
const create_js_1 = require("../create.js");
|
|
20
20
|
const guard_js_1 = require("./guard.js");
|
|
21
|
+
const unsafe_js_1 = require("./unsafe.js");
|
|
21
22
|
const wrappers_js_1 = require("../wkt/wrappers.js");
|
|
22
23
|
// google.protobuf.NullValue.NULL_VALUE;
|
|
23
24
|
const NULL_VALUE = 0;
|
|
@@ -81,7 +82,7 @@ function wktStructToReflect(json) {
|
|
|
81
82
|
};
|
|
82
83
|
if ((0, guard_js_1.isObject)(json)) {
|
|
83
84
|
for (const k of Object.keys(json)) {
|
|
84
|
-
struct.fields
|
|
85
|
+
(0, unsafe_js_1.setOwn)(struct.fields, k, wktValueToReflect(json[k]));
|
|
85
86
|
}
|
|
86
87
|
}
|
|
87
88
|
return struct;
|
|
@@ -94,7 +95,7 @@ function wktStructToReflect(json) {
|
|
|
94
95
|
function wktStructToLocal(val) {
|
|
95
96
|
const json = {};
|
|
96
97
|
for (const k of Object.keys(val.fields)) {
|
|
97
|
-
json
|
|
98
|
+
(0, unsafe_js_1.setOwn)(json, k, wktValueToLocal(val.fields[k]));
|
|
98
99
|
}
|
|
99
100
|
return json;
|
|
100
101
|
}
|
|
@@ -104,10 +104,9 @@ function checkScalarValue(scalar) {
|
|
|
104
104
|
if (typeof value != "number") {
|
|
105
105
|
return false;
|
|
106
106
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
if (value > binary_encoding_js_1.FLOAT32_MAX || value < binary_encoding_js_1.FLOAT32_MIN) {
|
|
107
|
+
// float32 is represented with regular 64-bit numbers. A value too large for
|
|
108
|
+
// a float32 becomes infinity when rounded. NaN and infinity are valid values.
|
|
109
|
+
if (!Number.isFinite(Math.fround(value)) && Number.isFinite(value)) {
|
|
111
110
|
return `${value.toFixed()} out of range`;
|
|
112
111
|
}
|
|
113
112
|
return true;
|
|
@@ -248,7 +248,7 @@ class ReflectMapImpl {
|
|
|
248
248
|
throw err;
|
|
249
249
|
}
|
|
250
250
|
}
|
|
251
|
-
this.obj
|
|
251
|
+
(0, unsafe_js_1.setOwn)(this.obj, mapKeyToLocal(key), mapValueToLocal(this._field, value));
|
|
252
252
|
return this;
|
|
253
253
|
}
|
|
254
254
|
delete(key) {
|
|
@@ -265,7 +265,7 @@ class ReflectMapImpl {
|
|
|
265
265
|
}
|
|
266
266
|
}
|
|
267
267
|
get(key) {
|
|
268
|
-
let val = this.obj
|
|
268
|
+
let val = (0, unsafe_js_1.getOwn)(this.obj, mapKeyToLocal(key));
|
|
269
269
|
if (val !== undefined) {
|
|
270
270
|
val = mapValueToReflect(this._field, val, this.check);
|
|
271
271
|
}
|
|
@@ -19,6 +19,8 @@ exports.unsafeIsSet = unsafeIsSet;
|
|
|
19
19
|
exports.unsafeIsSetExplicit = unsafeIsSetExplicit;
|
|
20
20
|
exports.unsafeGet = unsafeGet;
|
|
21
21
|
exports.unsafeSet = unsafeSet;
|
|
22
|
+
exports.setOwn = setOwn;
|
|
23
|
+
exports.getOwn = getOwn;
|
|
22
24
|
exports.unsafeClear = unsafeClear;
|
|
23
25
|
const scalar_js_1 = require("./scalar.js");
|
|
24
26
|
// bootstrap-inject google.protobuf.FeatureSet.FieldPresence.IMPLICIT: const $name = $number;
|
|
@@ -109,6 +111,35 @@ function unsafeSet(target, field, value) {
|
|
|
109
111
|
target[field.localName] = value;
|
|
110
112
|
}
|
|
111
113
|
}
|
|
114
|
+
/**
|
|
115
|
+
* Set a property, treating __proto__ as an own data property.
|
|
116
|
+
*
|
|
117
|
+
* @private
|
|
118
|
+
*/
|
|
119
|
+
function setOwn(obj, key, value) {
|
|
120
|
+
if (key === "__proto__") {
|
|
121
|
+
Object.defineProperty(obj, "__proto__", {
|
|
122
|
+
value,
|
|
123
|
+
writable: true,
|
|
124
|
+
enumerable: true,
|
|
125
|
+
configurable: true,
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
// Plain assignment is the engine's optimized fast path: defineProperty is
|
|
130
|
+
// several times slower and can deoptimize the object, so we reserve it for
|
|
131
|
+
// the only key that actually needs it.
|
|
132
|
+
obj[key] = value;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Get a property, disregarding inherited members.
|
|
137
|
+
*
|
|
138
|
+
* @private
|
|
139
|
+
*/
|
|
140
|
+
function getOwn(obj, key) {
|
|
141
|
+
return Object.prototype.hasOwnProperty.call(obj, key) ? obj[key] : undefined;
|
|
142
|
+
}
|
|
112
143
|
/**
|
|
113
144
|
* Resets the field, so that unsafeIsSet() will return false.
|
|
114
145
|
*
|
|
@@ -22,6 +22,7 @@ const text_format_js_1 = require("./wire/text-format.js");
|
|
|
22
22
|
const nested_types_js_1 = require("./reflect/nested-types.js");
|
|
23
23
|
const unsafe_js_1 = require("./reflect/unsafe.js");
|
|
24
24
|
const names_js_1 = require("./reflect/names.js");
|
|
25
|
+
const binary_encoding_js_1 = require("./wire/binary-encoding.js");
|
|
25
26
|
/**
|
|
26
27
|
* Create a registry from the given inputs.
|
|
27
28
|
*
|
|
@@ -232,9 +233,9 @@ const OPEN = 1;
|
|
|
232
233
|
// bootstrap-inject google.protobuf.FeatureSet.Utf8Validation.VERIFY: const $name = $number;
|
|
233
234
|
const VERIFY = 2;
|
|
234
235
|
// biome-ignore format: want this to read well
|
|
235
|
-
// bootstrap-inject defaults: EDITION_PROTO2 to
|
|
236
|
-
// generated from protoc
|
|
237
|
-
exports.minimumEdition = 998, exports.maximumEdition =
|
|
236
|
+
// bootstrap-inject defaults: EDITION_PROTO2 to EDITION_2026: export const minimumEdition: SupportedEdition = $minimumEdition, maximumEdition: SupportedEdition = $maximumEdition;
|
|
237
|
+
// generated from protoc v36.2
|
|
238
|
+
exports.minimumEdition = 998, exports.maximumEdition = 1002;
|
|
238
239
|
const featureDefaults = {
|
|
239
240
|
// EDITION_PROTO2
|
|
240
241
|
998: {
|
|
@@ -246,6 +247,7 @@ const featureDefaults = {
|
|
|
246
247
|
jsonFormat: 2, // LEGACY_BEST_EFFORT,
|
|
247
248
|
enforceNamingStyle: 2, // STYLE_LEGACY,
|
|
248
249
|
defaultSymbolVisibility: 1, // EXPORT_ALL,
|
|
250
|
+
enforceProtoLimits: 1, // LEGACY_NO_EXPLICIT_LIMITS,
|
|
249
251
|
},
|
|
250
252
|
// EDITION_PROTO3
|
|
251
253
|
999: {
|
|
@@ -257,6 +259,7 @@ const featureDefaults = {
|
|
|
257
259
|
jsonFormat: 1, // ALLOW,
|
|
258
260
|
enforceNamingStyle: 2, // STYLE_LEGACY,
|
|
259
261
|
defaultSymbolVisibility: 1, // EXPORT_ALL,
|
|
262
|
+
enforceProtoLimits: 1, // LEGACY_NO_EXPLICIT_LIMITS,
|
|
260
263
|
},
|
|
261
264
|
// EDITION_2023
|
|
262
265
|
1000: {
|
|
@@ -268,6 +271,7 @@ const featureDefaults = {
|
|
|
268
271
|
jsonFormat: 1, // ALLOW,
|
|
269
272
|
enforceNamingStyle: 2, // STYLE_LEGACY,
|
|
270
273
|
defaultSymbolVisibility: 1, // EXPORT_ALL,
|
|
274
|
+
enforceProtoLimits: 1, // LEGACY_NO_EXPLICIT_LIMITS,
|
|
271
275
|
},
|
|
272
276
|
// EDITION_2024
|
|
273
277
|
1001: {
|
|
@@ -279,6 +283,19 @@ const featureDefaults = {
|
|
|
279
283
|
jsonFormat: 1, // ALLOW,
|
|
280
284
|
enforceNamingStyle: 1, // STYLE2024,
|
|
281
285
|
defaultSymbolVisibility: 2, // EXPORT_TOP_LEVEL,
|
|
286
|
+
enforceProtoLimits: 1, // LEGACY_NO_EXPLICIT_LIMITS,
|
|
287
|
+
},
|
|
288
|
+
// EDITION_2026
|
|
289
|
+
1002: {
|
|
290
|
+
fieldPresence: 1, // EXPLICIT,
|
|
291
|
+
enumType: 1, // OPEN,
|
|
292
|
+
repeatedFieldEncoding: 1, // PACKED,
|
|
293
|
+
utf8Validation: 2, // VERIFY,
|
|
294
|
+
messageEncoding: 1, // LENGTH_PREFIXED,
|
|
295
|
+
jsonFormat: 1, // ALLOW,
|
|
296
|
+
enforceNamingStyle: 3, // STYLE2026,
|
|
297
|
+
defaultSymbolVisibility: 4, // STRICT,
|
|
298
|
+
enforceProtoLimits: 2, // PROTO_LIMITS2026,
|
|
282
299
|
},
|
|
283
300
|
};
|
|
284
301
|
/**
|
|
@@ -394,7 +411,7 @@ function addFields(message, reg, mapEntries) {
|
|
|
394
411
|
* parent type, if any.
|
|
395
412
|
*/
|
|
396
413
|
function addEnum(proto, file, parent, reg) {
|
|
397
|
-
var _a, _b, _c, _d, _e;
|
|
414
|
+
var _a, _b, _c, _d, _e, _f;
|
|
398
415
|
const sharedPrefix = findEnumSharedPrefix(proto.name, proto.value);
|
|
399
416
|
const desc = {
|
|
400
417
|
kind: "enum",
|
|
@@ -428,12 +445,13 @@ function addEnum(proto, file, parent, reg) {
|
|
|
428
445
|
? name
|
|
429
446
|
: name.substring(sharedPrefix.length)),
|
|
430
447
|
number: p.number,
|
|
448
|
+
jsonName: (_e = findEnumValueJsonName(p)) !== null && _e !== void 0 ? _e : name,
|
|
431
449
|
toString() {
|
|
432
450
|
return `enum value ${desc.typeName}.${name}`;
|
|
433
451
|
},
|
|
434
452
|
}));
|
|
435
453
|
}
|
|
436
|
-
((
|
|
454
|
+
((_f = parent === null || parent === void 0 ? void 0 : parent.nestedEnums) !== null && _f !== void 0 ? _f : file.enums).push(desc);
|
|
437
455
|
}
|
|
438
456
|
/**
|
|
439
457
|
* Create a descriptor for a message, including nested types, and add it to our
|
|
@@ -757,6 +775,36 @@ function findEnumSharedPrefix(enumName, values) {
|
|
|
757
775
|
}
|
|
758
776
|
return prefix;
|
|
759
777
|
}
|
|
778
|
+
/**
|
|
779
|
+
* Finds the custom JSON name of an enum value, set with the option
|
|
780
|
+
* `(pb.enumvalue.json).string` from google/protobuf/json_enumvalue_options.proto.
|
|
781
|
+
*
|
|
782
|
+
* Extensions are stored as unknown fields, so we read the option from the
|
|
783
|
+
* wire format instead of importing the extension, which depends on this file.
|
|
784
|
+
*/
|
|
785
|
+
function findEnumValueJsonName(proto) {
|
|
786
|
+
var _a, _b;
|
|
787
|
+
const extensionNumber = 998; // extend EnumValueOptions { JsonEnumValueOptions json = 998; }
|
|
788
|
+
const fieldNumber = 1; // message JsonEnumValueOptions { string string = 1; }
|
|
789
|
+
let jsonName;
|
|
790
|
+
for (const uf of (_b = (_a = proto.options) === null || _a === void 0 ? void 0 : _a.$unknown) !== null && _b !== void 0 ? _b : []) {
|
|
791
|
+
if (uf.no !== extensionNumber || uf.wireType !== binary_encoding_js_1.WireType.LengthDelimited) {
|
|
792
|
+
continue;
|
|
793
|
+
}
|
|
794
|
+
// Occurrences of a message field are merged, so the last value wins.
|
|
795
|
+
const reader = new binary_encoding_js_1.BinaryReader(new binary_encoding_js_1.BinaryReader(uf.data).bytes());
|
|
796
|
+
while (reader.pos < reader.len) {
|
|
797
|
+
const [no, wireType] = reader.tag();
|
|
798
|
+
if (no === fieldNumber && wireType === binary_encoding_js_1.WireType.LengthDelimited) {
|
|
799
|
+
jsonName = reader.string();
|
|
800
|
+
}
|
|
801
|
+
else {
|
|
802
|
+
reader.skip(wireType, no);
|
|
803
|
+
}
|
|
804
|
+
}
|
|
805
|
+
}
|
|
806
|
+
return jsonName;
|
|
807
|
+
}
|
|
760
808
|
/**
|
|
761
809
|
* Converts lowerCamelCase or UpperCamelCase into lower_snake_case.
|
|
762
810
|
* This is used to find shared prefixes in an enum.
|
|
@@ -64,7 +64,7 @@ function enumToJson(descEnum, value) {
|
|
|
64
64
|
if (descEnum.typeName == "google.protobuf.NullValue") {
|
|
65
65
|
return null;
|
|
66
66
|
}
|
|
67
|
-
const name = (_a = descEnum.value[value]) === null || _a === void 0 ? void 0 : _a.
|
|
67
|
+
const name = (_a = descEnum.value[value]) === null || _a === void 0 ? void 0 : _a.jsonName;
|
|
68
68
|
if (name === undefined) {
|
|
69
69
|
throw new Error(`${value} is not a value in ${descEnum}`);
|
|
70
70
|
}
|
|
@@ -118,10 +118,32 @@ function compileMessage(desc) {
|
|
|
118
118
|
// resolve to this instance instead of compiling endlessly.
|
|
119
119
|
compiledWriters.set(desc, compiledWriter);
|
|
120
120
|
for (const field of sortedFields) {
|
|
121
|
-
|
|
121
|
+
const writeField = compileField(field);
|
|
122
|
+
// Both names a field can be written under are fixed by the schema, so we
|
|
123
|
+
// decide here, once, whether a field needs the wrapper. Ordinary fields
|
|
124
|
+
// get the plain writer, keeping the hot path free of any per-write check.
|
|
125
|
+
fieldWriters.push(field.jsonName === "__proto__" || field.name === "__proto__"
|
|
126
|
+
? writeOwnKeys(writeField)
|
|
127
|
+
: writeField);
|
|
122
128
|
}
|
|
123
129
|
return compiledWriter;
|
|
124
130
|
}
|
|
131
|
+
/**
|
|
132
|
+
* Wrap a field encoder so that a JSON name or proto name of "__proto__" ends
|
|
133
|
+
* up as an own property. Assigning that key on a plain object hits the
|
|
134
|
+
* inherited accessor instead, and the field is silently lost. The encoder
|
|
135
|
+
* writes to a null-prototype object, where the key is ordinary, and the
|
|
136
|
+
* result is copied to the real output with setOwn().
|
|
137
|
+
*/
|
|
138
|
+
function writeOwnKeys(writeField) {
|
|
139
|
+
return (opts, message, json) => {
|
|
140
|
+
const tmp = Object.create(null);
|
|
141
|
+
writeField(opts, message, tmp);
|
|
142
|
+
for (const key of Object.keys(tmp)) {
|
|
143
|
+
(0, unsafe_js_1.setOwn)(json, key, tmp[key]);
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
}
|
|
125
147
|
/**
|
|
126
148
|
* Compile an encoder for a well-known type with a custom JSON representation,
|
|
127
149
|
* or return undefined for other messages.
|
|
@@ -353,7 +375,7 @@ function compileMapValue(field) {
|
|
|
353
375
|
const jsonObject = {};
|
|
354
376
|
for (let i = 0; i < keys.length; i++) {
|
|
355
377
|
const key = keys[i];
|
|
356
|
-
jsonObject
|
|
378
|
+
(0, unsafe_js_1.setOwn)(jsonObject, key, writeMapValue(opts, record[key]));
|
|
357
379
|
}
|
|
358
380
|
return jsonObject;
|
|
359
381
|
};
|
|
@@ -390,7 +412,7 @@ function compileEnumValue(field) {
|
|
|
390
412
|
return value;
|
|
391
413
|
}
|
|
392
414
|
// If we don't know the enum value, just return the number.
|
|
393
|
-
return (_b = (_a = desc.value[value]) === null || _a === void 0 ? void 0 : _a.
|
|
415
|
+
return (_b = (_a = desc.value[value]) === null || _a === void 0 ? void 0 : _a.jsonName) !== null && _b !== void 0 ? _b : value;
|
|
394
416
|
};
|
|
395
417
|
}
|
|
396
418
|
function errorEnumValue(desc, value) {
|
|
@@ -569,7 +591,7 @@ function structToJson(val) {
|
|
|
569
591
|
const keys = Object.keys(val.fields);
|
|
570
592
|
for (let i = 0; i < keys.length; i++) {
|
|
571
593
|
const key = keys[i];
|
|
572
|
-
json
|
|
594
|
+
(0, unsafe_js_1.setOwn)(json, key, valueToJson(val.fields[key]));
|
|
573
595
|
}
|
|
574
596
|
return json;
|
|
575
597
|
}
|