@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,119 +0,0 @@
1
- "use strict";
2
- /* eslint-disable @typescript-eslint/ban-ts-comment, @typescript-eslint/no-unnecessary-condition, prefer-const */
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.base64encode = exports.base64decode = void 0;
5
- // lookup table from base64 character to byte
6
- let encTable = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");
7
- // lookup table from base64 character *code* to byte because lookup by number is fast
8
- let decTable = [];
9
- for (let i = 0; i < encTable.length; i++)
10
- decTable[encTable[i].charCodeAt(0)] = i;
11
- // support base64url variants
12
- decTable["-".charCodeAt(0)] = encTable.indexOf("+");
13
- decTable["_".charCodeAt(0)] = encTable.indexOf("/");
14
- /**
15
- * Decodes a base64 string to a byte array.
16
- *
17
- * - ignores white-space, including line breaks and tabs
18
- * - allows inner padding (can decode concatenated base64 strings)
19
- * - does not require padding
20
- * - understands base64url encoding:
21
- * "-" instead of "+",
22
- * "_" instead of "/",
23
- * no padding
24
- */
25
- function base64decode(base64Str) {
26
- // estimate byte size, not accounting for inner padding and whitespace
27
- let es = (base64Str.length * 3) / 4;
28
- // if (es % 3 !== 0)
29
- // throw new Error("invalid base64 string");
30
- if (base64Str[base64Str.length - 2] == "=")
31
- es -= 2;
32
- else if (base64Str[base64Str.length - 1] == "=")
33
- es -= 1;
34
- let bytes = new Uint8Array(es), bytePos = 0, // position in byte array
35
- groupPos = 0, // position in base64 group
36
- b, // current byte
37
- p = 0; // previous byte
38
- for (let i = 0; i < base64Str.length; i++) {
39
- b = decTable[base64Str.charCodeAt(i)];
40
- if (b === undefined) {
41
- switch (base64Str[i]) {
42
- // @ts-ignore TS7029: Fallthrough case in switch
43
- case "=":
44
- groupPos = 0; // reset state when padding found
45
- // @ts-ignore TS7029: Fallthrough case in switch
46
- case "\n":
47
- case "\r":
48
- case "\t":
49
- case " ":
50
- continue; // skip white-space, and padding
51
- default:
52
- throw Error("invalid base64 string.");
53
- }
54
- }
55
- switch (groupPos) {
56
- case 0:
57
- p = b;
58
- groupPos = 1;
59
- break;
60
- case 1:
61
- bytes[bytePos++] = (p << 2) | ((b & 48) >> 4);
62
- p = b;
63
- groupPos = 2;
64
- break;
65
- case 2:
66
- bytes[bytePos++] = ((p & 15) << 4) | ((b & 60) >> 2);
67
- p = b;
68
- groupPos = 3;
69
- break;
70
- case 3:
71
- bytes[bytePos++] = ((p & 3) << 6) | b;
72
- groupPos = 0;
73
- break;
74
- }
75
- }
76
- if (groupPos == 1)
77
- throw Error("invalid base64 string.");
78
- return bytes.subarray(0, bytePos);
79
- }
80
- exports.base64decode = base64decode;
81
- /**
82
- * Encodes a byte array to a base64 string.
83
- * Adds padding at the end.
84
- * Does not insert newlines.
85
- */
86
- function base64encode(bytes) {
87
- let base64 = "", groupPos = 0, // position in base64 group
88
- b, // current byte
89
- p = 0; // carry over from previous byte
90
- for (let i = 0; i < bytes.length; i++) {
91
- b = bytes[i];
92
- switch (groupPos) {
93
- case 0:
94
- base64 += encTable[b >> 2];
95
- p = (b & 3) << 4;
96
- groupPos = 1;
97
- break;
98
- case 1:
99
- base64 += encTable[p | (b >> 4)];
100
- p = (b & 15) << 2;
101
- groupPos = 2;
102
- break;
103
- case 2:
104
- base64 += encTable[p | (b >> 6)];
105
- base64 += encTable[b & 63];
106
- groupPos = 0;
107
- break;
108
- }
109
- }
110
- // padding required?
111
- if (groupPos) {
112
- base64 += encTable[p];
113
- base64 += "=";
114
- if (groupPos == 1)
115
- base64 += "=";
116
- }
117
- return base64;
118
- }
119
- exports.base64encode = base64encode;
@@ -1,114 +0,0 @@
1
- /* eslint-disable @typescript-eslint/ban-ts-comment, @typescript-eslint/no-unnecessary-condition, prefer-const */
2
- // lookup table from base64 character to byte
3
- let encTable = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");
4
- // lookup table from base64 character *code* to byte because lookup by number is fast
5
- let decTable = [];
6
- for (let i = 0; i < encTable.length; i++)
7
- decTable[encTable[i].charCodeAt(0)] = i;
8
- // support base64url variants
9
- decTable["-".charCodeAt(0)] = encTable.indexOf("+");
10
- decTable["_".charCodeAt(0)] = encTable.indexOf("/");
11
- /**
12
- * Decodes a base64 string to a byte array.
13
- *
14
- * - ignores white-space, including line breaks and tabs
15
- * - allows inner padding (can decode concatenated base64 strings)
16
- * - does not require padding
17
- * - understands base64url encoding:
18
- * "-" instead of "+",
19
- * "_" instead of "/",
20
- * no padding
21
- */
22
- export function base64decode(base64Str) {
23
- // estimate byte size, not accounting for inner padding and whitespace
24
- let es = (base64Str.length * 3) / 4;
25
- // if (es % 3 !== 0)
26
- // throw new Error("invalid base64 string");
27
- if (base64Str[base64Str.length - 2] == "=")
28
- es -= 2;
29
- else if (base64Str[base64Str.length - 1] == "=")
30
- es -= 1;
31
- let bytes = new Uint8Array(es), bytePos = 0, // position in byte array
32
- groupPos = 0, // position in base64 group
33
- b, // current byte
34
- p = 0; // previous byte
35
- for (let i = 0; i < base64Str.length; i++) {
36
- b = decTable[base64Str.charCodeAt(i)];
37
- if (b === undefined) {
38
- switch (base64Str[i]) {
39
- // @ts-ignore TS7029: Fallthrough case in switch
40
- case "=":
41
- groupPos = 0; // reset state when padding found
42
- // @ts-ignore TS7029: Fallthrough case in switch
43
- case "\n":
44
- case "\r":
45
- case "\t":
46
- case " ":
47
- continue; // skip white-space, and padding
48
- default:
49
- throw Error("invalid base64 string.");
50
- }
51
- }
52
- switch (groupPos) {
53
- case 0:
54
- p = b;
55
- groupPos = 1;
56
- break;
57
- case 1:
58
- bytes[bytePos++] = (p << 2) | ((b & 48) >> 4);
59
- p = b;
60
- groupPos = 2;
61
- break;
62
- case 2:
63
- bytes[bytePos++] = ((p & 15) << 4) | ((b & 60) >> 2);
64
- p = b;
65
- groupPos = 3;
66
- break;
67
- case 3:
68
- bytes[bytePos++] = ((p & 3) << 6) | b;
69
- groupPos = 0;
70
- break;
71
- }
72
- }
73
- if (groupPos == 1)
74
- throw Error("invalid base64 string.");
75
- return bytes.subarray(0, bytePos);
76
- }
77
- /**
78
- * Encodes a byte array to a base64 string.
79
- * Adds padding at the end.
80
- * Does not insert newlines.
81
- */
82
- export function base64encode(bytes) {
83
- let base64 = "", groupPos = 0, // position in base64 group
84
- b, // current byte
85
- p = 0; // carry over from previous byte
86
- for (let i = 0; i < bytes.length; i++) {
87
- b = bytes[i];
88
- switch (groupPos) {
89
- case 0:
90
- base64 += encTable[b >> 2];
91
- p = (b & 3) << 4;
92
- groupPos = 1;
93
- break;
94
- case 1:
95
- base64 += encTable[p | (b >> 4)];
96
- p = (b & 15) << 2;
97
- groupPos = 2;
98
- break;
99
- case 2:
100
- base64 += encTable[p | (b >> 6)];
101
- base64 += encTable[b & 63];
102
- groupPos = 0;
103
- break;
104
- }
105
- }
106
- // padding required?
107
- if (groupPos) {
108
- base64 += encTable[p];
109
- base64 += "=";
110
- if (groupPos == 1)
111
- base64 += "=";
112
- }
113
- return base64;
114
- }
@@ -1,18 +0,0 @@
1
- /**
2
- * Decodes a base64 string to a byte array.
3
- *
4
- * - ignores white-space, including line breaks and tabs
5
- * - allows inner padding (can decode concatenated base64 strings)
6
- * - does not require padding
7
- * - understands base64url encoding:
8
- * "-" instead of "+",
9
- * "_" instead of "/",
10
- * no padding
11
- */
12
- export declare function base64decode(base64Str: string): Uint8Array;
13
- /**
14
- * Encodes a byte array to a base64 string.
15
- * Adds padding at the end.
16
- * Does not insert newlines.
17
- */
18
- export declare function base64encode(bytes: Uint8Array): string;