@bufbuild/protobuf 0.0.1 → 0.0.2-alpha.3

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 (115) hide show
  1. package/README.md +1 -21
  2. package/dist/cjs/binary-encoding.js +21 -8
  3. package/dist/cjs/binary-format.js +13 -0
  4. package/dist/cjs/descriptor-registry.js +13 -0
  5. package/dist/cjs/descriptor-set.js +13 -0
  6. package/dist/cjs/enum.js +13 -0
  7. package/dist/cjs/field-list.js +13 -0
  8. package/dist/cjs/field.js +13 -0
  9. package/dist/cjs/google/protobuf/any_pb.js +13 -33
  10. package/dist/cjs/google/protobuf/api_pb.js +10 -30
  11. package/dist/cjs/google/protobuf/compiler/plugin_pb.js +10 -45
  12. package/dist/cjs/google/protobuf/descriptor_pb.js +13 -39
  13. package/dist/cjs/google/protobuf/duration_pb.js +10 -30
  14. package/dist/cjs/google/protobuf/empty_pb.js +10 -30
  15. package/dist/cjs/google/protobuf/field_mask_pb.js +10 -30
  16. package/dist/cjs/google/protobuf/source_context_pb.js +10 -30
  17. package/dist/cjs/google/protobuf/struct_pb.js +10 -30
  18. package/dist/cjs/google/protobuf/timestamp_pb.js +10 -30
  19. package/dist/cjs/google/protobuf/type_pb.js +10 -30
  20. package/dist/cjs/google/protobuf/wrappers_pb.js +10 -39
  21. package/dist/cjs/{private/goog-varint.js → google/varint.js} +0 -0
  22. package/dist/cjs/index.js +21 -2
  23. package/dist/cjs/json-format.js +13 -0
  24. package/dist/cjs/message-type.js +13 -0
  25. package/dist/cjs/message.js +18 -6
  26. package/dist/cjs/private/assert.js +13 -0
  27. package/dist/cjs/private/binary-format-common.js +13 -0
  28. package/dist/cjs/private/binary-format-proto2.js +13 -0
  29. package/dist/cjs/private/binary-format-proto3.js +13 -0
  30. package/dist/cjs/private/enum.js +39 -1
  31. package/dist/cjs/private/field-list.js +13 -0
  32. package/dist/cjs/private/field-wrapper.js +13 -0
  33. package/dist/cjs/private/field.js +13 -0
  34. package/dist/cjs/private/json-format-common.js +16 -3
  35. package/dist/cjs/private/json-format-proto2.js +13 -0
  36. package/dist/cjs/private/json-format-proto3.js +13 -0
  37. package/dist/cjs/private/message-type.js +13 -0
  38. package/dist/cjs/private/names.js +13 -0
  39. package/dist/cjs/private/options-map.js +13 -0
  40. package/dist/cjs/private/proto-runtime.js +14 -0
  41. package/dist/cjs/private/scalars.js +13 -0
  42. package/dist/cjs/private/util-common.js +16 -3
  43. package/dist/cjs/private/util.js +13 -0
  44. package/dist/cjs/proto-base64.js +138 -0
  45. package/dist/cjs/proto-int64.js +19 -6
  46. package/dist/cjs/proto2.js +13 -0
  47. package/dist/cjs/proto3.js +13 -0
  48. package/dist/cjs/service-type.js +13 -0
  49. package/dist/cjs/type-registry.js +13 -0
  50. package/dist/esm/binary-encoding.js +14 -1
  51. package/dist/esm/binary-format.js +13 -0
  52. package/dist/esm/descriptor-registry.js +13 -0
  53. package/dist/esm/descriptor-set.js +13 -0
  54. package/dist/esm/enum.js +13 -0
  55. package/dist/esm/field-list.js +13 -0
  56. package/dist/esm/field.js +13 -0
  57. package/dist/esm/google/protobuf/any_pb.js +13 -33
  58. package/dist/esm/google/protobuf/api_pb.js +10 -30
  59. package/dist/esm/google/protobuf/compiler/plugin_pb.js +10 -45
  60. package/dist/esm/google/protobuf/descriptor_pb.js +13 -39
  61. package/dist/esm/google/protobuf/duration_pb.js +10 -30
  62. package/dist/esm/google/protobuf/empty_pb.js +10 -30
  63. package/dist/esm/google/protobuf/field_mask_pb.js +10 -30
  64. package/dist/esm/google/protobuf/source_context_pb.js +10 -30
  65. package/dist/esm/google/protobuf/struct_pb.js +10 -30
  66. package/dist/esm/google/protobuf/timestamp_pb.js +10 -30
  67. package/dist/esm/google/protobuf/type_pb.js +10 -30
  68. package/dist/esm/google/protobuf/wrappers_pb.js +10 -39
  69. package/dist/esm/{private/goog-varint.js → google/varint.js} +0 -0
  70. package/dist/esm/index.js +14 -0
  71. package/dist/esm/json-format.js +13 -0
  72. package/dist/esm/message-type.js +13 -0
  73. package/dist/esm/message.js +18 -6
  74. package/dist/esm/private/assert.js +13 -0
  75. package/dist/esm/private/binary-format-common.js +13 -0
  76. package/dist/esm/private/binary-format-proto2.js +13 -0
  77. package/dist/esm/private/binary-format-proto3.js +13 -0
  78. package/dist/esm/private/enum.js +37 -0
  79. package/dist/esm/private/field-list.js +13 -0
  80. package/dist/esm/private/field-wrapper.js +13 -0
  81. package/dist/esm/private/field.js +13 -0
  82. package/dist/esm/private/json-format-common.js +16 -3
  83. package/dist/esm/private/json-format-proto2.js +13 -0
  84. package/dist/esm/private/json-format-proto3.js +13 -0
  85. package/dist/esm/private/message-type.js +13 -0
  86. package/dist/esm/private/names.js +13 -0
  87. package/dist/esm/private/options-map.js +13 -0
  88. package/dist/esm/private/proto-runtime.js +15 -1
  89. package/dist/esm/private/scalars.js +13 -0
  90. package/dist/esm/private/util-common.js +16 -3
  91. package/dist/esm/private/util.js +13 -0
  92. package/dist/esm/proto-base64.js +135 -0
  93. package/dist/esm/proto-int64.js +14 -1
  94. package/dist/esm/proto2.js +13 -0
  95. package/dist/esm/proto3.js +13 -0
  96. package/dist/esm/service-type.js +13 -0
  97. package/dist/esm/type-registry.js +13 -0
  98. package/dist/types/google/protobuf/any_pb.d.ts +3 -3
  99. package/dist/types/google/protobuf/descriptor_pb.d.ts +16 -3
  100. package/dist/types/{private/goog-varint.d.ts → google/varint.d.ts} +0 -0
  101. package/dist/types/index.d.ts +2 -1
  102. package/dist/types/json-format.d.ts +1 -1
  103. package/dist/types/message-type.d.ts +4 -3
  104. package/dist/types/message.d.ts +16 -15
  105. package/dist/types/private/enum.d.ts +9 -0
  106. package/dist/types/private/field-wrapper.d.ts +3 -3
  107. package/dist/types/private/message-type.d.ts +12 -2
  108. package/dist/types/private/proto-runtime.d.ts +18 -13
  109. package/dist/types/private/util.d.ts +4 -4
  110. package/dist/types/proto-base64.d.ts +26 -0
  111. package/dist/types/service-type.d.ts +7 -7
  112. package/package.json +3 -4
  113. package/dist/cjs/private/base64.js +0 -119
  114. package/dist/esm/private/base64.js +0 -114
  115. package/dist/types/private/base64.d.ts +0 -18
@@ -1,11 +1,24 @@
1
1
  "use strict";
2
+ // Copyright 2021-2022 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.
2
15
  Object.defineProperty(exports, "__esModule", { value: true });
3
16
  exports.makeJsonFormatCommon = void 0;
4
17
  const field_wrapper_js_1 = require("./field-wrapper.js");
5
18
  const field_js_1 = require("../field.js");
6
19
  const assert_js_1 = require("./assert.js");
7
20
  const proto_int64_js_1 = require("../proto-int64.js");
8
- const base64_js_1 = require("./base64.js");
21
+ const proto_base64_js_1 = require("../proto-base64.js");
9
22
  /* eslint-disable no-case-declarations, @typescript-eslint/restrict-plus-operands,@typescript-eslint/no-explicit-any,@typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-argument */
10
23
  // Default options for parsing JSON.
11
24
  const jsonReadDefaults = {
@@ -354,7 +367,7 @@ function readScalar(type, json) {
354
367
  return new Uint8Array(0);
355
368
  if (typeof json !== "string")
356
369
  break;
357
- return (0, base64_js_1.base64decode)(json);
370
+ return proto_base64_js_1.protoBase64.dec(json);
358
371
  }
359
372
  throw new Error();
360
373
  }
@@ -450,7 +463,7 @@ function writeScalar(type, value, emitIntrinsicDefault) {
450
463
  case field_js_1.ScalarType.BYTES:
451
464
  (0, assert_js_1.assert)(value instanceof Uint8Array);
452
465
  return emitIntrinsicDefault || value.byteLength > 0
453
- ? (0, base64_js_1.base64encode)(value)
466
+ ? proto_base64_js_1.protoBase64.enc(value)
454
467
  : undefined;
455
468
  }
456
469
  }
@@ -1,4 +1,17 @@
1
1
  "use strict";
2
+ // Copyright 2021-2022 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.
2
15
  Object.defineProperty(exports, "__esModule", { value: true });
3
16
  exports.makeJsonFormatProto2 = void 0;
4
17
  const field_wrapper_js_1 = require("./field-wrapper.js");
@@ -1,4 +1,17 @@
1
1
  "use strict";
2
+ // Copyright 2021-2022 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.
2
15
  Object.defineProperty(exports, "__esModule", { value: true });
3
16
  exports.makeJsonFormatProto3 = void 0;
4
17
  const field_wrapper_js_1 = require("./field-wrapper.js");
@@ -1,4 +1,17 @@
1
1
  "use strict";
2
+ // Copyright 2021-2022 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.
2
15
  Object.defineProperty(exports, "__esModule", { value: true });
3
16
  exports.makeMessageType = void 0;
4
17
  const message_js_1 = require("../message.js");
@@ -1,4 +1,17 @@
1
1
  "use strict";
2
+ // Copyright 2021-2022 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.
2
15
  Object.defineProperty(exports, "__esModule", { value: true });
3
16
  exports.makeMethodName = exports.makeOneofName = exports.makeFieldName = exports.makeJsonName = void 0;
4
17
  /**
@@ -1,2 +1,15 @@
1
1
  "use strict";
2
+ // Copyright 2021-2022 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.
2
15
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,4 +1,17 @@
1
1
  "use strict";
2
+ // Copyright 2021-2022 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.
2
15
  Object.defineProperty(exports, "__esModule", { value: true });
3
16
  exports.makeProtoRuntime = void 0;
4
17
  const enum_js_1 = require("./enum.js");
@@ -12,6 +25,7 @@ function makeProtoRuntime(syntax, json, bin, util) {
12
25
  makeMessageType(typeName, fields, opt) {
13
26
  return (0, message_type_js_1.makeMessageType)(this, typeName, fields, opt);
14
27
  },
28
+ makeEnum: enum_js_1.makeEnum,
15
29
  makeEnumType: enum_js_1.makeEnumType,
16
30
  getEnumType: enum_js_1.getEnumType,
17
31
  };
@@ -1,4 +1,17 @@
1
1
  "use strict";
2
+ // Copyright 2021-2022 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.
2
15
  Object.defineProperty(exports, "__esModule", { value: true });
3
16
  exports.scalarTypeInfo = exports.scalarDefaultValue = exports.scalarEquals = void 0;
4
17
  const field_js_1 = require("../field.js");
@@ -1,4 +1,17 @@
1
1
  "use strict";
2
+ // Copyright 2021-2022 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.
2
15
  Object.defineProperty(exports, "__esModule", { value: true });
3
16
  exports.makeUtilCommon = void 0;
4
17
  const enum_js_1 = require("./enum.js");
@@ -145,7 +158,7 @@ function makeUtilCommon() {
145
158
  });
146
159
  },
147
160
  clone(message) {
148
- const type = message.getType(), target = new type();
161
+ const type = message.getType(), target = new type(), any = target;
149
162
  for (const member of type.fields.byMember()) {
150
163
  const source = message[member.localName];
151
164
  let copy;
@@ -153,7 +166,7 @@ function makeUtilCommon() {
153
166
  copy = source.map((e) => cloneSingularField(member, e));
154
167
  }
155
168
  else if (member.kind == "map") {
156
- copy = target[member.localName];
169
+ copy = any[member.localName];
157
170
  for (const [key, v] of Object.entries(source)) {
158
171
  copy[key] = cloneSingularField(member.V, v);
159
172
  }
@@ -167,7 +180,7 @@ function makeUtilCommon() {
167
180
  else {
168
181
  copy = cloneSingularField(member, source);
169
182
  }
170
- target[member.localName] = copy;
183
+ any[member.localName] = copy;
171
184
  }
172
185
  return target;
173
186
  },
@@ -1,2 +1,15 @@
1
1
  "use strict";
2
+ // Copyright 2021-2022 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.
2
15
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,138 @@
1
+ "use strict";
2
+ // Copyright 2021-2022 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.protoBase64 = void 0;
17
+ /* eslint-disable @typescript-eslint/ban-ts-comment, @typescript-eslint/no-unnecessary-condition, prefer-const */
18
+ // lookup table from base64 character to byte
19
+ let encTable = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");
20
+ // lookup table from base64 character *code* to byte because lookup by number is fast
21
+ let decTable = [];
22
+ for (let i = 0; i < encTable.length; i++)
23
+ decTable[encTable[i].charCodeAt(0)] = i;
24
+ // support base64url variants
25
+ decTable["-".charCodeAt(0)] = encTable.indexOf("+");
26
+ decTable["_".charCodeAt(0)] = encTable.indexOf("/");
27
+ exports.protoBase64 = {
28
+ /**
29
+ * Decodes a base64 string to a byte array.
30
+ *
31
+ * - ignores white-space, including line breaks and tabs
32
+ * - allows inner padding (can decode concatenated base64 strings)
33
+ * - does not require padding
34
+ * - understands base64url encoding:
35
+ * "-" instead of "+",
36
+ * "_" instead of "/",
37
+ * no padding
38
+ */
39
+ dec(base64Str) {
40
+ // estimate byte size, not accounting for inner padding and whitespace
41
+ let es = (base64Str.length * 3) / 4;
42
+ // if (es % 3 !== 0)
43
+ // throw new Error("invalid base64 string");
44
+ if (base64Str[base64Str.length - 2] == "=")
45
+ es -= 2;
46
+ else if (base64Str[base64Str.length - 1] == "=")
47
+ es -= 1;
48
+ let bytes = new Uint8Array(es), bytePos = 0, // position in byte array
49
+ groupPos = 0, // position in base64 group
50
+ b, // current byte
51
+ p = 0; // previous byte
52
+ for (let i = 0; i < base64Str.length; i++) {
53
+ b = decTable[base64Str.charCodeAt(i)];
54
+ if (b === undefined) {
55
+ switch (base64Str[i]) {
56
+ // @ts-ignore TS7029: Fallthrough case in switch
57
+ case "=":
58
+ groupPos = 0; // reset state when padding found
59
+ // @ts-ignore TS7029: Fallthrough case in switch
60
+ case "\n":
61
+ case "\r":
62
+ case "\t":
63
+ case " ":
64
+ continue; // skip white-space, and padding
65
+ default:
66
+ throw Error("invalid base64 string.");
67
+ }
68
+ }
69
+ switch (groupPos) {
70
+ case 0:
71
+ p = b;
72
+ groupPos = 1;
73
+ break;
74
+ case 1:
75
+ bytes[bytePos++] = (p << 2) | ((b & 48) >> 4);
76
+ p = b;
77
+ groupPos = 2;
78
+ break;
79
+ case 2:
80
+ bytes[bytePos++] = ((p & 15) << 4) | ((b & 60) >> 2);
81
+ p = b;
82
+ groupPos = 3;
83
+ break;
84
+ case 3:
85
+ bytes[bytePos++] = ((p & 3) << 6) | b;
86
+ groupPos = 0;
87
+ break;
88
+ }
89
+ }
90
+ if (groupPos == 1)
91
+ throw Error("invalid base64 string.");
92
+ return bytes.subarray(0, bytePos);
93
+ },
94
+ /**
95
+ * Decodes a base64 string to a byte array.
96
+ *
97
+ * - ignores white-space, including line breaks and tabs
98
+ * - allows inner padding (can decode concatenated base64 strings)
99
+ * - does not require padding
100
+ * - understands base64url encoding:
101
+ * "-" instead of "+",
102
+ * "_" instead of "/",
103
+ * no padding
104
+ */
105
+ enc(bytes) {
106
+ let base64 = "", groupPos = 0, // position in base64 group
107
+ b, // current byte
108
+ p = 0; // carry over from previous byte
109
+ for (let i = 0; i < bytes.length; i++) {
110
+ b = bytes[i];
111
+ switch (groupPos) {
112
+ case 0:
113
+ base64 += encTable[b >> 2];
114
+ p = (b & 3) << 4;
115
+ groupPos = 1;
116
+ break;
117
+ case 1:
118
+ base64 += encTable[p | (b >> 4)];
119
+ p = (b & 15) << 2;
120
+ groupPos = 2;
121
+ break;
122
+ case 2:
123
+ base64 += encTable[p | (b >> 6)];
124
+ base64 += encTable[b & 63];
125
+ groupPos = 0;
126
+ break;
127
+ }
128
+ }
129
+ // padding required?
130
+ if (groupPos) {
131
+ base64 += encTable[p];
132
+ base64 += "=";
133
+ if (groupPos == 1)
134
+ base64 += "=";
135
+ }
136
+ return base64;
137
+ },
138
+ };
@@ -1,7 +1,20 @@
1
1
  "use strict";
2
+ // Copyright 2021-2022 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.
2
15
  Object.defineProperty(exports, "__esModule", { value: true });
3
16
  exports.protoInt64 = void 0;
4
- const goog_varint_js_1 = require("./private/goog-varint.js");
17
+ const varint_js_1 = require("./google/varint.js");
5
18
  function makeInt64Support() {
6
19
  const dv = new DataView(new ArrayBuffer(8));
7
20
  // note that Safari 14 implements BigInt, but not the DataView methods
@@ -79,7 +92,7 @@ function makeInt64Support() {
79
92
  else {
80
93
  value = value.toString(10);
81
94
  }
82
- const [, lo, hi] = (0, goog_varint_js_1.int64fromString)(value);
95
+ const [, lo, hi] = (0, varint_js_1.int64fromString)(value);
83
96
  return { lo, hi };
84
97
  },
85
98
  uEnc(value) {
@@ -91,7 +104,7 @@ function makeInt64Support() {
91
104
  else {
92
105
  value = value.toString(10);
93
106
  }
94
- const [minus, lo, hi] = (0, goog_varint_js_1.int64fromString)(value);
107
+ const [minus, lo, hi] = (0, varint_js_1.int64fromString)(value);
95
108
  if (minus) {
96
109
  throw new Error(`uint64 invalid: ${value}`);
97
110
  }
@@ -108,12 +121,12 @@ function makeInt64Support() {
108
121
  else {
109
122
  hi += 1;
110
123
  }
111
- return ("-" + (0, goog_varint_js_1.int64toString)(lo, hi));
124
+ return ("-" + (0, varint_js_1.int64toString)(lo, hi));
112
125
  }
113
- return (0, goog_varint_js_1.int64toString)(lo, hi);
126
+ return (0, varint_js_1.int64toString)(lo, hi);
114
127
  },
115
128
  uDec(lo, hi) {
116
- return (0, goog_varint_js_1.int64toString)(lo, hi);
129
+ return (0, varint_js_1.int64toString)(lo, hi);
117
130
  },
118
131
  };
119
132
  }
@@ -1,4 +1,17 @@
1
1
  "use strict";
2
+ // Copyright 2021-2022 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.
2
15
  Object.defineProperty(exports, "__esModule", { value: true });
3
16
  exports.proto2 = void 0;
4
17
  const proto_runtime_js_1 = require("./private/proto-runtime.js");
@@ -1,4 +1,17 @@
1
1
  "use strict";
2
+ // Copyright 2021-2022 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.
2
15
  Object.defineProperty(exports, "__esModule", { value: true });
3
16
  exports.proto3 = void 0;
4
17
  const proto_runtime_js_1 = require("./private/proto-runtime.js");
@@ -1,4 +1,17 @@
1
1
  "use strict";
2
+ // Copyright 2021-2022 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.
2
15
  Object.defineProperty(exports, "__esModule", { value: true });
3
16
  exports.MethodIdempotency = exports.MethodKind = void 0;
4
17
  /**
@@ -1,4 +1,17 @@
1
1
  "use strict";
2
+ // Copyright 2021-2022 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.
2
15
  Object.defineProperty(exports, "__esModule", { value: true });
3
16
  exports.TypeRegistry = void 0;
4
17
  /**
@@ -1,4 +1,17 @@
1
- import { varint32read, varint32write, varint64read, varint64write, } from "./private/goog-varint.js";
1
+ // Copyright 2021-2022 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 { varint32read, varint32write, varint64read, varint64write, } from "./google/varint.js";
2
15
  import { assertFloat32, assertInt32, assertUInt32 } from "./private/assert.js";
3
16
  import { protoInt64 } from "./proto-int64.js";
4
17
  /* eslint-disable prefer-const,no-case-declarations,@typescript-eslint/restrict-plus-operands */
@@ -1 +1,14 @@
1
+ // Copyright 2021-2022 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.
1
14
  export {};
@@ -1,3 +1,16 @@
1
+ // Copyright 2021-2022 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.
1
14
  import { assert } from "./private/assert.js";
2
15
  import { proto3 } from "./proto3.js";
3
16
  import { proto2 } from "./proto2.js";
@@ -1,3 +1,16 @@
1
+ // Copyright 2021-2022 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.
1
14
  import { FieldDescriptorProto_Label, FieldDescriptorProto_Type, MethodOptions_IdempotencyLevel, } from "./google/protobuf/descriptor_pb.js";
2
15
  import { assert } from "./private/assert.js";
3
16
  import { ScalarType } from "./field.js";
package/dist/esm/enum.js CHANGED
@@ -1 +1,14 @@
1
+ // Copyright 2021-2022 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.
1
14
  export {};
@@ -1 +1,14 @@
1
+ // Copyright 2021-2022 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.
1
14
  export {};
package/dist/esm/field.js CHANGED
@@ -1,3 +1,16 @@
1
+ // Copyright 2021-2022 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.
1
14
  /**
2
15
  * Scalar value types. This is a subset of field types declared by protobuf
3
16
  * enum google.protobuf.FieldDescriptorProto.Type The types GROUP and MESSAGE