@songtonyli/dsh-cli 0.1.98 → 0.1.100
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/@aws-sdk/core/dist-cjs/submodules/client/index.js +12 -0
- package/node_modules/@aws-sdk/core/dist-es/submodules/client/getDefaultSocketTimeout.js +10 -0
- package/node_modules/@aws-sdk/core/dist-es/submodules/client/index.browser.js +1 -0
- package/node_modules/@aws-sdk/core/dist-es/submodules/client/index.js +1 -0
- package/node_modules/@aws-sdk/core/dist-es/submodules/client/index.native.js +1 -0
- package/node_modules/@aws-sdk/core/package.json +1 -1
- package/node_modules/@aws-sdk/credential-provider-env/package.json +2 -2
- package/node_modules/@aws-sdk/credential-provider-http/package.json +2 -2
- package/node_modules/@aws-sdk/credential-provider-ini/package.json +9 -9
- package/node_modules/@aws-sdk/credential-provider-login/package.json +3 -3
- package/node_modules/@aws-sdk/credential-provider-node/package.json +7 -7
- package/node_modules/@aws-sdk/credential-provider-process/package.json +2 -2
- package/node_modules/@aws-sdk/credential-provider-sso/package.json +4 -4
- package/node_modules/@aws-sdk/credential-provider-web-identity/package.json +3 -3
- package/node_modules/@aws-sdk/middleware-websocket/package.json +2 -2
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/cognito-identity/index.js +3 -2
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/signin/index.js +3 -2
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sso/index.js +3 -2
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sso-oidc/index.js +3 -2
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sts/index.js +3 -2
- package/node_modules/@aws-sdk/nested-clients/dist-es/submodules/cognito-identity/runtimeConfig.js +2 -1
- package/node_modules/@aws-sdk/nested-clients/dist-es/submodules/signin/runtimeConfig.js +2 -1
- package/node_modules/@aws-sdk/nested-clients/dist-es/submodules/sso/runtimeConfig.js +2 -1
- package/node_modules/@aws-sdk/nested-clients/dist-es/submodules/sso-oidc/runtimeConfig.js +2 -1
- package/node_modules/@aws-sdk/nested-clients/dist-es/submodules/sts/runtimeConfig.js +2 -1
- package/node_modules/@aws-sdk/nested-clients/package.json +2 -2
- package/node_modules/@aws-sdk/token-providers/package.json +3 -3
- package/node_modules/@bufbuild/protobuf/dist/{commonjs → cjs}/codegenv2/boot.js +1 -1
- package/node_modules/@bufbuild/protobuf/dist/{commonjs → cjs}/codegenv2/file.js +1 -1
- package/node_modules/@bufbuild/protobuf/dist/{commonjs → cjs}/codegenv2/index.js +3 -0
- package/node_modules/@bufbuild/protobuf/dist/{commonjs → cjs}/from-binary.js +3 -1
- package/node_modules/@bufbuild/protobuf/dist/{commonjs → cjs}/index.js +7 -2
- package/node_modules/@bufbuild/protobuf/dist/cjs/package.json +1 -0
- package/node_modules/@bufbuild/protobuf/dist/{commonjs → cjs}/reflect/reflect.js +0 -1
- package/node_modules/@bufbuild/protobuf/dist/{commonjs → cjs}/registry.js +79 -10
- package/node_modules/@bufbuild/protobuf/dist/{commonjs → cjs}/to-json.js +1 -1
- package/node_modules/@bufbuild/protobuf/dist/{commonjs → cjs}/txtpb/to-text.js +4 -9
- package/node_modules/@bufbuild/protobuf/dist/{commonjs → cjs}/wire/binary-encoding.js +9 -5
- package/node_modules/@bufbuild/protobuf/dist/{commonjs → cjs}/wire/text-encoding.js +7 -3
- package/node_modules/@bufbuild/protobuf/dist/esm/codegenv2/boot.js +2 -2
- package/node_modules/@bufbuild/protobuf/dist/esm/codegenv2/file.js +2 -2
- package/node_modules/@bufbuild/protobuf/dist/esm/codegenv2/index.js +1 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/from-binary.js +3 -1
- package/node_modules/@bufbuild/protobuf/dist/esm/index.js +1 -1
- package/node_modules/@bufbuild/protobuf/dist/esm/reflect/reflect.js +0 -1
- package/node_modules/@bufbuild/protobuf/dist/esm/registry.js +77 -10
- package/node_modules/@bufbuild/protobuf/dist/esm/to-json.js +1 -1
- package/node_modules/@bufbuild/protobuf/dist/esm/txtpb/to-text.js +4 -9
- package/node_modules/@bufbuild/protobuf/dist/esm/wire/binary-encoding.js +9 -5
- package/node_modules/@bufbuild/protobuf/dist/esm/wire/text-encoding.js +7 -3
- package/node_modules/@bufbuild/protobuf/package.json +70 -267
- package/node_modules/@deepseek-ai/dsh-client-modules/lib/index.js +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 +4 -4
- package/node_modules/@deepseek-ai/dsh-tui-app/README.zh.md +4 -4
- package/node_modules/@deepseek-ai/dsh-tui-app/lib/index.js +507 -127
- package/node_modules/@eslint-community/regexpp/index.js +3 -3
- package/node_modules/@eslint-community/regexpp/index.mjs +3 -3
- package/node_modules/@eslint-community/regexpp/package.json +1 -1
- package/node_modules/@opentelemetry/semantic-conventions/dist/experimental_attributes.cjs +1461 -176
- package/node_modules/@opentelemetry/semantic-conventions/dist/experimental_attributes.mjs +1363 -171
- package/node_modules/@opentelemetry/semantic-conventions/dist/experimental_events.cjs +1 -1
- package/node_modules/@opentelemetry/semantic-conventions/dist/experimental_events.mjs +1 -1
- package/node_modules/@opentelemetry/semantic-conventions/dist/experimental_metrics.cjs +382 -95
- package/node_modules/@opentelemetry/semantic-conventions/dist/experimental_metrics.mjs +358 -94
- package/node_modules/@opentelemetry/semantic-conventions/dist/index-incubating.cjs +132 -8
- package/node_modules/@opentelemetry/semantic-conventions/dist/index-incubating.mjs +5 -5
- package/node_modules/@opentelemetry/semantic-conventions/dist/index.cjs +8 -0
- package/node_modules/@opentelemetry/semantic-conventions/dist/index.mjs +3 -3
- package/node_modules/@opentelemetry/semantic-conventions/dist/stable_attributes.cjs +104 -13
- package/node_modules/@opentelemetry/semantic-conventions/dist/stable_attributes.mjs +99 -14
- package/node_modules/@opentelemetry/semantic-conventions/dist/stable_metrics.cjs +16 -0
- package/node_modules/@opentelemetry/semantic-conventions/dist/stable_metrics.mjs +15 -1
- package/node_modules/@opentelemetry/semantic-conventions/package.json +2 -2
- package/node_modules/@smithy/core/dist-cjs/submodules/client/index.js +1 -0
- package/node_modules/@smithy/core/dist-cjs/submodules/retry/index.browser.js +33 -5
- package/node_modules/@smithy/core/dist-cjs/submodules/retry/index.js +33 -5
- package/node_modules/@smithy/core/dist-es/submodules/client/smithy-client/command.js +1 -0
- package/node_modules/@smithy/core/dist-es/submodules/retry/middleware-retry/retryMiddleware.js +11 -5
- package/node_modules/@smithy/core/dist-es/submodules/retry/util-retry/race.js +22 -0
- package/node_modules/@smithy/core/package.json +2 -2
- package/node_modules/@smithy/fetch-http-handler/dist-cjs/index.js +10 -4
- package/node_modules/@smithy/fetch-http-handler/dist-es/fetch-http-handler.js +6 -2
- package/node_modules/@smithy/fetch-http-handler/dist-es/request-timeout.js +4 -2
- package/node_modules/@smithy/fetch-http-handler/package.json +3 -3
- package/node_modules/@smithy/node-http-handler/dist-cjs/index.js +31 -31
- package/node_modules/@smithy/node-http-handler/dist-es/node-http-handler.js +2 -4
- package/node_modules/@smithy/node-http-handler/dist-es/set-socket-timeout.js +29 -27
- package/node_modules/@smithy/node-http-handler/package.json +3 -3
- package/node_modules/@smithy/types/package.json +1 -1
- package/node_modules/commander/Readme.md +6 -32
- package/node_modules/commander/index.js +1 -1
- package/node_modules/commander/lib/command.js +22 -9
- package/node_modules/commander/lib/help.js +6 -2
- package/node_modules/commander/lib/option.js +1 -1
- package/node_modules/commander/package.json +2 -1
- package/node_modules/jose/dist/webapi/jwe/general/decrypt.js +3 -2
- package/node_modules/jose/dist/webapi/jwks/remote.js +1 -1
- package/node_modules/jose/dist/webapi/jws/general/verify.js +2 -8
- package/node_modules/jose/dist/webapi/lib/jwe_decrypt.js +11 -8
- package/node_modules/jose/dist/webapi/lib/key_management.js +0 -1
- package/node_modules/jose/package.json +1 -1
- package/node_modules/vfile-message/lib/index.js +44 -14
- package/node_modules/vfile-message/package.json +6 -13
- package/node_modules/vfile-message/readme.md +9 -14
- package/package.json +23 -23
- package/node_modules/@bufbuild/protobuf/dist/commonjs/package.json +0 -4
- package/node_modules/@bufbuild/protobuf/dist/esm/package.json +0 -4
- /package/node_modules/@bufbuild/protobuf/dist/{commonjs → cjs}/clone.js +0 -0
- /package/node_modules/@bufbuild/protobuf/dist/{commonjs → cjs}/codegenv1/boot.js +0 -0
- /package/node_modules/@bufbuild/protobuf/dist/{commonjs → cjs}/codegenv1/enum.js +0 -0
- /package/node_modules/@bufbuild/protobuf/dist/{commonjs → cjs}/codegenv1/extension.js +0 -0
- /package/node_modules/@bufbuild/protobuf/dist/{commonjs → cjs}/codegenv1/file.js +0 -0
- /package/node_modules/@bufbuild/protobuf/dist/{commonjs → cjs}/codegenv1/index.js +0 -0
- /package/node_modules/@bufbuild/protobuf/dist/{commonjs → cjs}/codegenv1/message.js +0 -0
- /package/node_modules/@bufbuild/protobuf/dist/{commonjs → cjs}/codegenv1/service.js +0 -0
- /package/node_modules/@bufbuild/protobuf/dist/{commonjs → cjs}/codegenv1/symbols.js +0 -0
- /package/node_modules/@bufbuild/protobuf/dist/{commonjs → cjs}/codegenv1/types.js +0 -0
- /package/node_modules/@bufbuild/protobuf/dist/{commonjs → cjs}/codegenv2/embed.js +0 -0
- /package/node_modules/@bufbuild/protobuf/dist/{commonjs → cjs}/codegenv2/enum.js +0 -0
- /package/node_modules/@bufbuild/protobuf/dist/{commonjs → cjs}/codegenv2/extension.js +0 -0
- /package/node_modules/@bufbuild/protobuf/dist/{commonjs → cjs}/codegenv2/message.js +0 -0
- /package/node_modules/@bufbuild/protobuf/dist/{commonjs → cjs}/codegenv2/restore-json-names.js +0 -0
- /package/node_modules/@bufbuild/protobuf/dist/{commonjs → cjs}/codegenv2/scalar.js +0 -0
- /package/node_modules/@bufbuild/protobuf/dist/{commonjs → cjs}/codegenv2/service.js +0 -0
- /package/node_modules/@bufbuild/protobuf/dist/{commonjs → cjs}/codegenv2/symbols.js +0 -0
- /package/node_modules/@bufbuild/protobuf/dist/{commonjs → cjs}/codegenv2/types.js +0 -0
- /package/node_modules/@bufbuild/protobuf/dist/{commonjs → cjs}/create.js +0 -0
- /package/node_modules/@bufbuild/protobuf/dist/{commonjs → cjs}/descriptors.js +0 -0
- /package/node_modules/@bufbuild/protobuf/dist/{commonjs → cjs}/equals.js +0 -0
- /package/node_modules/@bufbuild/protobuf/dist/{commonjs → cjs}/extensions.js +0 -0
- /package/node_modules/@bufbuild/protobuf/dist/{commonjs → cjs}/fields.js +0 -0
- /package/node_modules/@bufbuild/protobuf/dist/{commonjs → cjs}/from-json.js +0 -0
- /package/node_modules/@bufbuild/protobuf/dist/{commonjs → cjs}/is-message.js +0 -0
- /package/node_modules/@bufbuild/protobuf/dist/{commonjs → cjs}/json-value.js +0 -0
- /package/node_modules/@bufbuild/protobuf/dist/{commonjs → cjs}/merge.js +0 -0
- /package/node_modules/@bufbuild/protobuf/dist/{commonjs → cjs}/proto-int64.js +0 -0
- /package/node_modules/@bufbuild/protobuf/dist/{commonjs → cjs}/reflect/error.js +0 -0
- /package/node_modules/@bufbuild/protobuf/dist/{commonjs → cjs}/reflect/guard.js +0 -0
- /package/node_modules/@bufbuild/protobuf/dist/{commonjs → cjs}/reflect/index.js +0 -0
- /package/node_modules/@bufbuild/protobuf/dist/{commonjs → cjs}/reflect/message.js +0 -0
- /package/node_modules/@bufbuild/protobuf/dist/{commonjs → cjs}/reflect/names.js +0 -0
- /package/node_modules/@bufbuild/protobuf/dist/{commonjs → cjs}/reflect/nested-types.js +0 -0
- /package/node_modules/@bufbuild/protobuf/dist/{commonjs → cjs}/reflect/path.js +0 -0
- /package/node_modules/@bufbuild/protobuf/dist/{commonjs → cjs}/reflect/reflect-check.js +0 -0
- /package/node_modules/@bufbuild/protobuf/dist/{commonjs → cjs}/reflect/reflect-types.js +0 -0
- /package/node_modules/@bufbuild/protobuf/dist/{commonjs → cjs}/reflect/scalar.js +0 -0
- /package/node_modules/@bufbuild/protobuf/dist/{commonjs → cjs}/reflect/unsafe.js +0 -0
- /package/node_modules/@bufbuild/protobuf/dist/{commonjs → cjs}/to-binary.js +0 -0
- /package/node_modules/@bufbuild/protobuf/dist/{commonjs → cjs}/txtpb/from-text.js +0 -0
- /package/node_modules/@bufbuild/protobuf/dist/{commonjs → cjs}/txtpb/index.js +0 -0
- /package/node_modules/@bufbuild/protobuf/dist/{commonjs → cjs}/txtpb/is-group-like.js +0 -0
- /package/node_modules/@bufbuild/protobuf/dist/{commonjs → cjs}/txtpb/reader.js +0 -0
- /package/node_modules/@bufbuild/protobuf/dist/{commonjs → cjs}/txtpb/writer.js +0 -0
- /package/node_modules/@bufbuild/protobuf/dist/{commonjs → cjs}/types.js +0 -0
- /package/node_modules/@bufbuild/protobuf/dist/{commonjs → cjs}/unknown-enum.js +0 -0
- /package/node_modules/@bufbuild/protobuf/dist/{commonjs → cjs}/wire/base64-encoding.js +0 -0
- /package/node_modules/@bufbuild/protobuf/dist/{commonjs → cjs}/wire/index.js +0 -0
- /package/node_modules/@bufbuild/protobuf/dist/{commonjs → cjs}/wire/size-delimited.js +0 -0
- /package/node_modules/@bufbuild/protobuf/dist/{commonjs → cjs}/wire/text-format.js +0 -0
- /package/node_modules/@bufbuild/protobuf/dist/{commonjs → cjs}/wire/varint.js +0 -0
- /package/node_modules/@bufbuild/protobuf/dist/{commonjs → cjs}/wkt/any.js +0 -0
- /package/node_modules/@bufbuild/protobuf/dist/{commonjs → cjs}/wkt/duration.js +0 -0
- /package/node_modules/@bufbuild/protobuf/dist/{commonjs → cjs}/wkt/google/protobuf/any_pb.js +0 -0
- /package/node_modules/@bufbuild/protobuf/dist/{commonjs → cjs}/wkt/google/protobuf/api_pb.js +0 -0
- /package/node_modules/@bufbuild/protobuf/dist/{commonjs → cjs}/wkt/google/protobuf/c_sharp_features_pb.js +0 -0
- /package/node_modules/@bufbuild/protobuf/dist/{commonjs → cjs}/wkt/google/protobuf/compiler/plugin_pb.js +0 -0
- /package/node_modules/@bufbuild/protobuf/dist/{commonjs → cjs}/wkt/google/protobuf/cpp_features_pb.js +0 -0
- /package/node_modules/@bufbuild/protobuf/dist/{commonjs → cjs}/wkt/google/protobuf/cpp_file_options_pb.js +0 -0
- /package/node_modules/@bufbuild/protobuf/dist/{commonjs → cjs}/wkt/google/protobuf/cpp_options_pb.js +0 -0
- /package/node_modules/@bufbuild/protobuf/dist/{commonjs → cjs}/wkt/google/protobuf/descriptor_pb.js +0 -0
- /package/node_modules/@bufbuild/protobuf/dist/{commonjs → cjs}/wkt/google/protobuf/duration_pb.js +0 -0
- /package/node_modules/@bufbuild/protobuf/dist/{commonjs → cjs}/wkt/google/protobuf/empty_pb.js +0 -0
- /package/node_modules/@bufbuild/protobuf/dist/{commonjs → cjs}/wkt/google/protobuf/field_mask_pb.js +0 -0
- /package/node_modules/@bufbuild/protobuf/dist/{commonjs → cjs}/wkt/google/protobuf/go_features_pb.js +0 -0
- /package/node_modules/@bufbuild/protobuf/dist/{commonjs → cjs}/wkt/google/protobuf/java_features_pb.js +0 -0
- /package/node_modules/@bufbuild/protobuf/dist/{commonjs → cjs}/wkt/google/protobuf/json_enumvalue_options_pb.js +0 -0
- /package/node_modules/@bufbuild/protobuf/dist/{commonjs → cjs}/wkt/google/protobuf/json_options_pb.js +0 -0
- /package/node_modules/@bufbuild/protobuf/dist/{commonjs → cjs}/wkt/google/protobuf/source_context_pb.js +0 -0
- /package/node_modules/@bufbuild/protobuf/dist/{commonjs → cjs}/wkt/google/protobuf/struct_pb.js +0 -0
- /package/node_modules/@bufbuild/protobuf/dist/{commonjs → cjs}/wkt/google/protobuf/timestamp_pb.js +0 -0
- /package/node_modules/@bufbuild/protobuf/dist/{commonjs → cjs}/wkt/google/protobuf/type_pb.js +0 -0
- /package/node_modules/@bufbuild/protobuf/dist/{commonjs → cjs}/wkt/google/protobuf/wrappers_pb.js +0 -0
- /package/node_modules/@bufbuild/protobuf/dist/{commonjs → cjs}/wkt/index.js +0 -0
- /package/node_modules/@bufbuild/protobuf/dist/{commonjs → cjs}/wkt/json.js +0 -0
- /package/node_modules/@bufbuild/protobuf/dist/{commonjs → cjs}/wkt/timestamp.js +0 -0
- /package/node_modules/@bufbuild/protobuf/dist/{commonjs → cjs}/wkt/wrappers.js +0 -0
|
@@ -86,7 +86,6 @@ class ReflectMessageImpl {
|
|
|
86
86
|
const value = (0, unsafe_js_1.unsafeGet)(this.message, field);
|
|
87
87
|
switch (field.fieldKind) {
|
|
88
88
|
case "list":
|
|
89
|
-
// eslint-disable-next-line no-case-declarations
|
|
90
89
|
let list = this.lists.get(field);
|
|
91
90
|
if (!list || list[unsafe_js_1.unsafeLocal] !== value) {
|
|
92
91
|
this.lists.set(field,
|
|
@@ -17,6 +17,8 @@ exports.maximumEdition = exports.minimumEdition = void 0;
|
|
|
17
17
|
exports.createRegistry = createRegistry;
|
|
18
18
|
exports.createMutableRegistry = createMutableRegistry;
|
|
19
19
|
exports.createFileRegistry = createFileRegistry;
|
|
20
|
+
exports.createEmbeddedFileRegistry = createEmbeddedFileRegistry;
|
|
21
|
+
exports.assertValidNames = assertValidNames;
|
|
20
22
|
const descriptors_js_1 = require("./descriptors.js");
|
|
21
23
|
const text_format_js_1 = require("./wire/text-format.js");
|
|
22
24
|
const nested_types_js_1 = require("./reflect/nested-types.js");
|
|
@@ -51,6 +53,22 @@ function createMutableRegistry(...input) {
|
|
|
51
53
|
} });
|
|
52
54
|
}
|
|
53
55
|
function createFileRegistry(...args) {
|
|
56
|
+
return buildFileRegistry(args, assertValidNames);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Create a registry from an embedded file descriptor without validating it.
|
|
60
|
+
* Embedded descriptors are validated when they are generated, so they are
|
|
61
|
+
* trusted at runtime.
|
|
62
|
+
*
|
|
63
|
+
* @private
|
|
64
|
+
*/
|
|
65
|
+
function createEmbeddedFileRegistry(fileDescriptorProto, resolve) {
|
|
66
|
+
return buildFileRegistry([fileDescriptorProto, resolve]);
|
|
67
|
+
}
|
|
68
|
+
function buildFileRegistry(args,
|
|
69
|
+
// A function rather than a boolean, so that bundles that only load embedded
|
|
70
|
+
// descriptors can tree-shake the validation code.
|
|
71
|
+
check) {
|
|
54
72
|
const registry = createBaseRegistry();
|
|
55
73
|
if (!args.length) {
|
|
56
74
|
return registry;
|
|
@@ -58,6 +76,7 @@ function createFileRegistry(...args) {
|
|
|
58
76
|
if ("$typeName" in args[0] &&
|
|
59
77
|
args[0].$typeName == "google.protobuf.FileDescriptorSet") {
|
|
60
78
|
for (const file of args[0].file) {
|
|
79
|
+
check === null || check === void 0 ? void 0 : check(file);
|
|
61
80
|
addFile(file, registry);
|
|
62
81
|
}
|
|
63
82
|
return registry;
|
|
@@ -90,6 +109,7 @@ function createFileRegistry(...args) {
|
|
|
90
109
|
return deps.concat(...deps.map(recurseDeps));
|
|
91
110
|
}
|
|
92
111
|
for (const file of [input, ...recurseDeps(input)].reverse()) {
|
|
112
|
+
check === null || check === void 0 ? void 0 : check(file);
|
|
93
113
|
addFile(file, registry);
|
|
94
114
|
}
|
|
95
115
|
}
|
|
@@ -102,6 +122,56 @@ function createFileRegistry(...args) {
|
|
|
102
122
|
}
|
|
103
123
|
return registry;
|
|
104
124
|
}
|
|
125
|
+
// Matches protoc's descriptor check, which allows a leading digit.
|
|
126
|
+
const identifierRe = /^[A-Za-z0-9_]+$/;
|
|
127
|
+
/**
|
|
128
|
+
* Throw an error if a name in the file is not a Protobuf identifier. Checks
|
|
129
|
+
* the names of messages, fields, oneofs, extensions, enums, enum values,
|
|
130
|
+
* services, and methods.
|
|
131
|
+
*
|
|
132
|
+
* Compilers reject anything else, but a descriptor can be crafted by hand, and
|
|
133
|
+
* code generators print these names, for example as identifiers.
|
|
134
|
+
*
|
|
135
|
+
* @private
|
|
136
|
+
*/
|
|
137
|
+
function assertValidNames(file) {
|
|
138
|
+
const check = (kind, name) => {
|
|
139
|
+
if (!identifierRe.test(name)) {
|
|
140
|
+
throw new Error(`${file.name}: invalid ${kind} name ${JSON.stringify(name)}`);
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
const checkEnum = (enumType) => {
|
|
144
|
+
check("enum", enumType.name);
|
|
145
|
+
for (const value of enumType.value) {
|
|
146
|
+
check("enum value", value.name);
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
const checkMessage = (message) => {
|
|
150
|
+
check("message", message.name);
|
|
151
|
+
for (const field of message.field) {
|
|
152
|
+
check("field", field.name);
|
|
153
|
+
}
|
|
154
|
+
for (const oneof of message.oneofDecl) {
|
|
155
|
+
check("oneof", oneof.name);
|
|
156
|
+
}
|
|
157
|
+
for (const extension of message.extension) {
|
|
158
|
+
check("extension", extension.name);
|
|
159
|
+
}
|
|
160
|
+
message.nestedType.forEach(checkMessage);
|
|
161
|
+
message.enumType.forEach(checkEnum);
|
|
162
|
+
};
|
|
163
|
+
file.messageType.forEach(checkMessage);
|
|
164
|
+
file.enumType.forEach(checkEnum);
|
|
165
|
+
for (const extension of file.extension) {
|
|
166
|
+
check("extension", extension.name);
|
|
167
|
+
}
|
|
168
|
+
for (const service of file.service) {
|
|
169
|
+
check("service", service.name);
|
|
170
|
+
for (const method of service.method) {
|
|
171
|
+
check("method", method.name);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
105
175
|
/**
|
|
106
176
|
* @private
|
|
107
177
|
*/
|
|
@@ -315,7 +385,6 @@ function addFile(proto, reg) {
|
|
|
315
385
|
extensions: [],
|
|
316
386
|
services: [],
|
|
317
387
|
toString() {
|
|
318
|
-
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions -- we asserted above
|
|
319
388
|
return `file ${proto.name}`;
|
|
320
389
|
},
|
|
321
390
|
};
|
|
@@ -411,7 +480,8 @@ function addFields(message, reg, mapEntries) {
|
|
|
411
480
|
* parent type, if any.
|
|
412
481
|
*/
|
|
413
482
|
function addEnum(proto, file, parent, reg) {
|
|
414
|
-
var _a, _b, _c, _d, _e, _f;
|
|
483
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
484
|
+
var _h, _j;
|
|
415
485
|
const sharedPrefix = findEnumSharedPrefix(proto.name, proto.value);
|
|
416
486
|
const desc = {
|
|
417
487
|
kind: "enum",
|
|
@@ -433,25 +503,24 @@ function addEnum(proto, file, parent, reg) {
|
|
|
433
503
|
reg.add(desc);
|
|
434
504
|
for (const p of proto.value) {
|
|
435
505
|
const name = p.name;
|
|
436
|
-
|
|
437
|
-
// biome-ignore lint/suspicious/noAssignInExpressions: no
|
|
438
|
-
(desc.value[p.number] = {
|
|
506
|
+
const value = {
|
|
439
507
|
kind: "enum_value",
|
|
440
508
|
proto: p,
|
|
441
509
|
deprecated: (_d = (_c = p.options) === null || _c === void 0 ? void 0 : _c.deprecated) !== null && _d !== void 0 ? _d : false,
|
|
442
510
|
parent: desc,
|
|
443
511
|
name,
|
|
444
|
-
localName: (0, names_js_1.safeObjectProperty)(sharedPrefix == undefined
|
|
445
|
-
? name
|
|
446
|
-
: name.substring(sharedPrefix.length)),
|
|
512
|
+
localName: (0, names_js_1.safeObjectProperty)(sharedPrefix == undefined ? name : name.substring(sharedPrefix.length)),
|
|
447
513
|
number: p.number,
|
|
448
514
|
jsonName: (_e = findEnumValueJsonName(p)) !== null && _e !== void 0 ? _e : name,
|
|
449
515
|
toString() {
|
|
450
516
|
return `enum value ${desc.typeName}.${name}`;
|
|
451
517
|
},
|
|
452
|
-
}
|
|
518
|
+
};
|
|
519
|
+
desc.values.push(value);
|
|
520
|
+
// Preserve the first declared name for aliased enum values.
|
|
521
|
+
(_f = (_h = desc.value)[_j = p.number]) !== null && _f !== void 0 ? _f : (_h[_j] = value);
|
|
453
522
|
}
|
|
454
|
-
((
|
|
523
|
+
((_g = parent === null || parent === void 0 ? void 0 : parent.nestedEnums) !== null && _g !== void 0 ? _g : file.enums).push(desc);
|
|
455
524
|
}
|
|
456
525
|
/**
|
|
457
526
|
* Create a descriptor for a message, including nested types, and add it to our
|
|
@@ -628,7 +628,7 @@ function timestampToJson(val) {
|
|
|
628
628
|
throw new Error(`cannot encode message ${val.$typeName} to JSON: nanos must not be negative`);
|
|
629
629
|
}
|
|
630
630
|
if (val.nanos > 999999999) {
|
|
631
|
-
throw new Error(`cannot encode message ${val.$typeName} to JSON: nanos must not be greater than
|
|
631
|
+
throw new Error(`cannot encode message ${val.$typeName} to JSON: nanos must not be greater than 999999999`);
|
|
632
632
|
}
|
|
633
633
|
let z = "Z";
|
|
634
634
|
if (val.nanos > 0) {
|
|
@@ -315,15 +315,10 @@ function scalarToText(type, value) {
|
|
|
315
315
|
}
|
|
316
316
|
}
|
|
317
317
|
function enumToText(descEnum, value) {
|
|
318
|
-
|
|
319
|
-
//
|
|
320
|
-
// unknown value prints as a decimal.
|
|
321
|
-
|
|
322
|
-
if (v.number === value) {
|
|
323
|
-
return v.name;
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
return value.toString();
|
|
318
|
+
var _a, _b;
|
|
319
|
+
// The by-number record holds the first-declared alias, matching protobuf-go.
|
|
320
|
+
// An unknown value prints as a decimal.
|
|
321
|
+
return ((_b = (_a = descEnum.value[value]) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : value.toString());
|
|
327
322
|
}
|
|
328
323
|
function floatToText(value, single) {
|
|
329
324
|
// Round to 32-bit precision first so an overflow becomes inf (not the JS
|
|
@@ -658,21 +658,25 @@ class BinaryReader {
|
|
|
658
658
|
* `strict` is true, throw on invalid UTF-8 instead of substituting U+FFFD.
|
|
659
659
|
*/
|
|
660
660
|
string(strict) {
|
|
661
|
-
|
|
662
|
-
const len =
|
|
661
|
+
// Like bytes(), but the ASCII fast path reads the buffer without a view.
|
|
662
|
+
const len = this.uint32();
|
|
663
|
+
const start = this.pos;
|
|
664
|
+
this.pos += len;
|
|
665
|
+
this.assertBounds();
|
|
666
|
+
const buf = this.buf;
|
|
663
667
|
// Fast path for ASCII.
|
|
664
668
|
if (len <= ASCII_MAX_LENGTH) {
|
|
665
669
|
const codes = new Array(len);
|
|
666
670
|
for (let i = 0; i < len; i++) {
|
|
667
|
-
const byte =
|
|
671
|
+
const byte = buf[start + i];
|
|
668
672
|
if (byte > 0x7f) {
|
|
669
|
-
return this.decodeUtf8(
|
|
673
|
+
return this.decodeUtf8(buf.subarray(start, this.pos), strict);
|
|
670
674
|
}
|
|
671
675
|
codes[i] = byte;
|
|
672
676
|
}
|
|
673
677
|
return String.fromCharCode.apply(String, codes);
|
|
674
678
|
}
|
|
675
|
-
return this.decodeUtf8(
|
|
679
|
+
return this.decodeUtf8(buf.subarray(start, this.pos), strict);
|
|
676
680
|
}
|
|
677
681
|
}
|
|
678
682
|
exports.BinaryReader = BinaryReader;
|
|
@@ -26,8 +26,8 @@ let te;
|
|
|
26
26
|
* It only configures the copy of the library it is imported from. To provide
|
|
27
27
|
* the encoding API for every copy of Protobuf-ES in an isolate, install
|
|
28
28
|
* `TextEncoder` (with the methods `encode` and optionally `encodeInto`) and
|
|
29
|
-
* `TextDecoder` (with the `fatal: true`
|
|
30
|
-
* method) on `globalThis`.
|
|
29
|
+
* `TextDecoder` (with the `fatal: true` and `ignoreBOM: true` constructor
|
|
30
|
+
* arguments and the `decode` method) on `globalThis`.
|
|
31
31
|
*
|
|
32
32
|
* Providing `encodeUtf8Into` is optional for backwards compatibility. If it
|
|
33
33
|
* is omitted, we emulate it with a wrapper that calls `encodeUtf8`.
|
|
@@ -49,7 +49,10 @@ function getTextEncoding() {
|
|
|
49
49
|
throw new Error("encoding API missing: install TextEncoder and TextDecoder on globalThis");
|
|
50
50
|
}
|
|
51
51
|
const textEncoder = new globals.TextEncoder();
|
|
52
|
-
|
|
52
|
+
// A leading U+FEFF in a protobuf string is text, not a byte-order mark.
|
|
53
|
+
const textDecoder = new globals.TextDecoder("utf-8", {
|
|
54
|
+
ignoreBOM: true,
|
|
55
|
+
});
|
|
53
56
|
let textDecoderStrict;
|
|
54
57
|
const config = {
|
|
55
58
|
encodeUtf8(text) {
|
|
@@ -60,6 +63,7 @@ function getTextEncoding() {
|
|
|
60
63
|
if (!textDecoderStrict) {
|
|
61
64
|
textDecoderStrict = new globals.TextDecoder("utf-8", {
|
|
62
65
|
fatal: true,
|
|
66
|
+
ignoreBOM: true,
|
|
63
67
|
});
|
|
64
68
|
}
|
|
65
69
|
return textDecoderStrict.decode(bytes);
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
// See the License for the specific language governing permissions and
|
|
13
13
|
// limitations under the License.
|
|
14
14
|
import { restoreJsonNames } from "./restore-json-names.js";
|
|
15
|
-
import {
|
|
15
|
+
import { createEmbeddedFileRegistry } from "../registry.js";
|
|
16
16
|
/**
|
|
17
17
|
* Hydrate a file descriptor for google/protobuf/descriptor.proto from a plain
|
|
18
18
|
* object.
|
|
@@ -24,7 +24,7 @@ import { createFileRegistry } from "../registry.js";
|
|
|
24
24
|
export function boot(boot) {
|
|
25
25
|
const root = bootFileDescriptorProto(boot);
|
|
26
26
|
root.messageType.forEach(restoreJsonNames);
|
|
27
|
-
const reg =
|
|
27
|
+
const reg = createEmbeddedFileRegistry(root, () => undefined);
|
|
28
28
|
// biome-ignore lint/style/noNonNullAssertion: non-null assertion because we just created the registry from the file we look up
|
|
29
29
|
return reg.getFile(root.name);
|
|
30
30
|
}
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
// limitations under the License.
|
|
14
14
|
import { base64Decode } from "../wire/base64-encoding.js";
|
|
15
15
|
import { FileDescriptorProtoSchema } from "../wkt/google/protobuf/descriptor_pb.js";
|
|
16
|
-
import {
|
|
16
|
+
import { createEmbeddedFileRegistry } from "../registry.js";
|
|
17
17
|
import { restoreJsonNames } from "./restore-json-names.js";
|
|
18
18
|
import { fromBinary } from "../from-binary.js";
|
|
19
19
|
/**
|
|
@@ -26,7 +26,7 @@ export function fileDesc(b64, imports) {
|
|
|
26
26
|
const root = fromBinary(FileDescriptorProtoSchema, base64Decode(b64));
|
|
27
27
|
root.messageType.forEach(restoreJsonNames);
|
|
28
28
|
root.dependency = (_a = imports === null || imports === void 0 ? void 0 : imports.map((f) => f.proto.name)) !== null && _a !== void 0 ? _a : [];
|
|
29
|
-
const reg =
|
|
29
|
+
const reg = createEmbeddedFileRegistry(root, (protoFileName) => imports === null || imports === void 0 ? void 0 : imports.find((f) => f.proto.name === protoFileName));
|
|
30
30
|
// biome-ignore lint/style/noNonNullAssertion: non-null assertion because we just created the registry from the file we look up
|
|
31
31
|
return reg.getFile(root.name);
|
|
32
32
|
}
|
|
@@ -334,7 +334,7 @@ function compileMapFieldReader(field) {
|
|
|
334
334
|
const end = reader.pos + len;
|
|
335
335
|
while (reader.pos < end) {
|
|
336
336
|
// Map entries have the key in field 1, and the value in field 2.
|
|
337
|
-
const [fieldNo] = reader.tag();
|
|
337
|
+
const [fieldNo, wireType] = reader.tag();
|
|
338
338
|
switch (fieldNo) {
|
|
339
339
|
case 1:
|
|
340
340
|
key = readKey(reader);
|
|
@@ -342,6 +342,8 @@ function compileMapFieldReader(field) {
|
|
|
342
342
|
case 2:
|
|
343
343
|
val = readValue(reader, ctx, val);
|
|
344
344
|
break;
|
|
345
|
+
default:
|
|
346
|
+
reader.skip(wireType, fieldNo, ctx.recursionLimit - ctx.depth);
|
|
345
347
|
}
|
|
346
348
|
}
|
|
347
349
|
if (key === undefined) {
|
|
@@ -18,7 +18,7 @@ export * from "./clone.js";
|
|
|
18
18
|
export * from "./descriptors.js";
|
|
19
19
|
export * from "./equals.js";
|
|
20
20
|
export * from "./fields.js";
|
|
21
|
-
export
|
|
21
|
+
export { createRegistry, createMutableRegistry, createFileRegistry, minimumEdition, maximumEdition, } from "./registry.js";
|
|
22
22
|
export { toBinary } from "./to-binary.js";
|
|
23
23
|
export { fromBinary, mergeFromBinary } from "./from-binary.js";
|
|
24
24
|
export * from "./to-json.js";
|
|
@@ -81,7 +81,6 @@ class ReflectMessageImpl {
|
|
|
81
81
|
const value = unsafeGet(this.message, field);
|
|
82
82
|
switch (field.fieldKind) {
|
|
83
83
|
case "list":
|
|
84
|
-
// eslint-disable-next-line no-case-declarations
|
|
85
84
|
let list = this.lists.get(field);
|
|
86
85
|
if (!list || list[unsafeLocal] !== value) {
|
|
87
86
|
this.lists.set(field,
|
|
@@ -45,6 +45,22 @@ export function createMutableRegistry(...input) {
|
|
|
45
45
|
} });
|
|
46
46
|
}
|
|
47
47
|
export function createFileRegistry(...args) {
|
|
48
|
+
return buildFileRegistry(args, assertValidNames);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Create a registry from an embedded file descriptor without validating it.
|
|
52
|
+
* Embedded descriptors are validated when they are generated, so they are
|
|
53
|
+
* trusted at runtime.
|
|
54
|
+
*
|
|
55
|
+
* @private
|
|
56
|
+
*/
|
|
57
|
+
export function createEmbeddedFileRegistry(fileDescriptorProto, resolve) {
|
|
58
|
+
return buildFileRegistry([fileDescriptorProto, resolve]);
|
|
59
|
+
}
|
|
60
|
+
function buildFileRegistry(args,
|
|
61
|
+
// A function rather than a boolean, so that bundles that only load embedded
|
|
62
|
+
// descriptors can tree-shake the validation code.
|
|
63
|
+
check) {
|
|
48
64
|
const registry = createBaseRegistry();
|
|
49
65
|
if (!args.length) {
|
|
50
66
|
return registry;
|
|
@@ -52,6 +68,7 @@ export function createFileRegistry(...args) {
|
|
|
52
68
|
if ("$typeName" in args[0] &&
|
|
53
69
|
args[0].$typeName == "google.protobuf.FileDescriptorSet") {
|
|
54
70
|
for (const file of args[0].file) {
|
|
71
|
+
check === null || check === void 0 ? void 0 : check(file);
|
|
55
72
|
addFile(file, registry);
|
|
56
73
|
}
|
|
57
74
|
return registry;
|
|
@@ -84,6 +101,7 @@ export function createFileRegistry(...args) {
|
|
|
84
101
|
return deps.concat(...deps.map(recurseDeps));
|
|
85
102
|
}
|
|
86
103
|
for (const file of [input, ...recurseDeps(input)].reverse()) {
|
|
104
|
+
check === null || check === void 0 ? void 0 : check(file);
|
|
87
105
|
addFile(file, registry);
|
|
88
106
|
}
|
|
89
107
|
}
|
|
@@ -96,6 +114,56 @@ export function createFileRegistry(...args) {
|
|
|
96
114
|
}
|
|
97
115
|
return registry;
|
|
98
116
|
}
|
|
117
|
+
// Matches protoc's descriptor check, which allows a leading digit.
|
|
118
|
+
const identifierRe = /^[A-Za-z0-9_]+$/;
|
|
119
|
+
/**
|
|
120
|
+
* Throw an error if a name in the file is not a Protobuf identifier. Checks
|
|
121
|
+
* the names of messages, fields, oneofs, extensions, enums, enum values,
|
|
122
|
+
* services, and methods.
|
|
123
|
+
*
|
|
124
|
+
* Compilers reject anything else, but a descriptor can be crafted by hand, and
|
|
125
|
+
* code generators print these names, for example as identifiers.
|
|
126
|
+
*
|
|
127
|
+
* @private
|
|
128
|
+
*/
|
|
129
|
+
export function assertValidNames(file) {
|
|
130
|
+
const check = (kind, name) => {
|
|
131
|
+
if (!identifierRe.test(name)) {
|
|
132
|
+
throw new Error(`${file.name}: invalid ${kind} name ${JSON.stringify(name)}`);
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
const checkEnum = (enumType) => {
|
|
136
|
+
check("enum", enumType.name);
|
|
137
|
+
for (const value of enumType.value) {
|
|
138
|
+
check("enum value", value.name);
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
const checkMessage = (message) => {
|
|
142
|
+
check("message", message.name);
|
|
143
|
+
for (const field of message.field) {
|
|
144
|
+
check("field", field.name);
|
|
145
|
+
}
|
|
146
|
+
for (const oneof of message.oneofDecl) {
|
|
147
|
+
check("oneof", oneof.name);
|
|
148
|
+
}
|
|
149
|
+
for (const extension of message.extension) {
|
|
150
|
+
check("extension", extension.name);
|
|
151
|
+
}
|
|
152
|
+
message.nestedType.forEach(checkMessage);
|
|
153
|
+
message.enumType.forEach(checkEnum);
|
|
154
|
+
};
|
|
155
|
+
file.messageType.forEach(checkMessage);
|
|
156
|
+
file.enumType.forEach(checkEnum);
|
|
157
|
+
for (const extension of file.extension) {
|
|
158
|
+
check("extension", extension.name);
|
|
159
|
+
}
|
|
160
|
+
for (const service of file.service) {
|
|
161
|
+
check("service", service.name);
|
|
162
|
+
for (const method of service.method) {
|
|
163
|
+
check("method", method.name);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
99
167
|
/**
|
|
100
168
|
* @private
|
|
101
169
|
*/
|
|
@@ -309,7 +377,6 @@ function addFile(proto, reg) {
|
|
|
309
377
|
extensions: [],
|
|
310
378
|
services: [],
|
|
311
379
|
toString() {
|
|
312
|
-
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions -- we asserted above
|
|
313
380
|
return `file ${proto.name}`;
|
|
314
381
|
},
|
|
315
382
|
};
|
|
@@ -405,7 +472,8 @@ function addFields(message, reg, mapEntries) {
|
|
|
405
472
|
* parent type, if any.
|
|
406
473
|
*/
|
|
407
474
|
function addEnum(proto, file, parent, reg) {
|
|
408
|
-
var _a, _b, _c, _d, _e, _f;
|
|
475
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
476
|
+
var _h, _j;
|
|
409
477
|
const sharedPrefix = findEnumSharedPrefix(proto.name, proto.value);
|
|
410
478
|
const desc = {
|
|
411
479
|
kind: "enum",
|
|
@@ -427,25 +495,24 @@ function addEnum(proto, file, parent, reg) {
|
|
|
427
495
|
reg.add(desc);
|
|
428
496
|
for (const p of proto.value) {
|
|
429
497
|
const name = p.name;
|
|
430
|
-
|
|
431
|
-
// biome-ignore lint/suspicious/noAssignInExpressions: no
|
|
432
|
-
(desc.value[p.number] = {
|
|
498
|
+
const value = {
|
|
433
499
|
kind: "enum_value",
|
|
434
500
|
proto: p,
|
|
435
501
|
deprecated: (_d = (_c = p.options) === null || _c === void 0 ? void 0 : _c.deprecated) !== null && _d !== void 0 ? _d : false,
|
|
436
502
|
parent: desc,
|
|
437
503
|
name,
|
|
438
|
-
localName: safeObjectProperty(sharedPrefix == undefined
|
|
439
|
-
? name
|
|
440
|
-
: name.substring(sharedPrefix.length)),
|
|
504
|
+
localName: safeObjectProperty(sharedPrefix == undefined ? name : name.substring(sharedPrefix.length)),
|
|
441
505
|
number: p.number,
|
|
442
506
|
jsonName: (_e = findEnumValueJsonName(p)) !== null && _e !== void 0 ? _e : name,
|
|
443
507
|
toString() {
|
|
444
508
|
return `enum value ${desc.typeName}.${name}`;
|
|
445
509
|
},
|
|
446
|
-
}
|
|
510
|
+
};
|
|
511
|
+
desc.values.push(value);
|
|
512
|
+
// Preserve the first declared name for aliased enum values.
|
|
513
|
+
(_f = (_h = desc.value)[_j = p.number]) !== null && _f !== void 0 ? _f : (_h[_j] = value);
|
|
447
514
|
}
|
|
448
|
-
((
|
|
515
|
+
((_g = parent === null || parent === void 0 ? void 0 : parent.nestedEnums) !== null && _g !== void 0 ? _g : file.enums).push(desc);
|
|
449
516
|
}
|
|
450
517
|
/**
|
|
451
518
|
* Create a descriptor for a message, including nested types, and add it to our
|
|
@@ -623,7 +623,7 @@ function timestampToJson(val) {
|
|
|
623
623
|
throw new Error(`cannot encode message ${val.$typeName} to JSON: nanos must not be negative`);
|
|
624
624
|
}
|
|
625
625
|
if (val.nanos > 999999999) {
|
|
626
|
-
throw new Error(`cannot encode message ${val.$typeName} to JSON: nanos must not be greater than
|
|
626
|
+
throw new Error(`cannot encode message ${val.$typeName} to JSON: nanos must not be greater than 999999999`);
|
|
627
627
|
}
|
|
628
628
|
let z = "Z";
|
|
629
629
|
if (val.nanos > 0) {
|
|
@@ -312,15 +312,10 @@ function scalarToText(type, value) {
|
|
|
312
312
|
}
|
|
313
313
|
}
|
|
314
314
|
function enumToText(descEnum, value) {
|
|
315
|
-
|
|
316
|
-
//
|
|
317
|
-
// unknown value prints as a decimal.
|
|
318
|
-
|
|
319
|
-
if (v.number === value) {
|
|
320
|
-
return v.name;
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
return value.toString();
|
|
315
|
+
var _a, _b;
|
|
316
|
+
// The by-number record holds the first-declared alias, matching protobuf-go.
|
|
317
|
+
// An unknown value prints as a decimal.
|
|
318
|
+
return ((_b = (_a = descEnum.value[value]) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : value.toString());
|
|
324
319
|
}
|
|
325
320
|
function floatToText(value, single) {
|
|
326
321
|
// Round to 32-bit precision first so an overflow becomes inf (not the JS
|
|
@@ -654,21 +654,25 @@ export class BinaryReader {
|
|
|
654
654
|
* `strict` is true, throw on invalid UTF-8 instead of substituting U+FFFD.
|
|
655
655
|
*/
|
|
656
656
|
string(strict) {
|
|
657
|
-
|
|
658
|
-
const len =
|
|
657
|
+
// Like bytes(), but the ASCII fast path reads the buffer without a view.
|
|
658
|
+
const len = this.uint32();
|
|
659
|
+
const start = this.pos;
|
|
660
|
+
this.pos += len;
|
|
661
|
+
this.assertBounds();
|
|
662
|
+
const buf = this.buf;
|
|
659
663
|
// Fast path for ASCII.
|
|
660
664
|
if (len <= ASCII_MAX_LENGTH) {
|
|
661
665
|
const codes = new Array(len);
|
|
662
666
|
for (let i = 0; i < len; i++) {
|
|
663
|
-
const byte =
|
|
667
|
+
const byte = buf[start + i];
|
|
664
668
|
if (byte > 0x7f) {
|
|
665
|
-
return this.decodeUtf8(
|
|
669
|
+
return this.decodeUtf8(buf.subarray(start, this.pos), strict);
|
|
666
670
|
}
|
|
667
671
|
codes[i] = byte;
|
|
668
672
|
}
|
|
669
673
|
return String.fromCharCode.apply(String, codes);
|
|
670
674
|
}
|
|
671
|
-
return this.decodeUtf8(
|
|
675
|
+
return this.decodeUtf8(buf.subarray(start, this.pos), strict);
|
|
672
676
|
}
|
|
673
677
|
}
|
|
674
678
|
/**
|
|
@@ -21,8 +21,8 @@ let te;
|
|
|
21
21
|
* It only configures the copy of the library it is imported from. To provide
|
|
22
22
|
* the encoding API for every copy of Protobuf-ES in an isolate, install
|
|
23
23
|
* `TextEncoder` (with the methods `encode` and optionally `encodeInto`) and
|
|
24
|
-
* `TextDecoder` (with the `fatal: true`
|
|
25
|
-
* method) on `globalThis`.
|
|
24
|
+
* `TextDecoder` (with the `fatal: true` and `ignoreBOM: true` constructor
|
|
25
|
+
* arguments and the `decode` method) on `globalThis`.
|
|
26
26
|
*
|
|
27
27
|
* Providing `encodeUtf8Into` is optional for backwards compatibility. If it
|
|
28
28
|
* is omitted, we emulate it with a wrapper that calls `encodeUtf8`.
|
|
@@ -44,7 +44,10 @@ export function getTextEncoding() {
|
|
|
44
44
|
throw new Error("encoding API missing: install TextEncoder and TextDecoder on globalThis");
|
|
45
45
|
}
|
|
46
46
|
const textEncoder = new globals.TextEncoder();
|
|
47
|
-
|
|
47
|
+
// A leading U+FEFF in a protobuf string is text, not a byte-order mark.
|
|
48
|
+
const textDecoder = new globals.TextDecoder("utf-8", {
|
|
49
|
+
ignoreBOM: true,
|
|
50
|
+
});
|
|
48
51
|
let textDecoderStrict;
|
|
49
52
|
const config = {
|
|
50
53
|
encodeUtf8(text) {
|
|
@@ -55,6 +58,7 @@ export function getTextEncoding() {
|
|
|
55
58
|
if (!textDecoderStrict) {
|
|
56
59
|
textDecoderStrict = new globals.TextDecoder("utf-8", {
|
|
57
60
|
fatal: true,
|
|
61
|
+
ignoreBOM: true,
|
|
58
62
|
});
|
|
59
63
|
}
|
|
60
64
|
return textDecoderStrict.decode(bytes);
|