@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,63 @@
1
+ // Copyright 2021-2026 Buf Technologies, Inc.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ import { ScalarType } from "../descriptors.js";
15
+ /**
16
+ * Return the TypeScript type (as a string) for the given scalar type.
17
+ */
18
+ export function scalarTypeScriptType(scalar, longAsString) {
19
+ switch (scalar) {
20
+ case ScalarType.STRING:
21
+ return "string";
22
+ case ScalarType.BOOL:
23
+ return "boolean";
24
+ case ScalarType.UINT64:
25
+ case ScalarType.SFIXED64:
26
+ case ScalarType.FIXED64:
27
+ case ScalarType.SINT64:
28
+ case ScalarType.INT64:
29
+ return longAsString ? "string" : "bigint";
30
+ case ScalarType.BYTES:
31
+ return "Uint8Array";
32
+ default:
33
+ return "number";
34
+ }
35
+ }
36
+ /**
37
+ * Return the JSON type (as a string) for the given scalar type.
38
+ */
39
+ export function scalarJsonType(scalar) {
40
+ switch (scalar) {
41
+ case ScalarType.DOUBLE:
42
+ case ScalarType.FLOAT:
43
+ return `number | "NaN" | "Infinity" | "-Infinity"`;
44
+ case ScalarType.UINT64:
45
+ case ScalarType.SFIXED64:
46
+ case ScalarType.FIXED64:
47
+ case ScalarType.SINT64:
48
+ case ScalarType.INT64:
49
+ return "string";
50
+ case ScalarType.INT32:
51
+ case ScalarType.FIXED32:
52
+ case ScalarType.UINT32:
53
+ case ScalarType.SFIXED32:
54
+ case ScalarType.SINT32:
55
+ return "number";
56
+ case ScalarType.STRING:
57
+ return "string";
58
+ case ScalarType.BOOL:
59
+ return "boolean";
60
+ case ScalarType.BYTES:
61
+ return "string";
62
+ }
63
+ }
@@ -0,0 +1,24 @@
1
+ // Copyright 2021-2026 Buf Technologies, Inc.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ /**
15
+ * Hydrate a service descriptor.
16
+ *
17
+ * @private
18
+ */
19
+ export function serviceDesc(file, path, ...paths) {
20
+ if (paths.length > 0) {
21
+ throw new Error();
22
+ }
23
+ return file.services[path];
24
+ }
@@ -0,0 +1,71 @@
1
+ // Copyright 2021-2026 Buf Technologies, Inc.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ /**
15
+ * @private
16
+ */
17
+ export const packageName = "@bufbuild/protobuf";
18
+ /**
19
+ * @private
20
+ */
21
+ export const wktPublicImportPaths = {
22
+ "google/protobuf/compiler/plugin.proto": packageName + "/wkt",
23
+ "google/protobuf/any.proto": packageName + "/wkt",
24
+ "google/protobuf/api.proto": packageName + "/wkt",
25
+ "google/protobuf/cpp_features.proto": packageName + "/wkt",
26
+ "google/protobuf/descriptor.proto": packageName + "/wkt",
27
+ "google/protobuf/duration.proto": packageName + "/wkt",
28
+ "google/protobuf/empty.proto": packageName + "/wkt",
29
+ "google/protobuf/field_mask.proto": packageName + "/wkt",
30
+ "google/protobuf/go_features.proto": packageName + "/wkt",
31
+ "google/protobuf/java_features.proto": packageName + "/wkt",
32
+ "google/protobuf/source_context.proto": packageName + "/wkt",
33
+ "google/protobuf/struct.proto": packageName + "/wkt",
34
+ "google/protobuf/timestamp.proto": packageName + "/wkt",
35
+ "google/protobuf/type.proto": packageName + "/wkt",
36
+ "google/protobuf/wrappers.proto": packageName + "/wkt",
37
+ };
38
+ /**
39
+ * @private
40
+ */
41
+ // biome-ignore format: want this to read well
42
+ export const symbols = {
43
+ isMessage: { typeOnly: false, bootstrapWktFrom: "../../is-message.js", from: packageName },
44
+ Message: { typeOnly: true, bootstrapWktFrom: "../../types.js", from: packageName },
45
+ create: { typeOnly: false, bootstrapWktFrom: "../../create.js", from: packageName },
46
+ fromJson: { typeOnly: false, bootstrapWktFrom: "../../from-json.js", from: packageName },
47
+ fromJsonString: { typeOnly: false, bootstrapWktFrom: "../../from-json.js", from: packageName },
48
+ fromBinary: { typeOnly: false, bootstrapWktFrom: "../../from-binary.js", from: packageName },
49
+ toBinary: { typeOnly: false, bootstrapWktFrom: "../../to-binary.js", from: packageName },
50
+ toJson: { typeOnly: false, bootstrapWktFrom: "../../to-json.js", from: packageName },
51
+ toJsonString: { typeOnly: false, bootstrapWktFrom: "../../to-json.js", from: packageName },
52
+ protoInt64: { typeOnly: false, bootstrapWktFrom: "../../proto-int64.js", from: packageName },
53
+ JsonValue: { typeOnly: true, bootstrapWktFrom: "../../json-value.js", from: packageName },
54
+ JsonObject: { typeOnly: true, bootstrapWktFrom: "../../json-value.js", from: packageName },
55
+ UnknownEnum: { typeOnly: true, bootstrapWktFrom: "../../types.js", from: packageName },
56
+ codegen: {
57
+ boot: { typeOnly: false, bootstrapWktFrom: "../../codegenv2/boot.js", from: packageName + "/codegenv2" },
58
+ fileDesc: { typeOnly: false, bootstrapWktFrom: "../../codegenv2/file.js", from: packageName + "/codegenv2" },
59
+ enumDesc: { typeOnly: false, bootstrapWktFrom: "../../codegenv2/enum.js", from: packageName + "/codegenv2" },
60
+ extDesc: { typeOnly: false, bootstrapWktFrom: "../../codegenv2/extension.js", from: packageName + "/codegenv2" },
61
+ messageDesc: { typeOnly: false, bootstrapWktFrom: "../../codegenv2/message.js", from: packageName + "/codegenv2" },
62
+ serviceDesc: { typeOnly: false, bootstrapWktFrom: "../../codegenv2/service.js", from: packageName + "/codegenv2" },
63
+ tsEnum: { typeOnly: false, bootstrapWktFrom: "../../codegenv2/enum.js", from: packageName + "/codegenv2" },
64
+ objEnum: { typeOnly: false, bootstrapWktFrom: "../../codegenv2/enum.js", from: packageName + "/codegenv2" },
65
+ GenFile: { typeOnly: true, bootstrapWktFrom: "../../codegenv2/types.js", from: packageName + "/codegenv2" },
66
+ GenEnum: { typeOnly: true, bootstrapWktFrom: "../../codegenv2/types.js", from: packageName + "/codegenv2" },
67
+ GenExtension: { typeOnly: true, bootstrapWktFrom: "../../codegenv2/types.js", from: packageName + "/codegenv2" },
68
+ GenMessage: { typeOnly: true, bootstrapWktFrom: "../../codegenv2/types.js", from: packageName + "/codegenv2" },
69
+ GenService: { typeOnly: true, bootstrapWktFrom: "../../codegenv2/types.js", from: packageName + "/codegenv2" },
70
+ },
71
+ };
@@ -0,0 +1,14 @@
1
+ // Copyright 2021-2026 Buf Technologies, Inc.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ export {};
@@ -0,0 +1,293 @@
1
+ // Copyright 2021-2026 Buf Technologies, Inc.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ import { isMessage } from "./is-message.js";
15
+ import { ScalarType, } from "./descriptors.js";
16
+ import { scalarZeroValue } from "./reflect/scalar.js";
17
+ import { isObject } from "./reflect/guard.js";
18
+ import { isWrapperDesc } from "./wkt/wrappers.js";
19
+ // bootstrap-inject google.protobuf.Edition.EDITION_PROTO3: const $name = $number;
20
+ const EDITION_PROTO3 = 999;
21
+ // bootstrap-inject google.protobuf.Edition.EDITION_PROTO2: const $name = $number;
22
+ const EDITION_PROTO2 = 998;
23
+ // bootstrap-inject google.protobuf.FeatureSet.FieldPresence.IMPLICIT: const $name = $number;
24
+ const IMPLICIT = 2;
25
+ /**
26
+ * Create a new message instance.
27
+ *
28
+ * The second argument is an optional initializer object, where all fields are
29
+ * optional.
30
+ */
31
+ export function create(schema, init) {
32
+ if (isMessage(init, schema)) {
33
+ return init;
34
+ }
35
+ return compiledCreate(schema)(init);
36
+ }
37
+ const compiledCreates = new WeakMap();
38
+ /**
39
+ * Return the compiled create function for a message, compiling it on first use. */
40
+ function compiledCreate(desc) {
41
+ let compiled = compiledCreates.get(desc);
42
+ if (compiled === undefined) {
43
+ compiled = compileCreate(desc);
44
+ compiledCreates.set(desc, compiled);
45
+ }
46
+ return compiled;
47
+ }
48
+ /** Singular field: scalar, enum, or message. */
49
+ const INIT_SINGULAR = 0;
50
+ /** List field: a zero message has a fresh empty array. */
51
+ const INIT_LIST = 1;
52
+ /** Map field: a zero message has a fresh empty object. */
53
+ const INIT_MAP = 2;
54
+ /** Oneof group: the ADT is always stored, cases convert by case name. */
55
+ const INIT_ONEOF = 3;
56
+ /* Compile the create function for this message type. */
57
+ function compileCreate(desc) {
58
+ const typeName = desc.typeName;
59
+ const { properties, prototype } = compileInitMessage(desc);
60
+ return (init) => {
61
+ let message;
62
+ if (prototype !== undefined) {
63
+ message = Object.create(prototype);
64
+ message.$typeName = typeName;
65
+ }
66
+ else {
67
+ message = { $typeName: typeName };
68
+ }
69
+ for (let i = 0; i < properties.length; i++) {
70
+ const property = properties[i];
71
+ const name = property.name;
72
+ const initValue = init === null || init === void 0 ? void 0 : init[name];
73
+ switch (property.kind) {
74
+ case INIT_SINGULAR:
75
+ if (initValue != null) {
76
+ message[name] =
77
+ property.convert !== undefined
78
+ ? property.convert(initValue)
79
+ : initValue;
80
+ }
81
+ else if (property.constant !== undefined) {
82
+ message[name] = property.constant;
83
+ }
84
+ break;
85
+ case INIT_LIST:
86
+ message[name] =
87
+ property.convert !== undefined && Array.isArray(initValue)
88
+ ? initValue.map(property.convert)
89
+ : (initValue !== null && initValue !== void 0 ? initValue : []);
90
+ break;
91
+ case INIT_MAP:
92
+ // Object.create(null) would be desirable for the fresh map, but is
93
+ // unsupported by React:
94
+ // https://react.dev/reference/react/use-server#serializable-parameters-and-return-values
95
+ if (property.convert === undefined || !isObject(initValue)) {
96
+ message[name] = initValue !== null && initValue !== void 0 ? initValue : {};
97
+ }
98
+ else {
99
+ const converted = {};
100
+ const keys = Object.keys(initValue);
101
+ for (let k = 0; k < keys.length; k++) {
102
+ converted[keys[k]] = property.convert(initValue[keys[k]]);
103
+ }
104
+ message[name] = converted;
105
+ }
106
+ break;
107
+ case INIT_ONEOF: {
108
+ const oneofValue = initValue;
109
+ if ((oneofValue === null || oneofValue === void 0 ? void 0 : oneofValue.case) != null) {
110
+ const convert = property.convert.get(oneofValue.case);
111
+ if (convert !== undefined) {
112
+ message[name] = {
113
+ case: oneofValue.case,
114
+ value: convert(oneofValue.value),
115
+ };
116
+ break;
117
+ }
118
+ }
119
+ message[name] = { case: undefined };
120
+ break;
121
+ }
122
+ }
123
+ }
124
+ return message;
125
+ };
126
+ }
127
+ /**
128
+ * Classify every member once, so that creating a message is a walk over a
129
+ * compact list instead of a walk over the descriptor.
130
+ */
131
+ function compileInitMessage(desc) {
132
+ var _a, _b;
133
+ const properties = [];
134
+ const prototype = {};
135
+ const usePrototype = needsPrototypeChain(desc);
136
+ for (const member of desc.members) {
137
+ const name = member.localName;
138
+ if (member.kind == "oneof") {
139
+ properties.push({
140
+ name,
141
+ kind: INIT_ONEOF,
142
+ constant: undefined,
143
+ convert: compileConvertOneof(member),
144
+ });
145
+ continue;
146
+ }
147
+ switch (member.fieldKind) {
148
+ case "message": {
149
+ // Singular message fields are absent from a zero message.
150
+ properties.push({
151
+ name,
152
+ kind: INIT_SINGULAR,
153
+ constant: undefined,
154
+ convert: compileConvertMessage(member),
155
+ });
156
+ break;
157
+ }
158
+ case "list": {
159
+ properties.push({
160
+ name,
161
+ kind: INIT_LIST,
162
+ constant: undefined,
163
+ convert: member.listKind == "message"
164
+ ? ((_a = compileConvertMessage(member)) !== null && _a !== void 0 ? _a : ((value) => value))
165
+ : member.scalar == ScalarType.BYTES
166
+ ? toU8Arr
167
+ : undefined,
168
+ });
169
+ break;
170
+ }
171
+ case "map": {
172
+ properties.push({
173
+ name,
174
+ kind: INIT_MAP,
175
+ constant: undefined,
176
+ convert: member.mapKind == "message"
177
+ ? ((_b = compileConvertMessage(member)) !== null && _b !== void 0 ? _b : ((value) => value))
178
+ : member.scalar == ScalarType.BYTES
179
+ ? toU8Arr
180
+ : undefined,
181
+ });
182
+ break;
183
+ }
184
+ default: {
185
+ const zeroValue = createZeroValue(member);
186
+ properties.push({
187
+ name,
188
+ kind: INIT_SINGULAR,
189
+ constant: member.presence == IMPLICIT ? zeroValue : undefined,
190
+ convert: member.fieldKind == "scalar" && member.scalar == ScalarType.BYTES
191
+ ? toU8Arr
192
+ : undefined,
193
+ });
194
+ if (usePrototype) {
195
+ prototype[name] = zeroValue;
196
+ }
197
+ break;
198
+ }
199
+ }
200
+ }
201
+ return {
202
+ properties,
203
+ prototype: usePrototype ? prototype : undefined,
204
+ };
205
+ }
206
+ /**
207
+ * Compile the conversion of each case of a oneof group, keyed by case name.
208
+ */
209
+ function compileConvertOneof(oneof) {
210
+ const converters = new Map();
211
+ for (const field of oneof.fields) {
212
+ let convert;
213
+ if (field.fieldKind == "message") {
214
+ convert = compileConvertMessage(field);
215
+ }
216
+ else if (field.fieldKind == "scalar" &&
217
+ field.scalar == ScalarType.BYTES) {
218
+ convert = toU8Arr;
219
+ }
220
+ converters.set(field.localName, convert !== null && convert !== void 0 ? convert : ((value) => value));
221
+ }
222
+ return converters;
223
+ }
224
+ /**
225
+ * Compile the conversion of an init value for a message field, a message
226
+ * list item, or a message map value. Returns undefined if values are used
227
+ * as-is.
228
+ */
229
+ function compileConvertMessage(field) {
230
+ if (field.fieldKind == "message" &&
231
+ !field.oneof &&
232
+ isWrapperDesc(field.message)) {
233
+ // Types from google/protobuf/wrappers.proto are unwrapped when used in
234
+ // a singular field that is not part of a oneof group.
235
+ return field.message.fields[0].scalar == ScalarType.BYTES
236
+ ? toU8Arr
237
+ : undefined;
238
+ }
239
+ if (field.message.typeName == "google.protobuf.Struct" &&
240
+ field.parent.typeName !== "google.protobuf.Value") {
241
+ // google.protobuf.Struct is represented with JsonObject when used in a
242
+ // field, except when used in google.protobuf.Value.
243
+ return undefined;
244
+ }
245
+ const messageDesc = field.message;
246
+ // Resolved on first use, not here: the message type can be this very field's
247
+ // parent, whose create function is still being compiled.
248
+ let compiled;
249
+ return (value) => {
250
+ if (!isObject(value) || isMessage(value, messageDesc)) {
251
+ return value;
252
+ }
253
+ compiled !== null && compiled !== void 0 ? compiled : (compiled = compiledCreate(messageDesc));
254
+ return compiled(value);
255
+ };
256
+ }
257
+ // converts any ArrayLike<number> to Uint8Array if necessary.
258
+ function toU8Arr(value) {
259
+ return Array.isArray(value) ? new Uint8Array(value) : value;
260
+ }
261
+ /**
262
+ * Do we need the prototype chain to track field presence?
263
+ */
264
+ function needsPrototypeChain(desc) {
265
+ switch (desc.file.edition) {
266
+ case EDITION_PROTO3:
267
+ // proto3 always uses implicit presence, we never need the prototype chain.
268
+ return false;
269
+ case EDITION_PROTO2:
270
+ // proto2 never uses implicit presence, we always need the prototype chain.
271
+ return true;
272
+ default:
273
+ // If a message uses scalar or enum fields with explicit presence, we need
274
+ // the prototype chain to track presence. This rule does not apply to fields
275
+ // in a oneof group - they use a different mechanism to track presence.
276
+ return desc.fields.some((f) => f.presence != IMPLICIT && f.fieldKind != "message" && !f.oneof);
277
+ }
278
+ }
279
+ /**
280
+ * Returns the zero value for a scalar or enum field. Scalar and enum fields
281
+ * can have default values.
282
+ */
283
+ function createZeroValue(field) {
284
+ const defaultValue = field.getDefaultValue();
285
+ if (defaultValue !== undefined) {
286
+ return field.fieldKind == "scalar" && field.longAsString
287
+ ? defaultValue.toString()
288
+ : defaultValue;
289
+ }
290
+ return field.fieldKind == "scalar"
291
+ ? scalarZeroValue(field.scalar, field.longAsString)
292
+ : field.enum.values[0].number;
293
+ }
@@ -0,0 +1,50 @@
1
+ // Copyright 2021-2026 Buf Technologies, Inc.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ /**
15
+ * Scalar value types. This is a subset of field types declared by protobuf
16
+ * enum google.protobuf.FieldDescriptorProto.Type The types GROUP and MESSAGE
17
+ * are omitted, but the numerical values are identical.
18
+ */
19
+ export var ScalarType;
20
+ (function (ScalarType) {
21
+ // 0 is reserved for errors.
22
+ // Order is weird for historical reasons.
23
+ ScalarType[ScalarType["DOUBLE"] = 1] = "DOUBLE";
24
+ ScalarType[ScalarType["FLOAT"] = 2] = "FLOAT";
25
+ // Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT64 if
26
+ // negative values are likely.
27
+ ScalarType[ScalarType["INT64"] = 3] = "INT64";
28
+ ScalarType[ScalarType["UINT64"] = 4] = "UINT64";
29
+ // Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT32 if
30
+ // negative values are likely.
31
+ ScalarType[ScalarType["INT32"] = 5] = "INT32";
32
+ ScalarType[ScalarType["FIXED64"] = 6] = "FIXED64";
33
+ ScalarType[ScalarType["FIXED32"] = 7] = "FIXED32";
34
+ ScalarType[ScalarType["BOOL"] = 8] = "BOOL";
35
+ ScalarType[ScalarType["STRING"] = 9] = "STRING";
36
+ // Tag-delimited aggregate.
37
+ // Group type is deprecated and not supported in proto3. However, Proto3
38
+ // implementations should still be able to parse the group wire format and
39
+ // treat group fields as unknown fields.
40
+ // TYPE_GROUP = 10,
41
+ // TYPE_MESSAGE = 11, // Length-delimited aggregate.
42
+ // New in version 2.
43
+ ScalarType[ScalarType["BYTES"] = 12] = "BYTES";
44
+ ScalarType[ScalarType["UINT32"] = 13] = "UINT32";
45
+ // TYPE_ENUM = 14,
46
+ ScalarType[ScalarType["SFIXED32"] = 15] = "SFIXED32";
47
+ ScalarType[ScalarType["SFIXED64"] = 16] = "SFIXED64";
48
+ ScalarType[ScalarType["SINT32"] = 17] = "SINT32";
49
+ ScalarType[ScalarType["SINT64"] = 18] = "SINT64";
50
+ })(ScalarType || (ScalarType = {}));