@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,45 +1,16 @@
1
- /* eslint-disable */
2
- // @generated by protoc-gen-es v0.0.1 with parameter "bootstrap_wkt=true,ts_nocheck=false"
3
- // @generated from file google/protobuf/wrappers.proto (package google.protobuf, syntax proto3)
1
+ // Copyright 2021-2022 Buf Technologies, Inc.
4
2
  //
5
- // Protocol Buffers - Google's data interchange format
6
- // Copyright 2008 Google Inc. All rights reserved.
7
- // https://developers.google.com/protocol-buffers/
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
8
6
  //
9
- // Redistribution and use in source and binary forms, with or without
10
- // modification, are permitted provided that the following conditions are
11
- // met:
7
+ // http://www.apache.org/licenses/LICENSE-2.0
12
8
  //
13
- // * Redistributions of source code must retain the above copyright
14
- // notice, this list of conditions and the following disclaimer.
15
- // * Redistributions in binary form must reproduce the above
16
- // copyright notice, this list of conditions and the following disclaimer
17
- // in the documentation and/or other materials provided with the
18
- // distribution.
19
- // * Neither the name of Google Inc. nor the names of its
20
- // contributors may be used to endorse or promote products derived from
21
- // this software without specific prior written permission.
22
- //
23
- // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24
- // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25
- // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26
- // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27
- // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28
- // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29
- // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30
- // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31
- // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32
- // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33
- // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
- // Wrappers for primitive (non-message) types. These types are useful
35
- // for embedding primitives in the `google.protobuf.Any` type and for places
36
- // where we need to distinguish between the absence of a primitive
37
- // typed field and its default value.
38
- //
39
- // These wrappers have no meaningful use within repeated fields as they lack
40
- // the ability to detect presence on individual elements.
41
- // These wrappers have no meaningful use within a map or a oneof since
42
- // individual entries of a map or fields of a oneof can already detect presence.
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.
43
14
  import { Message, ScalarType, proto3, protoInt64 } from "../../index.js";
44
15
  /**
45
16
  * Wrapper message for `double`.
package/dist/esm/index.js CHANGED
@@ -1,6 +1,20 @@
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 { proto3 } from "./proto3.js";
2
15
  export { proto2 } from "./proto2.js";
3
16
  export { protoInt64 } from "./proto-int64.js";
17
+ export { protoBase64 } from "./proto-base64.js";
4
18
  export { Message, } from "./message.js";
5
19
  export { ScalarType } from "./field.js";
6
20
  export { MethodKind, MethodIdempotency } from "./service-type.js";
@@ -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 {};
@@ -1,23 +1,35 @@
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
- * Every message - generated or created at runtime - is an instance of this
3
- * class.
15
+ * Message is the base class of every message, generated, or created at
16
+ * runtime.
4
17
  *
5
- * It is unsafe to extend this class. If you want to create a message at run
6
- * time, use proto3.makeMessageType().
18
+ * It is _not_ safe to extend this class. If you want to create a message at
19
+ * run time, use proto3.makeMessageType().
7
20
  */
8
21
  export class Message {
9
- // TODO find better name to prevent field name conflicts?
10
22
  /**
11
23
  * Compare with a message of the same type.
12
24
  */
13
25
  equals(other) {
14
26
  return this.getType().runtime.util.equals(this.getType(), this, other);
15
27
  }
16
- // TODO find better name to prevent field name conflicts?
17
28
  /**
18
29
  * Create a deep copy.
19
30
  */
20
31
  clone() {
32
+ // return this.getType().runtime.util.clone(this);
21
33
  return this.getType().runtime.util.clone(this);
22
34
  }
23
35
  /**
@@ -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
  * Assert that condition is truthy or throw error (with message)
3
16
  */
@@ -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 { BinaryReader, BinaryWriter, WireType, } from "../binary-encoding.js";
2
15
  import { ScalarType } from "../field.js";
3
16
  import { unwrapField, wrapField } from "./field-wrapper.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 { ScalarType } from "../field.js";
2
15
  import { makeBinaryFormatCommon, writeMapEntry, writeMessageField, writePacked, writeScalar, } from "./binary-format-common.js";
3
16
  /* eslint-disable @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unnecessary-condition, @typescript-eslint/strict-boolean-expressions, no-case-declarations, prefer-const */
@@ -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 { ScalarType } from "../field.js";
2
15
  import { makeBinaryFormatCommon, writeMapEntry, writeMessageField, writePacked, writeScalar, } from "./binary-format-common.js";
3
16
  /* eslint-disable @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unnecessary-condition, @typescript-eslint/strict-boolean-expressions, prefer-const, no-case-declarations */
@@ -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 "./assert.js";
2
15
  const enumTypeSymbol = Symbol("@bufbuild/protobuf/enum-type");
3
16
  /**
@@ -57,3 +70,27 @@ export function makeEnumType(typeName, values
57
70
  },
58
71
  };
59
72
  }
73
+ /**
74
+ * Create a new enum object with the given values.
75
+ */
76
+ export function makeEnum(typeName, values, opt) {
77
+ const enumObject = {};
78
+ for (const value of values) {
79
+ const name = makeEnumValueName(value, opt?.sharedPrefix);
80
+ enumObject[name] = value.no;
81
+ enumObject[value.no] = name;
82
+ }
83
+ setEnumType(enumObject, typeName, values);
84
+ return enumObject;
85
+ }
86
+ // Construct a local name for an enum value.
87
+ // This logic matches the Go function with the same name in private/protoplugin/names.go
88
+ function makeEnumValueName(value, sharedPrefix) {
89
+ if (sharedPrefix === undefined) {
90
+ return value.name;
91
+ }
92
+ if (!value.name.startsWith(sharedPrefix)) {
93
+ return value.name;
94
+ }
95
+ return value.name.substring(sharedPrefix.length);
96
+ }
@@ -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
  export class InternalFieldList {
2
15
  constructor(fields, normalizer) {
3
16
  this._fields = fields;
@@ -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
  * Wrap field values whose message type has a wrapper.
3
16
  */
@@ -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 { makeOneofName } from "./names.js";
2
15
  import { assert } from "./assert.js";
3
16
  export class InternalOneofInfo {
@@ -1,8 +1,21 @@
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 { unwrapField, wrapField } from "./field-wrapper.js";
2
15
  import { ScalarType } from "../field.js";
3
16
  import { assert, assertFloat32, assertInt32, assertUInt32 } from "./assert.js";
4
17
  import { protoInt64 } from "../proto-int64.js";
5
- import { base64decode, base64encode } from "./base64.js";
18
+ import { protoBase64 } from "../proto-base64.js";
6
19
  /* 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 */
7
20
  // Default options for parsing JSON.
8
21
  const jsonReadDefaults = {
@@ -350,7 +363,7 @@ function readScalar(type, json) {
350
363
  return new Uint8Array(0);
351
364
  if (typeof json !== "string")
352
365
  break;
353
- return base64decode(json);
366
+ return protoBase64.dec(json);
354
367
  }
355
368
  throw new Error();
356
369
  }
@@ -446,7 +459,7 @@ function writeScalar(type, value, emitIntrinsicDefault) {
446
459
  case ScalarType.BYTES:
447
460
  assert(value instanceof Uint8Array);
448
461
  return emitIntrinsicDefault || value.byteLength > 0
449
- ? base64encode(value)
462
+ ? protoBase64.enc(value)
450
463
  : undefined;
451
464
  }
452
465
  }
@@ -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 { wrapField } from "./field-wrapper.js";
2
15
  import { assert } from "./assert.js";
3
16
  import { makeJsonFormatCommon } from "./json-format-common.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 { wrapField } from "./field-wrapper.js";
2
15
  import { assert } from "./assert.js";
3
16
  import { makeJsonFormatCommon } from "./json-format-common.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 { Message, } from "../message.js";
2
15
  /**
3
16
  * Create a new message type using the given runtime.
@@ -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
  * Returns the JSON name for a protobuf field, exactly like protoc does.
3
16
  */
@@ -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,4 +1,17 @@
1
- import { getEnumType, makeEnumType } from "./enum.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 { getEnumType, makeEnum, makeEnumType } from "./enum.js";
2
15
  import { makeMessageType } from "./message-type.js";
3
16
  export function makeProtoRuntime(syntax, json, bin, util) {
4
17
  return {
@@ -9,6 +22,7 @@ export function makeProtoRuntime(syntax, json, bin, util) {
9
22
  makeMessageType(typeName, fields, opt) {
10
23
  return makeMessageType(this, typeName, fields, opt);
11
24
  },
25
+ makeEnum,
12
26
  makeEnumType,
13
27
  getEnumType,
14
28
  };
@@ -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 { ScalarType } from "../field.js";
2
15
  import { WireType } from "../binary-encoding.js";
3
16
  import { protoInt64 } from "../proto-int64.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 { setEnumType } from "./enum.js";
2
15
  import { ScalarType } from "../field.js";
3
16
  import { scalarEquals } from "./scalars.js";
@@ -142,7 +155,7 @@ export function makeUtilCommon() {
142
155
  });
143
156
  },
144
157
  clone(message) {
145
- const type = message.getType(), target = new type();
158
+ const type = message.getType(), target = new type(), any = target;
146
159
  for (const member of type.fields.byMember()) {
147
160
  const source = message[member.localName];
148
161
  let copy;
@@ -150,7 +163,7 @@ export function makeUtilCommon() {
150
163
  copy = source.map((e) => cloneSingularField(member, e));
151
164
  }
152
165
  else if (member.kind == "map") {
153
- copy = target[member.localName];
166
+ copy = any[member.localName];
154
167
  for (const [key, v] of Object.entries(source)) {
155
168
  copy[key] = cloneSingularField(member.V, v);
156
169
  }
@@ -164,7 +177,7 @@ export function makeUtilCommon() {
164
177
  else {
165
178
  copy = cloneSingularField(member, source);
166
179
  }
167
- target[member.localName] = copy;
180
+ any[member.localName] = copy;
168
181
  }
169
182
  return target;
170
183
  },
@@ -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 {};