From 5651518e21f0a8035a73d5d177e72d2a0ce0dda2 Mon Sep 17 00:00:00 2001 From: Jacob Bandes-Storch Date: Fri, 1 Sep 2023 19:27:14 -0700 Subject: [PATCH] Use @foxglove/protobufjs fork --- typescript/support/package.json | 4 +- typescript/support/src/parseChannel.test.ts | 2 +- .../support/src/parseJsonSchema.test.ts | 2 +- typescript/support/src/parseProtobufSchema.ts | 6 +-- .../src/protobufDefinitionsToDatatypes.ts | 2 +- typescript/support/src/protobufDescriptors.ts | 4 +- typescript/support/typings/protobufjs.d.ts | 6 +-- yarn.lock | 42 +++++++++---------- 8 files changed, 34 insertions(+), 34 deletions(-) diff --git a/typescript/support/package.json b/typescript/support/package.json index 2c7031de76..366926a77b 100644 --- a/typescript/support/package.json +++ b/typescript/support/package.json @@ -53,6 +53,7 @@ }, "dependencies": { "@foxglove/message-definition": "^0.2.0", + "@foxglove/protobufjs": "0.0.1-toobject-bigint.1", "@foxglove/rosmsg": "^4.2.2", "@foxglove/rosmsg-serialization": "^2.0.1", "@foxglove/rosmsg2-serialization": "^2.0.2", @@ -62,7 +63,6 @@ "@foxglove/wasm-zstd": "^1.0.1", "@protobufjs/base64": "^1.1.2", "flatbuffers": "^23.5.26", - "flatbuffers_reflection": "^0.0.6", - "protobufjs": "^7.2.2" + "flatbuffers_reflection": "^0.0.6" } } diff --git a/typescript/support/src/parseChannel.test.ts b/typescript/support/src/parseChannel.test.ts index 7f46003718..89259029f1 100644 --- a/typescript/support/src/parseChannel.test.ts +++ b/typescript/support/src/parseChannel.test.ts @@ -1,5 +1,5 @@ +import { FileDescriptorSet, IFileDescriptorSet } from "@foxglove/protobufjs/ext/descriptor"; import fs from "fs"; -import { FileDescriptorSet, IFileDescriptorSet } from "protobufjs/ext/descriptor"; import { parseChannel } from "./parseChannel"; diff --git a/typescript/support/src/parseJsonSchema.test.ts b/typescript/support/src/parseJsonSchema.test.ts index 105fcc01eb..ce2bd9bb2b 100644 --- a/typescript/support/src/parseJsonSchema.test.ts +++ b/typescript/support/src/parseJsonSchema.test.ts @@ -1,5 +1,5 @@ +import * as protobufjs from "@foxglove/protobufjs"; import { foxgloveMessageSchemas, generateJsonSchema } from "@foxglove/schemas/internal"; -import * as protobufjs from "protobufjs"; import { parseJsonSchema } from "./parseJsonSchema"; diff --git a/typescript/support/src/parseProtobufSchema.ts b/typescript/support/src/parseProtobufSchema.ts index 8726158f08..2d3b0f785c 100644 --- a/typescript/support/src/parseProtobufSchema.ts +++ b/typescript/support/src/parseProtobufSchema.ts @@ -1,5 +1,5 @@ -import protobufjs from "protobufjs"; -import { FileDescriptorSet } from "protobufjs/ext/descriptor"; +import protobufjs from "@foxglove/protobufjs"; +import { FileDescriptorSet } from "@foxglove/protobufjs/ext/descriptor"; import { protobufDefinitionsToDatatypes, stripLeadingDot } from "./protobufDefinitionsToDatatypes"; import { MessageDefinitionMap } from "./types"; @@ -61,7 +61,7 @@ export function parseProtobufSchema( const deserialize = (data: ArrayBufferView) => { return rootType.toObject( rootType.decode(new Uint8Array(data.buffer, data.byteOffset, data.byteLength)), - { defaults: true }, + { defaults: true, longs: BigInt }, ); }; diff --git a/typescript/support/src/protobufDefinitionsToDatatypes.ts b/typescript/support/src/protobufDefinitionsToDatatypes.ts index 2265f291e1..dc28239272 100644 --- a/typescript/support/src/protobufDefinitionsToDatatypes.ts +++ b/typescript/support/src/protobufDefinitionsToDatatypes.ts @@ -1,5 +1,5 @@ import { MessageDefinitionField } from "@foxglove/message-definition"; -import protobufjs from "protobufjs"; +import protobufjs from "@foxglove/protobufjs"; import { MessageDefinitionMap } from "./types"; diff --git a/typescript/support/src/protobufDescriptors.ts b/typescript/support/src/protobufDescriptors.ts index fb572a7a5b..42678d43dc 100644 --- a/typescript/support/src/protobufDescriptors.ts +++ b/typescript/support/src/protobufDescriptors.ts @@ -1,8 +1,8 @@ // eslint-disable-next-line @typescript-eslint/triple-slash-reference /// -import protobufjs from "protobufjs"; -import { FileDescriptorSet } from "protobufjs/ext/descriptor"; +import protobufjs from "@foxglove/protobufjs"; +import { FileDescriptorSet } from "@foxglove/protobufjs/ext/descriptor"; export type ProtobufDescriptor = ReturnType; diff --git a/typescript/support/typings/protobufjs.d.ts b/typescript/support/typings/protobufjs.d.ts index 8c0445835e..61be38e80a 100644 --- a/typescript/support/typings/protobufjs.d.ts +++ b/typescript/support/typings/protobufjs.d.ts @@ -1,8 +1,8 @@ -import protobufjs from "protobufjs"; -import descriptor from "protobufjs/ext/descriptor"; +import protobufjs from "@foxglove/protobufjs"; +import descriptor from "@foxglove/protobufjs/ext/descriptor"; // https://github.com/protobufjs/protobuf.js/issues/1499 -declare module "protobufjs" { +declare module "@foxglove/protobufjs" { interface ReflectionObject { toDescriptor( protoVersion: string, diff --git a/yarn.lock b/yarn.lock index 2fa42f4696..c296d630da 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2963,6 +2963,26 @@ __metadata: languageName: node linkType: hard +"@foxglove/protobufjs@npm:0.0.1-toobject-bigint.1": + version: 0.0.1-toobject-bigint.1 + resolution: "@foxglove/protobufjs@npm:0.0.1-toobject-bigint.1" + dependencies: + "@protobufjs/aspromise": ^1.1.2 + "@protobufjs/base64": ^1.1.2 + "@protobufjs/codegen": ^2.0.4 + "@protobufjs/eventemitter": ^1.1.0 + "@protobufjs/fetch": ^1.1.0 + "@protobufjs/float": ^1.0.2 + "@protobufjs/inquire": ^1.1.0 + "@protobufjs/path": ^1.1.2 + "@protobufjs/pool": ^1.1.0 + "@protobufjs/utf8": ^1.1.0 + "@types/node": ">=13.7.0" + long: ^5.0.0 + checksum: bce02c9a255116927fe327a7fce1dde8682ff0e742064a0120e7944d346385e28aecc315030c5560afc0208eaf1448d2a36b87f9f424531b7dd06e1b18100808 + languageName: node + linkType: hard + "@foxglove/rosbag@npm:0.2.3": version: 0.2.3 resolution: "@foxglove/rosbag@npm:0.2.3" @@ -3570,6 +3590,7 @@ __metadata: dependencies: "@foxglove/eslint-plugin": 0.21.0 "@foxglove/message-definition": ^0.2.0 + "@foxglove/protobufjs": 0.0.1-toobject-bigint.1 "@foxglove/rosmsg": ^4.2.2 "@foxglove/rosmsg-serialization": ^2.0.1 "@foxglove/rosmsg2-serialization": ^2.0.2 @@ -3595,7 +3616,6 @@ __metadata: flatbuffers_reflection: ^0.0.6 jest: 29.4.3 prettier: 2.8.4 - protobufjs: ^7.2.2 ts-jest: 29.0.5 typescript: 4.9.5 languageName: unknown @@ -12662,26 +12682,6 @@ __metadata: languageName: node linkType: hard -"protobufjs@npm:^7.2.2": - version: 7.2.4 - resolution: "protobufjs@npm:7.2.4" - dependencies: - "@protobufjs/aspromise": ^1.1.2 - "@protobufjs/base64": ^1.1.2 - "@protobufjs/codegen": ^2.0.4 - "@protobufjs/eventemitter": ^1.1.0 - "@protobufjs/fetch": ^1.1.0 - "@protobufjs/float": ^1.0.2 - "@protobufjs/inquire": ^1.1.0 - "@protobufjs/path": ^1.1.2 - "@protobufjs/pool": ^1.1.0 - "@protobufjs/utf8": ^1.1.0 - "@types/node": ">=13.7.0" - long: ^5.0.0 - checksum: a952cdf2a5e5250c16ae651b570849b6f5b20a5475c3eef63ffb290ad239aa2916adfc1cc676f7fc93c69f48113df268761c0c246f7f023118c85bdd1a170044 - languageName: node - linkType: hard - "proxy-addr@npm:~2.0.7": version: 2.0.7 resolution: "proxy-addr@npm:2.0.7"