@songtonyli/dsh-cli 0.1.32 → 0.1.34

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (190) hide show
  1. package/README.md +1 -1
  2. package/bin/dsh.mjs +1 -1
  3. package/node_modules/@bufbuild/protobuf/README.md +41 -0
  4. package/node_modules/@bufbuild/protobuf/dist/commonjs/clone.js +66 -0
  5. package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv1/boot.js +18 -0
  6. package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv1/enum.js +31 -0
  7. package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv1/extension.js +28 -0
  8. package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv1/file.js +18 -0
  9. package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv1/index.js +39 -0
  10. package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv1/message.js +24 -0
  11. package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv1/service.js +27 -0
  12. package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv1/symbols.js +43 -0
  13. package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv1/types.js +15 -0
  14. package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv2/boot.js +105 -0
  15. package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv2/embed.js +244 -0
  16. package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv2/enum.js +58 -0
  17. package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv2/extension.js +28 -0
  18. package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv2/file.js +35 -0
  19. package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv2/index.js +39 -0
  20. package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv2/message.js +24 -0
  21. package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv2/restore-json-names.js +29 -0
  22. package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv2/scalar.js +67 -0
  23. package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv2/service.js +27 -0
  24. package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv2/symbols.js +74 -0
  25. package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv2/types.js +15 -0
  26. package/node_modules/@bufbuild/protobuf/dist/commonjs/create.js +296 -0
  27. package/node_modules/@bufbuild/protobuf/dist/commonjs/descriptors.js +53 -0
  28. package/node_modules/@bufbuild/protobuf/dist/commonjs/equals.js +209 -0
  29. package/node_modules/@bufbuild/protobuf/dist/commonjs/extensions.js +168 -0
  30. package/node_modules/@bufbuild/protobuf/dist/commonjs/fields.js +45 -0
  31. package/node_modules/@bufbuild/protobuf/dist/commonjs/from-binary.js +415 -0
  32. package/node_modules/@bufbuild/protobuf/dist/commonjs/from-json.js +1037 -0
  33. package/node_modules/@bufbuild/protobuf/dist/commonjs/index.js +55 -0
  34. package/node_modules/@bufbuild/protobuf/dist/commonjs/is-message.js +33 -0
  35. package/node_modules/@bufbuild/protobuf/dist/commonjs/json-value.js +15 -0
  36. package/node_modules/@bufbuild/protobuf/dist/commonjs/merge.js +70 -0
  37. package/node_modules/@bufbuild/protobuf/dist/commonjs/package.json +4 -0
  38. package/node_modules/@bufbuild/protobuf/dist/commonjs/proto-int64.js +131 -0
  39. package/node_modules/@bufbuild/protobuf/dist/commonjs/reflect/error.js +36 -0
  40. package/node_modules/@bufbuild/protobuf/dist/commonjs/reflect/guard.js +78 -0
  41. package/node_modules/@bufbuild/protobuf/dist/commonjs/reflect/index.js +41 -0
  42. package/node_modules/@bufbuild/protobuf/dist/commonjs/reflect/message.js +157 -0
  43. package/node_modules/@bufbuild/protobuf/dist/commonjs/reflect/names.js +115 -0
  44. package/node_modules/@bufbuild/protobuf/dist/commonjs/reflect/nested-types.js +110 -0
  45. package/node_modules/@bufbuild/protobuf/dist/commonjs/reflect/path.js +376 -0
  46. package/node_modules/@bufbuild/protobuf/dist/commonjs/reflect/reflect-check.js +292 -0
  47. package/node_modules/@bufbuild/protobuf/dist/commonjs/reflect/reflect-types.js +16 -0
  48. package/node_modules/@bufbuild/protobuf/dist/commonjs/reflect/reflect.js +469 -0
  49. package/node_modules/@bufbuild/protobuf/dist/commonjs/reflect/scalar.js +129 -0
  50. package/node_modules/@bufbuild/protobuf/dist/commonjs/reflect/unsafe.js +149 -0
  51. package/node_modules/@bufbuild/protobuf/dist/commonjs/registry.js +954 -0
  52. package/node_modules/@bufbuild/protobuf/dist/commonjs/to-binary.js +437 -0
  53. package/node_modules/@bufbuild/protobuf/dist/commonjs/to-json.js +625 -0
  54. package/node_modules/@bufbuild/protobuf/dist/commonjs/txtpb/from-text.js +684 -0
  55. package/node_modules/@bufbuild/protobuf/dist/commonjs/txtpb/index.js +21 -0
  56. package/node_modules/@bufbuild/protobuf/dist/commonjs/txtpb/is-group-like.js +47 -0
  57. package/node_modules/@bufbuild/protobuf/dist/commonjs/txtpb/reader.js +481 -0
  58. package/node_modules/@bufbuild/protobuf/dist/commonjs/txtpb/to-text.js +358 -0
  59. package/node_modules/@bufbuild/protobuf/dist/commonjs/txtpb/writer.js +220 -0
  60. package/node_modules/@bufbuild/protobuf/dist/commonjs/types.js +15 -0
  61. package/node_modules/@bufbuild/protobuf/dist/commonjs/unknown-enum.js +26 -0
  62. package/node_modules/@bufbuild/protobuf/dist/commonjs/wire/base64-encoding.js +188 -0
  63. package/node_modules/@bufbuild/protobuf/dist/commonjs/wire/binary-encoding.js +726 -0
  64. package/node_modules/@bufbuild/protobuf/dist/commonjs/wire/index.js +37 -0
  65. package/node_modules/@bufbuild/protobuf/dist/commonjs/wire/size-delimited.js +191 -0
  66. package/node_modules/@bufbuild/protobuf/dist/commonjs/wire/text-encoding.js +106 -0
  67. package/node_modules/@bufbuild/protobuf/dist/commonjs/wire/text-format.js +199 -0
  68. package/node_modules/@bufbuild/protobuf/dist/commonjs/wire/varint.js +334 -0
  69. package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/any.js +75 -0
  70. package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/duration.js +39 -0
  71. package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/gen/google/protobuf/any_pb.js +27 -0
  72. package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/gen/google/protobuf/api_pb.js +39 -0
  73. package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/gen/google/protobuf/compiler/plugin_pb.js +68 -0
  74. package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/gen/google/protobuf/cpp_features_pb.js +60 -0
  75. package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/gen/google/protobuf/descriptor_pb.js +892 -0
  76. package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/gen/google/protobuf/duration_pb.js +27 -0
  77. package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/gen/google/protobuf/empty_pb.js +27 -0
  78. package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/gen/google/protobuf/field_mask_pb.js +27 -0
  79. package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/gen/google/protobuf/go_features_pb.js +126 -0
  80. package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/gen/google/protobuf/java_features_pb.js +106 -0
  81. package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/gen/google/protobuf/source_context_pb.js +27 -0
  82. package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/gen/google/protobuf/struct_pb.js +59 -0
  83. package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/gen/google/protobuf/timestamp_pb.js +27 -0
  84. package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/gen/google/protobuf/type_pb.js +242 -0
  85. package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/gen/google/protobuf/wrappers_pb.js +67 -0
  86. package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/index.js +48 -0
  87. package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/json.js +44 -0
  88. package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/timestamp.js +57 -0
  89. package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/wrappers.js +66 -0
  90. package/node_modules/@bufbuild/protobuf/dist/esm/clone.js +63 -0
  91. package/node_modules/@bufbuild/protobuf/dist/esm/codegenv1/boot.js +14 -0
  92. package/node_modules/@bufbuild/protobuf/dist/esm/codegenv1/enum.js +26 -0
  93. package/node_modules/@bufbuild/protobuf/dist/esm/codegenv1/extension.js +25 -0
  94. package/node_modules/@bufbuild/protobuf/dist/esm/codegenv1/file.js +14 -0
  95. package/node_modules/@bufbuild/protobuf/dist/esm/codegenv1/index.js +23 -0
  96. package/node_modules/@bufbuild/protobuf/dist/esm/codegenv1/message.js +21 -0
  97. package/node_modules/@bufbuild/protobuf/dist/esm/codegenv1/service.js +24 -0
  98. package/node_modules/@bufbuild/protobuf/dist/esm/codegenv1/symbols.js +40 -0
  99. package/node_modules/@bufbuild/protobuf/dist/esm/codegenv1/types.js +14 -0
  100. package/node_modules/@bufbuild/protobuf/dist/esm/codegenv2/boot.js +101 -0
  101. package/node_modules/@bufbuild/protobuf/dist/esm/codegenv2/embed.js +239 -0
  102. package/node_modules/@bufbuild/protobuf/dist/esm/codegenv2/enum.js +53 -0
  103. package/node_modules/@bufbuild/protobuf/dist/esm/codegenv2/extension.js +25 -0
  104. package/node_modules/@bufbuild/protobuf/dist/esm/codegenv2/file.js +32 -0
  105. package/node_modules/@bufbuild/protobuf/dist/esm/codegenv2/index.js +23 -0
  106. package/node_modules/@bufbuild/protobuf/dist/esm/codegenv2/message.js +21 -0
  107. package/node_modules/@bufbuild/protobuf/dist/esm/codegenv2/restore-json-names.js +26 -0
  108. package/node_modules/@bufbuild/protobuf/dist/esm/codegenv2/scalar.js +63 -0
  109. package/node_modules/@bufbuild/protobuf/dist/esm/codegenv2/service.js +24 -0
  110. package/node_modules/@bufbuild/protobuf/dist/esm/codegenv2/symbols.js +71 -0
  111. package/node_modules/@bufbuild/protobuf/dist/esm/codegenv2/types.js +14 -0
  112. package/node_modules/@bufbuild/protobuf/dist/esm/create.js +293 -0
  113. package/node_modules/@bufbuild/protobuf/dist/esm/descriptors.js +50 -0
  114. package/node_modules/@bufbuild/protobuf/dist/esm/equals.js +206 -0
  115. package/node_modules/@bufbuild/protobuf/dist/esm/extensions.js +159 -0
  116. package/node_modules/@bufbuild/protobuf/dist/esm/fields.js +41 -0
  117. package/node_modules/@bufbuild/protobuf/dist/esm/from-binary.js +409 -0
  118. package/node_modules/@bufbuild/protobuf/dist/esm/from-json.js +1029 -0
  119. package/node_modules/@bufbuild/protobuf/dist/esm/index.js +29 -0
  120. package/node_modules/@bufbuild/protobuf/dist/esm/is-message.js +30 -0
  121. package/node_modules/@bufbuild/protobuf/dist/esm/json-value.js +14 -0
  122. package/node_modules/@bufbuild/protobuf/dist/esm/merge.js +67 -0
  123. package/node_modules/@bufbuild/protobuf/dist/esm/package.json +4 -0
  124. package/node_modules/@bufbuild/protobuf/dist/esm/proto-int64.js +128 -0
  125. package/node_modules/@bufbuild/protobuf/dist/esm/reflect/error.js +31 -0
  126. package/node_modules/@bufbuild/protobuf/dist/esm/reflect/guard.js +71 -0
  127. package/node_modules/@bufbuild/protobuf/dist/esm/reflect/index.js +21 -0
  128. package/node_modules/@bufbuild/protobuf/dist/esm/reflect/message.js +152 -0
  129. package/node_modules/@bufbuild/protobuf/dist/esm/reflect/names.js +109 -0
  130. package/node_modules/@bufbuild/protobuf/dist/esm/reflect/nested-types.js +105 -0
  131. package/node_modules/@bufbuild/protobuf/dist/esm/reflect/path.js +369 -0
  132. package/node_modules/@bufbuild/protobuf/dist/esm/reflect/reflect-check.js +284 -0
  133. package/node_modules/@bufbuild/protobuf/dist/esm/reflect/reflect-types.js +14 -0
  134. package/node_modules/@bufbuild/protobuf/dist/esm/reflect/reflect.js +464 -0
  135. package/node_modules/@bufbuild/protobuf/dist/esm/reflect/scalar.js +124 -0
  136. package/node_modules/@bufbuild/protobuf/dist/esm/reflect/unsafe.js +140 -0
  137. package/node_modules/@bufbuild/protobuf/dist/esm/registry.js +948 -0
  138. package/node_modules/@bufbuild/protobuf/dist/esm/to-binary.js +433 -0
  139. package/node_modules/@bufbuild/protobuf/dist/esm/to-json.js +620 -0
  140. package/node_modules/@bufbuild/protobuf/dist/esm/txtpb/from-text.js +680 -0
  141. package/node_modules/@bufbuild/protobuf/dist/esm/txtpb/index.js +15 -0
  142. package/node_modules/@bufbuild/protobuf/dist/esm/txtpb/is-group-like.js +44 -0
  143. package/node_modules/@bufbuild/protobuf/dist/esm/txtpb/reader.js +477 -0
  144. package/node_modules/@bufbuild/protobuf/dist/esm/txtpb/to-text.js +355 -0
  145. package/node_modules/@bufbuild/protobuf/dist/esm/txtpb/writer.js +214 -0
  146. package/node_modules/@bufbuild/protobuf/dist/esm/types.js +14 -0
  147. package/node_modules/@bufbuild/protobuf/dist/esm/unknown-enum.js +23 -0
  148. package/node_modules/@bufbuild/protobuf/dist/esm/wire/base64-encoding.js +184 -0
  149. package/node_modules/@bufbuild/protobuf/dist/esm/wire/binary-encoding.js +721 -0
  150. package/node_modules/@bufbuild/protobuf/dist/esm/wire/index.js +18 -0
  151. package/node_modules/@bufbuild/protobuf/dist/esm/wire/size-delimited.js +186 -0
  152. package/node_modules/@bufbuild/protobuf/dist/esm/wire/text-encoding.js +101 -0
  153. package/node_modules/@bufbuild/protobuf/dist/esm/wire/text-format.js +195 -0
  154. package/node_modules/@bufbuild/protobuf/dist/esm/wire/varint.js +325 -0
  155. package/node_modules/@bufbuild/protobuf/dist/esm/wkt/any.js +69 -0
  156. package/node_modules/@bufbuild/protobuf/dist/esm/wkt/duration.js +35 -0
  157. package/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/any_pb.js +24 -0
  158. package/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/api_pb.js +36 -0
  159. package/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/compiler/plugin_pb.js +65 -0
  160. package/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/cpp_features_pb.js +57 -0
  161. package/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/descriptor_pb.js +888 -0
  162. package/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/duration_pb.js +24 -0
  163. package/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/empty_pb.js +24 -0
  164. package/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/field_mask_pb.js +24 -0
  165. package/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/go_features_pb.js +123 -0
  166. package/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/java_features_pb.js +103 -0
  167. package/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/source_context_pb.js +24 -0
  168. package/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/struct_pb.js +56 -0
  169. package/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/timestamp_pb.js +24 -0
  170. package/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/type_pb.js +239 -0
  171. package/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/wrappers_pb.js +64 -0
  172. package/node_modules/@bufbuild/protobuf/dist/esm/wkt/index.js +32 -0
  173. package/node_modules/@bufbuild/protobuf/dist/esm/wkt/json.js +41 -0
  174. package/node_modules/@bufbuild/protobuf/dist/esm/wkt/timestamp.js +50 -0
  175. package/node_modules/@bufbuild/protobuf/dist/esm/wkt/wrappers.js +61 -0
  176. package/node_modules/@bufbuild/protobuf/package.json +136 -0
  177. package/node_modules/@deepseek-ai/dsh-base/package.json +1 -0
  178. package/node_modules/@deepseek-ai/dsh-client-ui-primitives/package.json +2 -2
  179. package/node_modules/@deepseek-ai/dsh-client-ui-sidebar/lib/client.js +1 -1
  180. package/node_modules/@deepseek-ai/dsh-client-ui-slots/package.json +2 -2
  181. package/node_modules/@deepseek-ai/dsh-llm-cursor/README.i18n.yaml +6 -0
  182. package/node_modules/@deepseek-ai/dsh-llm-cursor/README.md +143 -0
  183. package/node_modules/@deepseek-ai/dsh-llm-cursor/README.zh.md +143 -0
  184. package/node_modules/@deepseek-ai/dsh-llm-cursor/lib/index.js +3557 -0
  185. package/node_modules/@deepseek-ai/dsh-llm-cursor/package.json +61 -0
  186. package/node_modules/@deepseek-ai/dsh-tui-app/README.i18n.yaml +2 -2
  187. package/node_modules/@deepseek-ai/dsh-tui-app/README.md +39 -26
  188. package/node_modules/@deepseek-ai/dsh-tui-app/README.zh.md +39 -26
  189. package/node_modules/@deepseek-ai/dsh-tui-app/lib/index.js +1121 -223
  190. package/package.json +5 -1
@@ -0,0 +1,296 @@
1
+ "use strict";
2
+ // Copyright 2021-2026 Buf Technologies, Inc.
3
+ //
4
+ // Licensed under the Apache License, Version 2.0 (the "License");
5
+ // you may not use this file except in compliance with the License.
6
+ // You may obtain a copy of the License at
7
+ //
8
+ // http://www.apache.org/licenses/LICENSE-2.0
9
+ //
10
+ // Unless required by applicable law or agreed to in writing, software
11
+ // distributed under the License is distributed on an "AS IS" BASIS,
12
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ // See the License for the specific language governing permissions and
14
+ // limitations under the License.
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.create = create;
17
+ const is_message_js_1 = require("./is-message.js");
18
+ const descriptors_js_1 = require("./descriptors.js");
19
+ const scalar_js_1 = require("./reflect/scalar.js");
20
+ const guard_js_1 = require("./reflect/guard.js");
21
+ const wrappers_js_1 = require("./wkt/wrappers.js");
22
+ // bootstrap-inject google.protobuf.Edition.EDITION_PROTO3: const $name = $number;
23
+ const EDITION_PROTO3 = 999;
24
+ // bootstrap-inject google.protobuf.Edition.EDITION_PROTO2: const $name = $number;
25
+ const EDITION_PROTO2 = 998;
26
+ // bootstrap-inject google.protobuf.FeatureSet.FieldPresence.IMPLICIT: const $name = $number;
27
+ const IMPLICIT = 2;
28
+ /**
29
+ * Create a new message instance.
30
+ *
31
+ * The second argument is an optional initializer object, where all fields are
32
+ * optional.
33
+ */
34
+ function create(schema, init) {
35
+ if ((0, is_message_js_1.isMessage)(init, schema)) {
36
+ return init;
37
+ }
38
+ return compiledCreate(schema)(init);
39
+ }
40
+ const compiledCreates = new WeakMap();
41
+ /**
42
+ * Return the compiled create function for a message, compiling it on first use. */
43
+ function compiledCreate(desc) {
44
+ let compiled = compiledCreates.get(desc);
45
+ if (compiled === undefined) {
46
+ compiled = compileCreate(desc);
47
+ compiledCreates.set(desc, compiled);
48
+ }
49
+ return compiled;
50
+ }
51
+ /** Singular field: scalar, enum, or message. */
52
+ const INIT_SINGULAR = 0;
53
+ /** List field: a zero message has a fresh empty array. */
54
+ const INIT_LIST = 1;
55
+ /** Map field: a zero message has a fresh empty object. */
56
+ const INIT_MAP = 2;
57
+ /** Oneof group: the ADT is always stored, cases convert by case name. */
58
+ const INIT_ONEOF = 3;
59
+ /* Compile the create function for this message type. */
60
+ function compileCreate(desc) {
61
+ const typeName = desc.typeName;
62
+ const { properties, prototype } = compileInitMessage(desc);
63
+ return (init) => {
64
+ let message;
65
+ if (prototype !== undefined) {
66
+ message = Object.create(prototype);
67
+ message.$typeName = typeName;
68
+ }
69
+ else {
70
+ message = { $typeName: typeName };
71
+ }
72
+ for (let i = 0; i < properties.length; i++) {
73
+ const property = properties[i];
74
+ const name = property.name;
75
+ const initValue = init === null || init === void 0 ? void 0 : init[name];
76
+ switch (property.kind) {
77
+ case INIT_SINGULAR:
78
+ if (initValue != null) {
79
+ message[name] =
80
+ property.convert !== undefined
81
+ ? property.convert(initValue)
82
+ : initValue;
83
+ }
84
+ else if (property.constant !== undefined) {
85
+ message[name] = property.constant;
86
+ }
87
+ break;
88
+ case INIT_LIST:
89
+ message[name] =
90
+ property.convert !== undefined && Array.isArray(initValue)
91
+ ? initValue.map(property.convert)
92
+ : (initValue !== null && initValue !== void 0 ? initValue : []);
93
+ break;
94
+ case INIT_MAP:
95
+ // Object.create(null) would be desirable for the fresh map, but is
96
+ // unsupported by React:
97
+ // https://react.dev/reference/react/use-server#serializable-parameters-and-return-values
98
+ if (property.convert === undefined || !(0, guard_js_1.isObject)(initValue)) {
99
+ message[name] = initValue !== null && initValue !== void 0 ? initValue : {};
100
+ }
101
+ else {
102
+ const converted = {};
103
+ const keys = Object.keys(initValue);
104
+ for (let k = 0; k < keys.length; k++) {
105
+ converted[keys[k]] = property.convert(initValue[keys[k]]);
106
+ }
107
+ message[name] = converted;
108
+ }
109
+ break;
110
+ case INIT_ONEOF: {
111
+ const oneofValue = initValue;
112
+ if ((oneofValue === null || oneofValue === void 0 ? void 0 : oneofValue.case) != null) {
113
+ const convert = property.convert.get(oneofValue.case);
114
+ if (convert !== undefined) {
115
+ message[name] = {
116
+ case: oneofValue.case,
117
+ value: convert(oneofValue.value),
118
+ };
119
+ break;
120
+ }
121
+ }
122
+ message[name] = { case: undefined };
123
+ break;
124
+ }
125
+ }
126
+ }
127
+ return message;
128
+ };
129
+ }
130
+ /**
131
+ * Classify every member once, so that creating a message is a walk over a
132
+ * compact list instead of a walk over the descriptor.
133
+ */
134
+ function compileInitMessage(desc) {
135
+ var _a, _b;
136
+ const properties = [];
137
+ const prototype = {};
138
+ const usePrototype = needsPrototypeChain(desc);
139
+ for (const member of desc.members) {
140
+ const name = member.localName;
141
+ if (member.kind == "oneof") {
142
+ properties.push({
143
+ name,
144
+ kind: INIT_ONEOF,
145
+ constant: undefined,
146
+ convert: compileConvertOneof(member),
147
+ });
148
+ continue;
149
+ }
150
+ switch (member.fieldKind) {
151
+ case "message": {
152
+ // Singular message fields are absent from a zero message.
153
+ properties.push({
154
+ name,
155
+ kind: INIT_SINGULAR,
156
+ constant: undefined,
157
+ convert: compileConvertMessage(member),
158
+ });
159
+ break;
160
+ }
161
+ case "list": {
162
+ properties.push({
163
+ name,
164
+ kind: INIT_LIST,
165
+ constant: undefined,
166
+ convert: member.listKind == "message"
167
+ ? ((_a = compileConvertMessage(member)) !== null && _a !== void 0 ? _a : ((value) => value))
168
+ : member.scalar == descriptors_js_1.ScalarType.BYTES
169
+ ? toU8Arr
170
+ : undefined,
171
+ });
172
+ break;
173
+ }
174
+ case "map": {
175
+ properties.push({
176
+ name,
177
+ kind: INIT_MAP,
178
+ constant: undefined,
179
+ convert: member.mapKind == "message"
180
+ ? ((_b = compileConvertMessage(member)) !== null && _b !== void 0 ? _b : ((value) => value))
181
+ : member.scalar == descriptors_js_1.ScalarType.BYTES
182
+ ? toU8Arr
183
+ : undefined,
184
+ });
185
+ break;
186
+ }
187
+ default: {
188
+ const zeroValue = createZeroValue(member);
189
+ properties.push({
190
+ name,
191
+ kind: INIT_SINGULAR,
192
+ constant: member.presence == IMPLICIT ? zeroValue : undefined,
193
+ convert: member.fieldKind == "scalar" && member.scalar == descriptors_js_1.ScalarType.BYTES
194
+ ? toU8Arr
195
+ : undefined,
196
+ });
197
+ if (usePrototype) {
198
+ prototype[name] = zeroValue;
199
+ }
200
+ break;
201
+ }
202
+ }
203
+ }
204
+ return {
205
+ properties,
206
+ prototype: usePrototype ? prototype : undefined,
207
+ };
208
+ }
209
+ /**
210
+ * Compile the conversion of each case of a oneof group, keyed by case name.
211
+ */
212
+ function compileConvertOneof(oneof) {
213
+ const converters = new Map();
214
+ for (const field of oneof.fields) {
215
+ let convert;
216
+ if (field.fieldKind == "message") {
217
+ convert = compileConvertMessage(field);
218
+ }
219
+ else if (field.fieldKind == "scalar" &&
220
+ field.scalar == descriptors_js_1.ScalarType.BYTES) {
221
+ convert = toU8Arr;
222
+ }
223
+ converters.set(field.localName, convert !== null && convert !== void 0 ? convert : ((value) => value));
224
+ }
225
+ return converters;
226
+ }
227
+ /**
228
+ * Compile the conversion of an init value for a message field, a message
229
+ * list item, or a message map value. Returns undefined if values are used
230
+ * as-is.
231
+ */
232
+ function compileConvertMessage(field) {
233
+ if (field.fieldKind == "message" &&
234
+ !field.oneof &&
235
+ (0, wrappers_js_1.isWrapperDesc)(field.message)) {
236
+ // Types from google/protobuf/wrappers.proto are unwrapped when used in
237
+ // a singular field that is not part of a oneof group.
238
+ return field.message.fields[0].scalar == descriptors_js_1.ScalarType.BYTES
239
+ ? toU8Arr
240
+ : undefined;
241
+ }
242
+ if (field.message.typeName == "google.protobuf.Struct" &&
243
+ field.parent.typeName !== "google.protobuf.Value") {
244
+ // google.protobuf.Struct is represented with JsonObject when used in a
245
+ // field, except when used in google.protobuf.Value.
246
+ return undefined;
247
+ }
248
+ const messageDesc = field.message;
249
+ // Resolved on first use, not here: the message type can be this very field's
250
+ // parent, whose create function is still being compiled.
251
+ let compiled;
252
+ return (value) => {
253
+ if (!(0, guard_js_1.isObject)(value) || (0, is_message_js_1.isMessage)(value, messageDesc)) {
254
+ return value;
255
+ }
256
+ compiled !== null && compiled !== void 0 ? compiled : (compiled = compiledCreate(messageDesc));
257
+ return compiled(value);
258
+ };
259
+ }
260
+ // converts any ArrayLike<number> to Uint8Array if necessary.
261
+ function toU8Arr(value) {
262
+ return Array.isArray(value) ? new Uint8Array(value) : value;
263
+ }
264
+ /**
265
+ * Do we need the prototype chain to track field presence?
266
+ */
267
+ function needsPrototypeChain(desc) {
268
+ switch (desc.file.edition) {
269
+ case EDITION_PROTO3:
270
+ // proto3 always uses implicit presence, we never need the prototype chain.
271
+ return false;
272
+ case EDITION_PROTO2:
273
+ // proto2 never uses implicit presence, we always need the prototype chain.
274
+ return true;
275
+ default:
276
+ // If a message uses scalar or enum fields with explicit presence, we need
277
+ // the prototype chain to track presence. This rule does not apply to fields
278
+ // in a oneof group - they use a different mechanism to track presence.
279
+ return desc.fields.some((f) => f.presence != IMPLICIT && f.fieldKind != "message" && !f.oneof);
280
+ }
281
+ }
282
+ /**
283
+ * Returns the zero value for a scalar or enum field. Scalar and enum fields
284
+ * can have default values.
285
+ */
286
+ function createZeroValue(field) {
287
+ const defaultValue = field.getDefaultValue();
288
+ if (defaultValue !== undefined) {
289
+ return field.fieldKind == "scalar" && field.longAsString
290
+ ? defaultValue.toString()
291
+ : defaultValue;
292
+ }
293
+ return field.fieldKind == "scalar"
294
+ ? (0, scalar_js_1.scalarZeroValue)(field.scalar, field.longAsString)
295
+ : field.enum.values[0].number;
296
+ }
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ // Copyright 2021-2026 Buf Technologies, Inc.
3
+ //
4
+ // Licensed under the Apache License, Version 2.0 (the "License");
5
+ // you may not use this file except in compliance with the License.
6
+ // You may obtain a copy of the License at
7
+ //
8
+ // http://www.apache.org/licenses/LICENSE-2.0
9
+ //
10
+ // Unless required by applicable law or agreed to in writing, software
11
+ // distributed under the License is distributed on an "AS IS" BASIS,
12
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ // See the License for the specific language governing permissions and
14
+ // limitations under the License.
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.ScalarType = void 0;
17
+ /**
18
+ * Scalar value types. This is a subset of field types declared by protobuf
19
+ * enum google.protobuf.FieldDescriptorProto.Type The types GROUP and MESSAGE
20
+ * are omitted, but the numerical values are identical.
21
+ */
22
+ var ScalarType;
23
+ (function (ScalarType) {
24
+ // 0 is reserved for errors.
25
+ // Order is weird for historical reasons.
26
+ ScalarType[ScalarType["DOUBLE"] = 1] = "DOUBLE";
27
+ ScalarType[ScalarType["FLOAT"] = 2] = "FLOAT";
28
+ // Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT64 if
29
+ // negative values are likely.
30
+ ScalarType[ScalarType["INT64"] = 3] = "INT64";
31
+ ScalarType[ScalarType["UINT64"] = 4] = "UINT64";
32
+ // Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT32 if
33
+ // negative values are likely.
34
+ ScalarType[ScalarType["INT32"] = 5] = "INT32";
35
+ ScalarType[ScalarType["FIXED64"] = 6] = "FIXED64";
36
+ ScalarType[ScalarType["FIXED32"] = 7] = "FIXED32";
37
+ ScalarType[ScalarType["BOOL"] = 8] = "BOOL";
38
+ ScalarType[ScalarType["STRING"] = 9] = "STRING";
39
+ // Tag-delimited aggregate.
40
+ // Group type is deprecated and not supported in proto3. However, Proto3
41
+ // implementations should still be able to parse the group wire format and
42
+ // treat group fields as unknown fields.
43
+ // TYPE_GROUP = 10,
44
+ // TYPE_MESSAGE = 11, // Length-delimited aggregate.
45
+ // New in version 2.
46
+ ScalarType[ScalarType["BYTES"] = 12] = "BYTES";
47
+ ScalarType[ScalarType["UINT32"] = 13] = "UINT32";
48
+ // TYPE_ENUM = 14,
49
+ ScalarType[ScalarType["SFIXED32"] = 15] = "SFIXED32";
50
+ ScalarType[ScalarType["SFIXED64"] = 16] = "SFIXED64";
51
+ ScalarType[ScalarType["SINT32"] = 17] = "SINT32";
52
+ ScalarType[ScalarType["SINT64"] = 18] = "SINT64";
53
+ })(ScalarType || (exports.ScalarType = ScalarType = {}));
@@ -0,0 +1,209 @@
1
+ "use strict";
2
+ // Copyright 2021-2026 Buf Technologies, Inc.
3
+ //
4
+ // Licensed under the Apache License, Version 2.0 (the "License");
5
+ // you may not use this file except in compliance with the License.
6
+ // You may obtain a copy of the License at
7
+ //
8
+ // http://www.apache.org/licenses/LICENSE-2.0
9
+ //
10
+ // Unless required by applicable law or agreed to in writing, software
11
+ // distributed under the License is distributed on an "AS IS" BASIS,
12
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ // See the License for the specific language governing permissions and
14
+ // limitations under the License.
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.equals = equals;
17
+ const scalar_js_1 = require("./reflect/scalar.js");
18
+ const reflect_js_1 = require("./reflect/reflect.js");
19
+ const descriptors_js_1 = require("./descriptors.js");
20
+ const index_js_1 = require("./wkt/index.js");
21
+ const extensions_js_1 = require("./extensions.js");
22
+ /**
23
+ * Compare two messages of the same type for equality.
24
+ *
25
+ * Fields are compared one by one, but only when set: a field set in one message
26
+ * but not the other makes them unequal, while fields set in both are compared
27
+ * by value. Extensions and unknown fields are disregarded by default.
28
+ *
29
+ * Float and double values are compared with IEEE semantics: NaN does not equal
30
+ * NaN, and -0 equals 0 (with the exception for singular fields with implicit
31
+ * presence: -0 is set, +0 is unset).
32
+ */
33
+ function equals(schema, a, b, options) {
34
+ if (a.$typeName != schema.typeName || b.$typeName != schema.typeName) {
35
+ return false;
36
+ }
37
+ if (a === b) {
38
+ return true;
39
+ }
40
+ return reflectEquals((0, reflect_js_1.reflect)(schema, a), (0, reflect_js_1.reflect)(schema, b), options);
41
+ }
42
+ function reflectEquals(a, b, opts) {
43
+ if (a.desc.typeName === "google.protobuf.Any" && (opts === null || opts === void 0 ? void 0 : opts.unpackAny) == true) {
44
+ return anyUnpackedEquals(a.message, b.message, opts);
45
+ }
46
+ for (const f of a.fields) {
47
+ if (!fieldEquals(f, a, b, opts)) {
48
+ return false;
49
+ }
50
+ }
51
+ if ((opts === null || opts === void 0 ? void 0 : opts.unknown) == true && !unknownEquals(a, b, opts.registry)) {
52
+ return false;
53
+ }
54
+ if ((opts === null || opts === void 0 ? void 0 : opts.extensions) == true && !extensionsEquals(a, b, opts)) {
55
+ return false;
56
+ }
57
+ return true;
58
+ }
59
+ // TODO(tstamm) add an option to consider NaN equal to NaN?
60
+ function fieldEquals(f, a, b, opts) {
61
+ if (!a.isSet(f) && !b.isSet(f)) {
62
+ return true;
63
+ }
64
+ if (!a.isSet(f) || !b.isSet(f)) {
65
+ return false;
66
+ }
67
+ switch (f.fieldKind) {
68
+ case "scalar":
69
+ return (0, scalar_js_1.scalarEquals)(f.scalar, a.get(f), b.get(f));
70
+ case "enum":
71
+ return a.get(f) === b.get(f);
72
+ case "message":
73
+ return reflectEquals(a.get(f), b.get(f), opts);
74
+ case "map": {
75
+ // TODO(tstamm) can't we compare sizes first?
76
+ const mapA = a.get(f);
77
+ const mapB = b.get(f);
78
+ const keys = [];
79
+ for (const k of mapA.keys()) {
80
+ if (!mapB.has(k)) {
81
+ return false;
82
+ }
83
+ keys.push(k);
84
+ }
85
+ for (const k of mapB.keys()) {
86
+ if (!mapA.has(k)) {
87
+ return false;
88
+ }
89
+ }
90
+ for (const key of keys) {
91
+ const va = mapA.get(key);
92
+ const vb = mapB.get(key);
93
+ if (va === vb) {
94
+ continue;
95
+ }
96
+ switch (f.mapKind) {
97
+ case "enum":
98
+ return false;
99
+ case "message":
100
+ if (!reflectEquals(va, vb, opts)) {
101
+ return false;
102
+ }
103
+ break;
104
+ case "scalar":
105
+ if (!(0, scalar_js_1.scalarEquals)(f.scalar, va, vb)) {
106
+ return false;
107
+ }
108
+ break;
109
+ }
110
+ }
111
+ break;
112
+ }
113
+ case "list": {
114
+ const listA = a.get(f);
115
+ const listB = b.get(f);
116
+ if (listA.size != listB.size) {
117
+ return false;
118
+ }
119
+ for (let i = 0; i < listA.size; i++) {
120
+ const va = listA.get(i);
121
+ const vb = listB.get(i);
122
+ if (va === vb) {
123
+ continue;
124
+ }
125
+ switch (f.listKind) {
126
+ case "enum":
127
+ return false;
128
+ case "message":
129
+ if (!reflectEquals(va, vb, opts)) {
130
+ return false;
131
+ }
132
+ break;
133
+ case "scalar":
134
+ if (!(0, scalar_js_1.scalarEquals)(f.scalar, va, vb)) {
135
+ return false;
136
+ }
137
+ break;
138
+ }
139
+ }
140
+ break;
141
+ }
142
+ }
143
+ return true;
144
+ }
145
+ function anyUnpackedEquals(a, b, opts) {
146
+ if (a.typeUrl !== b.typeUrl) {
147
+ return false;
148
+ }
149
+ const unpackedA = (0, index_js_1.anyUnpack)(a, opts.registry);
150
+ const unpackedB = (0, index_js_1.anyUnpack)(b, opts.registry);
151
+ if (unpackedA && unpackedB) {
152
+ const schema = opts.registry.getMessage(unpackedA.$typeName);
153
+ if (schema) {
154
+ return equals(schema, unpackedA, unpackedB, opts);
155
+ }
156
+ }
157
+ return (0, scalar_js_1.scalarEquals)(descriptors_js_1.ScalarType.BYTES, a.value, b.value);
158
+ }
159
+ function unknownEquals(a, b, registry) {
160
+ function getTrulyUnknown(msg, registry) {
161
+ var _a;
162
+ const u = (_a = msg.getUnknown()) !== null && _a !== void 0 ? _a : [];
163
+ return registry
164
+ ? u.filter((uf) => !registry.getExtensionFor(msg.desc, uf.no))
165
+ : u;
166
+ }
167
+ const unknownA = getTrulyUnknown(a, registry);
168
+ const unknownB = getTrulyUnknown(b, registry);
169
+ if (unknownA.length != unknownB.length) {
170
+ return false;
171
+ }
172
+ for (let i = 0; i < unknownA.length; i++) {
173
+ const a = unknownA[i];
174
+ const b = unknownB[i];
175
+ if (a.no != b.no) {
176
+ return false;
177
+ }
178
+ if (a.wireType != b.wireType) {
179
+ return false;
180
+ }
181
+ if (!(0, scalar_js_1.scalarEquals)(descriptors_js_1.ScalarType.BYTES, a.data, b.data)) {
182
+ return false;
183
+ }
184
+ }
185
+ return true;
186
+ }
187
+ function extensionsEquals(a, b, opts) {
188
+ function getSetExtensions(msg, registry) {
189
+ var _a;
190
+ return ((_a = msg.getUnknown()) !== null && _a !== void 0 ? _a : [])
191
+ .map((uf) => registry.getExtensionFor(msg.desc, uf.no))
192
+ .filter((e) => e != undefined)
193
+ .filter((e, index, arr) => arr.indexOf(e) === index);
194
+ }
195
+ const extensionsA = getSetExtensions(a, opts.registry);
196
+ const extensionsB = getSetExtensions(b, opts.registry);
197
+ if (extensionsA.length != extensionsB.length ||
198
+ extensionsA.some((e) => !extensionsB.includes(e))) {
199
+ return false;
200
+ }
201
+ for (const extension of extensionsA) {
202
+ const [containerA, field] = (0, extensions_js_1.createExtensionContainer)(extension, (0, extensions_js_1.getExtension)(a.message, extension));
203
+ const [containerB] = (0, extensions_js_1.createExtensionContainer)(extension, (0, extensions_js_1.getExtension)(b.message, extension));
204
+ if (!fieldEquals(field, containerA, containerB, opts)) {
205
+ return false;
206
+ }
207
+ }
208
+ return true;
209
+ }