@foxglove/rosmsg
Advanced tools
Comparing version 5.0.2 to 5.0.3
{ | ||
"name": "@foxglove/rosmsg", | ||
"version": "5.0.2", | ||
"version": "5.0.3", | ||
"description": "Parser for ROS and ROS 2 .msg definitions", | ||
@@ -50,3 +50,3 @@ "license": "MIT", | ||
"dependencies": { | ||
"@foxglove/message-definition": "^0.2.0", | ||
"@foxglove/message-definition": "^0.3.1", | ||
"md5-typescript": "^1.0.5" | ||
@@ -53,0 +53,0 @@ }, |
@@ -237,2 +237,2 @@ # @foxglove/rosmsg | ||
Join our [Slack channel](https://foxglove.dev/join-slack) to ask questions, share feedback, and stay up to date on what our team is working on. | ||
Join our [Slack channel](https://foxglove.dev/slack) to ask questions, share feedback, and stay up to date on what our team is working on. |
@@ -626,2 +626,69 @@ // This file incorporates work covered by the following copyright and | ||
}); | ||
it("handles duplicate types", () => { | ||
const messageDefinition = ` | ||
foo_msgs/TypeA a | ||
foo_msgs/TypeB b | ||
================================================================================ | ||
MSG: foo_msgs/TypeA | ||
uint64 u | ||
================================================================================ | ||
MSG: foo_msgs/TypeB | ||
foo_msgs/TypeA a | ||
int32 i | ||
================================================================================ | ||
MSG: foo_msgs/TypeA | ||
uint64 u | ||
`; | ||
const types = parse(messageDefinition, { ros2: true }); | ||
expect(types).toEqual([ | ||
{ | ||
definitions: [ | ||
{ | ||
type: "foo_msgs/TypeA", | ||
isArray: false, | ||
name: "a", | ||
isComplex: true, | ||
}, | ||
{ | ||
type: "foo_msgs/TypeB", | ||
isArray: false, | ||
name: "b", | ||
isComplex: true, | ||
}, | ||
], | ||
}, | ||
{ | ||
name: "foo_msgs/TypeA", | ||
definitions: [ | ||
{ | ||
type: "uint64", | ||
isArray: false, | ||
name: "u", | ||
isComplex: false, | ||
}, | ||
], | ||
}, | ||
{ | ||
name: "foo_msgs/TypeB", | ||
definitions: [ | ||
{ | ||
type: "foo_msgs/TypeA", | ||
isArray: false, | ||
name: "a", | ||
isComplex: true, | ||
}, | ||
{ | ||
type: "int32", | ||
isArray: false, | ||
name: "i", | ||
isComplex: false, | ||
}, | ||
], | ||
}, | ||
]); | ||
}); | ||
}); |
@@ -1112,2 +1112,69 @@ // This file incorporates work covered by the following copyright and | ||
}); | ||
it("handles duplicate types", () => { | ||
const messageDefinition = ` | ||
foo_msgs/msg/TypeA a | ||
foo_msgs/msg/TypeB b | ||
================================================================================ | ||
MSG: foo_msgs/msg/TypeA | ||
uint64 u | ||
================================================================================ | ||
MSG: foo_msgs/msg/TypeB | ||
foo_msgs/msg/TypeA a | ||
int32 i | ||
================================================================================ | ||
MSG: foo_msgs/msg/TypeA | ||
uint64 u | ||
`; | ||
const types = parse(messageDefinition, { ros2: true }); | ||
expect(types).toEqual([ | ||
{ | ||
definitions: [ | ||
{ | ||
type: "foo_msgs/msg/TypeA", | ||
isArray: false, | ||
name: "a", | ||
isComplex: true, | ||
}, | ||
{ | ||
type: "foo_msgs/msg/TypeB", | ||
isArray: false, | ||
name: "b", | ||
isComplex: true, | ||
}, | ||
], | ||
}, | ||
{ | ||
name: "foo_msgs/msg/TypeA", | ||
definitions: [ | ||
{ | ||
type: "uint64", | ||
isArray: false, | ||
name: "u", | ||
isComplex: false, | ||
}, | ||
], | ||
}, | ||
{ | ||
name: "foo_msgs/msg/TypeB", | ||
definitions: [ | ||
{ | ||
type: "foo_msgs/msg/TypeA", | ||
isArray: false, | ||
name: "a", | ||
isComplex: true, | ||
}, | ||
{ | ||
type: "int32", | ||
isArray: false, | ||
name: "i", | ||
isComplex: false, | ||
}, | ||
], | ||
}, | ||
]); | ||
}); | ||
}); |
@@ -10,3 +10,7 @@ // This file incorporates work covered by the following copyright and | ||
import { MessageDefinition, MessageDefinitionField } from "@foxglove/message-definition"; | ||
import { | ||
MessageDefinition, | ||
MessageDefinitionField, | ||
isMsgDefEqual, | ||
} from "@foxglove/message-definition"; | ||
import { Grammar, Parser } from "nearley"; | ||
@@ -80,8 +84,18 @@ | ||
// Filter out duplicate types to handle the case where schemas are erroneously duplicated | ||
// e.g. caused by a bug in `mcap convert`. Removing duplicates here will avoid that searching | ||
// a type by name will return more than one result. | ||
const seenTypes: MessageDefinition[] = []; | ||
const uniqueTypes = types.filter((definition) => { | ||
return seenTypes.find((otherDefinition) => isMsgDefEqual(definition, otherDefinition)) | ||
? false | ||
: seenTypes.push(definition); // Always evaluates to true; | ||
}); | ||
// Fix up complex type names | ||
if (options.skipTypeFixup !== true) { | ||
fixupTypes(types); | ||
fixupTypes(uniqueTypes); | ||
} | ||
return types; | ||
return uniqueTypes; | ||
} | ||
@@ -88,0 +102,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 1 instance in 1 package
300847
4806
+ Added@foxglove/message-definition@0.3.1(transitive)
- Removed@foxglove/message-definition@0.2.0(transitive)