Skip to content

Commit

Permalink
Add includeTypedArrays option to generateTypeScript (#128)
Browse files Browse the repository at this point in the history
### Public-Facing Changes

Added an `includeTypedArrays` option to `generateTypeScript` to allow
generating type definitions that include TypedArrays in addition to
plain `number[]` arrays.

### Description

Relates FG-4976
See also https://github.com/foxglove/studio/pull/6890
  • Loading branch information
jtbandes authored Sep 27, 2023
1 parent 63f59f5 commit 3009ac7
Show file tree
Hide file tree
Showing 50 changed files with 239 additions and 7 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ jobs:
rm Linux.flatc.binary.clang++-12.zip
sudo mv flatc /usr/local/bin
- uses: arduino/setup-protoc@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/setup-node@v3
with:
node-version: 16.x
Expand Down Expand Up @@ -69,6 +71,8 @@ jobs:
steps:
- uses: actions/checkout@v3
- uses: arduino/setup-protoc@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Install Flatbuffer compiler
run: |
curl -LO https://github.com/google/flatbuffers/releases/download/v23.1.21/Linux.flatc.binary.clang++-12.zip
Expand Down
44 changes: 44 additions & 0 deletions internal/__snapshots__/exportTypeScriptSchemas.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
exports[`exportTypeScriptSchemas exports schemas 1`] = `
Map {
"ArrowPrimitive" => "// Generated by https://github.com/foxglove/schemas
// Options: {}
import { Color } from "./Color";
import { Pose } from "./Pose";
Expand All @@ -29,6 +30,7 @@ export type ArrowPrimitive = {
};
",
"CameraCalibration" => "// Generated by https://github.com/foxglove/schemas
// Options: {}
import { Time } from "./Time";
Expand Down Expand Up @@ -109,6 +111,7 @@ export type CameraCalibration = {
};
",
"CircleAnnotation" => "// Generated by https://github.com/foxglove/schemas
// Options: {}
import { Color } from "./Color";
import { Point2 } from "./Point2";
Expand Down Expand Up @@ -136,6 +139,7 @@ export type CircleAnnotation = {
};
",
"Color" => "// Generated by https://github.com/foxglove/schemas
// Options: {}
/** A color in RGBA format */
export type Color = {
Expand All @@ -153,6 +157,7 @@ export type Color = {
};
",
"CompressedImage" => "// Generated by https://github.com/foxglove/schemas
// Options: {}
import { Time } from "./Time";
Expand All @@ -176,6 +181,7 @@ export type CompressedImage = {
};
",
"CompressedVideo" => "// Generated by https://github.com/foxglove/schemas
// Options: {}
import { Time } from "./Time";
Expand All @@ -199,6 +205,7 @@ export type CompressedVideo = {
};
",
"CylinderPrimitive" => "// Generated by https://github.com/foxglove/schemas
// Options: {}
import { Color } from "./Color";
import { Pose } from "./Pose";
Expand All @@ -223,6 +230,7 @@ export type CylinderPrimitive = {
};
",
"CubePrimitive" => "// Generated by https://github.com/foxglove/schemas
// Options: {}
import { Color } from "./Color";
import { Pose } from "./Pose";
Expand All @@ -241,6 +249,7 @@ export type CubePrimitive = {
};
",
"FrameTransform" => "// Generated by https://github.com/foxglove/schemas
// Options: {}
import { Quaternion } from "./Quaternion";
import { Time } from "./Time";
Expand All @@ -265,6 +274,7 @@ export type FrameTransform = {
};
",
"FrameTransforms" => "// Generated by https://github.com/foxglove/schemas
// Options: {}
import { FrameTransform } from "./FrameTransform";
Expand All @@ -275,6 +285,7 @@ export type FrameTransforms = {
};
",
"GeoJSON" => "// Generated by https://github.com/foxglove/schemas
// Options: {}
/** GeoJSON data for annotating maps */
export type GeoJSON = {
Expand All @@ -283,6 +294,7 @@ export type GeoJSON = {
};
",
"Grid" => "// Generated by https://github.com/foxglove/schemas
// Options: {}
import { PackedElementField } from "./PackedElementField";
import { Pose } from "./Pose";
Expand Down Expand Up @@ -320,6 +332,7 @@ export type Grid = {
};
",
"ImageAnnotations" => "// Generated by https://github.com/foxglove/schemas
// Options: {}
import { CircleAnnotation } from "./CircleAnnotation";
import { PointsAnnotation } from "./PointsAnnotation";
Expand All @@ -338,6 +351,7 @@ export type ImageAnnotations = {
};
",
"KeyValuePair" => "// Generated by https://github.com/foxglove/schemas
// Options: {}
/** A key with its associated value */
export type KeyValuePair = {
Expand All @@ -349,6 +363,7 @@ export type KeyValuePair = {
};
",
"LaserScan" => "// Generated by https://github.com/foxglove/schemas
// Options: {}
import { Pose } from "./Pose";
import { Time } from "./Time";
Expand Down Expand Up @@ -378,6 +393,7 @@ export type LaserScan = {
};
",
"LinePrimitive" => "// Generated by https://github.com/foxglove/schemas
// Options: {}
import { Color } from "./Color";
import { LineType } from "./LineType";
Expand Down Expand Up @@ -416,6 +432,7 @@ export type LinePrimitive = {
};
",
"LocationFix" => "// Generated by https://github.com/foxglove/schemas
// Options: {}
import { PositionCovarianceType } from "./PositionCovarianceType";
import { Time } from "./Time";
Expand Down Expand Up @@ -445,6 +462,7 @@ export type LocationFix = {
};
",
"Log" => "// Generated by https://github.com/foxglove/schemas
// Options: {}
import { LogLevel } from "./LogLevel";
import { Time } from "./Time";
Expand All @@ -471,6 +489,7 @@ export type Log = {
};
",
"SceneEntityDeletion" => "// Generated by https://github.com/foxglove/schemas
// Options: {}
import { SceneEntityDeletionType } from "./SceneEntityDeletionType";
import { Time } from "./Time";
Expand All @@ -488,6 +507,7 @@ export type SceneEntityDeletion = {
};
",
"SceneEntity" => "// Generated by https://github.com/foxglove/schemas
// Options: {}
import { ArrowPrimitive } from "./ArrowPrimitive";
import { CubePrimitive } from "./CubePrimitive";
Expand Down Expand Up @@ -547,6 +567,7 @@ export type SceneEntity = {
};
",
"SceneUpdate" => "// Generated by https://github.com/foxglove/schemas
// Options: {}
import { SceneEntity } from "./SceneEntity";
import { SceneEntityDeletion } from "./SceneEntityDeletion";
Expand All @@ -561,6 +582,7 @@ export type SceneUpdate = {
};
",
"ModelPrimitive" => "// Generated by https://github.com/foxglove/schemas
// Options: {}
import { Color } from "./Color";
import { Pose } from "./Pose";
Expand Down Expand Up @@ -591,6 +613,7 @@ export type ModelPrimitive = {
};
",
"PackedElementField" => "// Generated by https://github.com/foxglove/schemas
// Options: {}
import { NumericType } from "./NumericType";
Expand All @@ -607,6 +630,7 @@ export type PackedElementField = {
};
",
"Point2" => "// Generated by https://github.com/foxglove/schemas
// Options: {}
/** A point representing a position in 2D space */
export type Point2 = {
Expand All @@ -618,6 +642,7 @@ export type Point2 = {
};
",
"Point3" => "// Generated by https://github.com/foxglove/schemas
// Options: {}
/** A point representing a position in 3D space */
export type Point3 = {
Expand All @@ -632,6 +657,7 @@ export type Point3 = {
};
",
"PointCloud" => "// Generated by https://github.com/foxglove/schemas
// Options: {}
import { PackedElementField } from "./PackedElementField";
import { Pose } from "./Pose";
Expand Down Expand Up @@ -659,6 +685,7 @@ export type PointCloud = {
};
",
"PointsAnnotation" => "// Generated by https://github.com/foxglove/schemas
// Options: {}
import { Color } from "./Color";
import { Point2 } from "./Point2";
Expand Down Expand Up @@ -690,6 +717,7 @@ export type PointsAnnotation = {
};
",
"Pose" => "// Generated by https://github.com/foxglove/schemas
// Options: {}
import { Quaternion } from "./Quaternion";
import { Vector3 } from "./Vector3";
Expand All @@ -704,6 +732,7 @@ export type Pose = {
};
",
"PoseInFrame" => "// Generated by https://github.com/foxglove/schemas
// Options: {}
import { Pose } from "./Pose";
import { Time } from "./Time";
Expand All @@ -721,6 +750,7 @@ export type PoseInFrame = {
};
",
"PosesInFrame" => "// Generated by https://github.com/foxglove/schemas
// Options: {}
import { Pose } from "./Pose";
import { Time } from "./Time";
Expand All @@ -738,6 +768,7 @@ export type PosesInFrame = {
};
",
"Quaternion" => "// Generated by https://github.com/foxglove/schemas
// Options: {}
/** A [quaternion](https://eater.net/quaternions) representing a rotation in 3D space */
export type Quaternion = {
Expand All @@ -755,6 +786,7 @@ export type Quaternion = {
};
",
"RawImage" => "// Generated by https://github.com/foxglove/schemas
// Options: {}
import { Time } from "./Time";
Expand Down Expand Up @@ -787,6 +819,7 @@ export type RawImage = {
};
",
"SpherePrimitive" => "// Generated by https://github.com/foxglove/schemas
// Options: {}
import { Color } from "./Color";
import { Pose } from "./Pose";
Expand All @@ -805,6 +838,7 @@ export type SpherePrimitive = {
};
",
"TextAnnotation" => "// Generated by https://github.com/foxglove/schemas
// Options: {}
import { Color } from "./Color";
import { Point2 } from "./Point2";
Expand Down Expand Up @@ -832,6 +866,7 @@ export type TextAnnotation = {
};
",
"TextPrimitive" => "// Generated by https://github.com/foxglove/schemas
// Options: {}
import { Color } from "./Color";
import { Pose } from "./Pose";
Expand All @@ -858,6 +893,7 @@ export type TextPrimitive = {
};
",
"TriangleListPrimitive" => "// Generated by https://github.com/foxglove/schemas
// Options: {}
import { Color } from "./Color";
import { Point3 } from "./Point3";
Expand Down Expand Up @@ -886,6 +922,7 @@ export type TriangleListPrimitive = {
};
",
"Vector2" => "// Generated by https://github.com/foxglove/schemas
// Options: {}
/** A vector in 2D space that represents a direction only */
export type Vector2 = {
Expand All @@ -897,6 +934,7 @@ export type Vector2 = {
};
",
"Vector3" => "// Generated by https://github.com/foxglove/schemas
// Options: {}
/** A vector in 3D space that represents a direction only */
export type Vector3 = {
Expand All @@ -911,6 +949,7 @@ export type Vector3 = {
};
",
"LineType" => "// Generated by https://github.com/foxglove/schemas
// Options: {}
/** An enumeration indicating how input points should be interpreted to create lines */
export enum LineType {
Expand All @@ -925,6 +964,7 @@ export enum LineType {
}
",
"LogLevel" => "// Generated by https://github.com/foxglove/schemas
// Options: {}
/** Log level */
export enum LogLevel {
Expand All @@ -942,6 +982,7 @@ export enum LogLevel {
}
",
"SceneEntityDeletionType" => "// Generated by https://github.com/foxglove/schemas
// Options: {}
/** An enumeration indicating which entities should match a SceneEntityDeletion command */
export enum SceneEntityDeletionType {
Expand All @@ -953,6 +994,7 @@ export enum SceneEntityDeletionType {
}
",
"NumericType" => "// Generated by https://github.com/foxglove/schemas
// Options: {}
/** Numeric type */
export enum NumericType {
Expand All @@ -976,6 +1018,7 @@ export enum NumericType {
}
",
"PointsAnnotationType" => "// Generated by https://github.com/foxglove/schemas
// Options: {}
/** Type of points annotation */
export enum PointsAnnotationType {
Expand All @@ -995,6 +1038,7 @@ export enum PointsAnnotationType {
}
",
"PositionCovarianceType" => "// Generated by https://github.com/foxglove/schemas
// Options: {}
/** Type of position covariance */
export enum PositionCovarianceType {
Expand Down
Loading

0 comments on commit 3009ac7

Please sign in to comment.