Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
179 changes: 172 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"@types/node": "^24.1.0",
"jest": "^29.7.0",
"turbo": "^2.5.5",
"typescript": "~5.6.3"
"typescript": "^5.9.2"
},
"//": "avoid hoisting of @typescript/vfs, see packages/protoplugin/src/transpile.ts",
"dependencies": {
Expand Down
10 changes: 5 additions & 5 deletions packages/bundle-size/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ usually do. We repeat this for an increasing number of files.

| code generator | files | bundle size | minified | compressed |
| ------------------- | ----: | ----------: | --------: | ---------: |
| Protobuf-ES | 1 | 132,159 b | 68,489 b | 15,756 b |
| Protobuf-ES | 4 | 134,348 b | 69,996 b | 16,428 b |
| Protobuf-ES | 8 | 137,110 b | 71,767 b | 16,932 b |
| Protobuf-ES | 16 | 147,560 b | 79,748 b | 19,320 b |
| Protobuf-ES | 32 | 175,351 b | 101,766 b | 24,771 b |
| Protobuf-ES | 1 | 132,341 b | 68,489 b | 15,756 b |
| Protobuf-ES | 4 | 134,530 b | 69,996 b | 16,428 b |
| Protobuf-ES | 8 | 137,292 b | 71,767 b | 16,932 b |
| Protobuf-ES | 16 | 147,742 b | 79,748 b | 19,320 b |
| Protobuf-ES | 32 | 175,533 b | 101,766 b | 24,771 b |
| protobuf-javascript | 1 | 104,048 b | 70,320 b | 15,540 b |
| protobuf-javascript | 4 | 130,537 b | 85,672 b | 16,956 b |
| protobuf-javascript | 8 | 152,429 b | 98,044 b | 18,138 b |
Expand Down
5 changes: 4 additions & 1 deletion packages/protobuf-conformance/src/conformance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,10 @@ async function* readMessages<Desc extends DescMessage>(
messageDesc: Desc,
): AsyncIterable<MessageShape<Desc>> {
// append chunk to buffer, returning updated buffer
function append(buffer: Uint8Array, chunk: Uint8Array): Uint8Array {
function append(
buffer: Uint8Array<ArrayBuffer>,
chunk: Uint8Array,
): Uint8Array<ArrayBuffer> {
const n = new Uint8Array(buffer.byteLength + chunk.byteLength);
n.set(buffer);
n.set(chunk, buffer.byteLength);
Expand Down
2 changes: 1 addition & 1 deletion packages/protobuf-test/src/wire/text-encoding.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ describe("configureTextEncoding()", () => {
configureTextEncoding({
checkUtf8: backup.checkUtf8,
decodeUtf8: backup.decodeUtf8,
encodeUtf8(text: string): Uint8Array {
encodeUtf8(text: string) {
arg = text;
return new Uint8Array(10);
},
Expand Down
2 changes: 1 addition & 1 deletion packages/protobuf/src/to-binary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export function toBinary<Desc extends DescMessage>(
schema: Desc,
message: MessageShape<Desc>,
options?: Partial<BinaryWriteOptions>,
): Uint8Array {
): Uint8Array<ArrayBuffer> {
return writeFields(
new BinaryWriter(),
makeWriteOptions(options),
Expand Down
4 changes: 2 additions & 2 deletions packages/protobuf/src/wire/base64-encoding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* "_" instead of "/",
* no padding
*/
export function base64Decode(base64Str: string) {
export function base64Decode(base64Str: string): Uint8Array<ArrayBuffer> {
const table = getDecodeTable();
// estimate byte size, not accounting for inner padding and whitespace
let es = (base64Str.length * 3) / 4;
Expand All @@ -39,7 +39,7 @@ export function base64Decode(base64Str: string) {
b = table[base64Str.charCodeAt(i)];
if (b === undefined) {
switch (base64Str[i]) {
// @ts-expect-error TS7029: Fallthrough case in switch
// @ts-ignore TS7029: Fallthrough case in switch -- ignore instead of expect-error for compiler settings without noFallthroughCasesInSwitch: true
case "=":
groupPos = 0; // reset state when padding found
case "\n":
Expand Down
4 changes: 2 additions & 2 deletions packages/protobuf/src/wire/binary-encoding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ export class BinaryWriter {
/**
* Return all bytes written and reset this writer.
*/
finish(): Uint8Array {
finish(): Uint8Array<ArrayBuffer> {
if (this.buf.length) {
this.chunks.push(new Uint8Array(this.buf)); // flush the buffer
this.buf = [];
Expand Down Expand Up @@ -412,7 +412,7 @@ export class BinaryReader {
// ignore
}
break;
// @ts-expect-error TS7029: Fallthrough case in switch
// @ts-ignore TS7029: Fallthrough case in switch -- ignore instead of expect-error for compiler settings without noFallthroughCasesInSwitch: true
case WireType.Bit64:
this.pos += 4;
case WireType.Bit32:
Expand Down
5 changes: 4 additions & 1 deletion packages/protobuf/src/wire/size-delimited.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ export async function* sizeDelimitedDecodeStream<Desc extends DescMessage>(
options?: BinaryReadOptions,
): AsyncIterableIterator<MessageShape<Desc>> {
// append chunk to buffer, returning updated buffer
function append(buffer: Uint8Array, chunk: Uint8Array): Uint8Array {
function append(
buffer: Uint8Array<ArrayBuffer>,
chunk: Uint8Array,
): Uint8Array<ArrayBuffer> {
const n = new Uint8Array(buffer.byteLength + chunk.byteLength);
n.set(buffer);
n.set(chunk, buffer.length);
Expand Down
6 changes: 3 additions & 3 deletions packages/protobuf/src/wire/text-encoding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ interface TextEncoding {
/**
* Encode UTF-8 text to binary.
*/
encodeUtf8: (text: string) => Uint8Array;
encodeUtf8: (text: string) => Uint8Array<ArrayBuffer>;
/**
* Decode UTF-8 text from binary.
*/
Expand Down Expand Up @@ -51,7 +51,7 @@ export function getTextEncoding() {
globalThis as unknown as GlobalWithTextEncoderDecoder
).TextDecoder();
(globalThis as GlobalWithTextEncoding)[symbol] = {
encodeUtf8(text: string): Uint8Array {
encodeUtf8(text: string): Uint8Array<ArrayBuffer> {
return te.encode(text);
},
decodeUtf8(bytes: Uint8Array): string {
Expand All @@ -77,7 +77,7 @@ type GlobalWithTextEncoding = {
type GlobalWithTextEncoderDecoder = {
TextEncoder: {
new (): {
encode(text: string): Uint8Array;
encode(text: string): Uint8Array<ArrayBuffer>;
};
};
TextDecoder: {
Expand Down
Loading